Commit 8a860036 authored by hupantingxue's avatar hupantingxue

1. Fix python 3 version issues;

2. Modify message test case;
parent f0a70670
...@@ -45,13 +45,13 @@ def ios(alert=None, badge=None, sound=None, content_available=False, ...@@ -45,13 +45,13 @@ def ios(alert=None, badge=None, sound=None, content_available=False,
""" """
payload = {} payload = {}
if alert is not None: if alert is not None:
if not isinstance(alert, basestring) or isinstance(alert, dict): if not isinstance(alert, str) or isinstance(alert, dict):
raise ValueError("iOS alert must be a string or dictionary") raise ValueError("iOS alert must be a string or dictionary")
payload['alert'] = alert payload['alert'] = alert
if badge is not None: if badge is not None:
if not (isinstance(badge, basestring) or isinstance(badge, int)): if not (isinstance(badge, str) or isinstance(badge, int)):
raise ValueError("iOS badge must be an integer or string") raise ValueError("iOS badge must be an integer or string")
if isinstance(badge, basestring) and not VALID_AUTOBADGE.match(badge): if isinstance(badge, str) and not VALID_AUTOBADGE.match(badge):
raise ValueError("Invalid iOS autobadge value") raise ValueError("Invalid iOS autobadge value")
payload['badge'] = badge payload['badge'] = badge
if sound is not None: if sound is not None:
...@@ -94,7 +94,7 @@ def winphone(alert, title=None, _open_page=None, extras=None): ...@@ -94,7 +94,7 @@ def winphone(alert, title=None, _open_page=None, extras=None):
Must include exactly one of ``alert``, ``title``, ``_open_page``, or ``extras``. Must include exactly one of ``alert``, ``title``, ``_open_page``, or ``extras``.
""" """
if len(filter(None, (alert, _open_page, title))) != 1: if len(list(filter(None, (alert, _open_page, title)))) != 1:
raise ValueError("MPNS payload must have one notification type.") raise ValueError("MPNS payload must have one notification type.")
payload = {} payload = {}
if alert is not None: if alert is not None:
......
#-*- coding:utf-8 -*-
import unittest import unittest
import jpush as jpush import jpush as jpush
class TestMessage(unittest.TestCase): class TestMessage(unittest.TestCase):
def test_simple_alert(self): def test_simple_alert(self):
self.assertEqual(jpush.notification(alert='Hello'), {'alert':'Hello'}) self.assertEqual(jpush.notification(alert='中文'), {'alert':'中文'})
def test_ios(self): def test_ios(self):
self.assertEqual( self.assertEqual(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment