Commit f0a70670 authored by hupantingxue's avatar hupantingxue

1. Add message test cases;

2. Update payload;
parent 3689ee0e
......@@ -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``.
"""
if len(filter(None, (alert, toast, tile))) != 1:
if len(filter(None, (alert, _open_page, title))) != 1:
raise ValueError("MPNS payload must have one notification type.")
payload = {}
if alert is not None:
......
import unittest
import jpush as jpush
class TestMessage(unittest.TestCase):
def test_simple_alert(self):
self.assertEqual(jpush.notification(alert='Hello'), {'alert':'Hello'})
def test_ios(self):
self.assertEqual(
jpush.notification(ios=jpush.ios(alert="Hello", badge="+1", sound="a.caf", extras={'k1':'v1'})),
{'ios': {'sound': 'a.caf', 'extras': {'k1': 'v1'}, 'badge': '+1', 'alert': 'Hello'}}
)
def test_android(self):
self.assertEqual(
jpush.notification(android=jpush.android(alert="Hello", extras={'k2':'v2'})),
{'android': {'extras': {'k2': 'v2'}, 'alert': 'Hello'}}
)
def test_winphone(self):
self.assertEqual(
jpush.notification(winphone=jpush.winphone(alert="Hello", extras={'k3':'v3'})),
{'winphone': {'extras': {'k3': 'v3'}, 'alert': 'Hello'}}
)
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