From b6c9ec85c6b899fd2704391e1438bdcf3395d32f Mon Sep 17 00:00:00 2001 From: shiyuchong <37971286+shiyuchong@users.noreply.github.com> Date: Fri, 2 Aug 2019 21:19:55 +0800 Subject: [PATCH] fix a python 3.x test problem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the order of the result in Payload.dict() changed after python upgrade,which caused a failure in test in python 3.6. And now it has been fixed. --- apns.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/apns.py b/apns.py index 33655b1..47ac8a0 100644 --- a/apns.py +++ b/apns.py @@ -321,6 +321,13 @@ def __init__(self, alert=None, badge=None, sound=None, category=None, custom=Non def dict(self): """Returns the payload as a regular Python dictionary""" d = {} + + if self.sound: + d['sound'] = self.sound + if self.badge is not None: + d['badge'] = int(self.badge) + if self.category: + d['category'] = self.category if self.alert: # Alert can be either a string or a PayloadAlert # object @@ -328,13 +335,7 @@ def dict(self): d['alert'] = self.alert.dict() else: d['alert'] = self.alert - if self.sound: - d['sound'] = self.sound - if self.badge is not None: - d['badge'] = int(self.badge) - if self.category: - d['category'] = self.category - + if self.content_available: d.update({'content-available': 1})