forked from jpush/jpush-api-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_entity.py
More file actions
33 lines (26 loc) · 1.26 KB
/
Copy pathtest_entity.py
File metadata and controls
33 lines (26 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import unittest
import jpush
class TestEntity(unittest.TestCase):
def test_basic_entity(self):
entities = (
(jpush.add, 'tag1', {'add': ['tag1']}),
(jpush.remove, 'tag1', {'remove': ['tag1']}),
(jpush.device_tag, 'tag1', {'tags': 'tag1'}),
(jpush.device_alias, 'alias1', {'alias': 'alias1'}),
(jpush.device_regid, 'registration_id1', {'registration_ids': 'registration_id1'}),
)
for entity, value, result in entities:
self.assertEqual(entity(value), result)
def test_compound_entity(self):
self.assertEqual(
jpush.device_tag(jpush.add("tag1", "tag2")),
{'tags':{'add':['tag1', 'tag2']}})
self.assertEqual(
jpush.device_tag(jpush.remove("tag1", "tag2")),
{'tags':{'remove':['tag1', 'tag2']}})
self.assertEqual(
jpush.device_alias(jpush.add("alias1", "alias2"), jpush.remove("alias3", "alias4")),
{'alias':{'add':['alias1', 'alias2'], 'remove':['alias3', 'alias4']}})
self.assertEqual(
jpush.device_regid(jpush.add("regid1", "regid2"), jpush.remove("regid3", "regid4")),
{'registration_ids':{'add':['regid1', 'regid2'], 'remove':['regid3', 'regid4']}})