-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest_push_notifications.py
77 lines (66 loc) · 2.5 KB
/
test_push_notifications.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""Unit tests for Pusher Push Notifications Python server SDK"""
import unittest
from pusher_push_notifications import (
PushNotifications,
)
class TestPushNotifications(unittest.TestCase):
def test_constructor_should_accept_valid_params(self):
PushNotifications(
instance_id='1234',
secret_key='1234',
)
def test_constructor_should_fail_if_instance_id_not_string(self):
with self.assertRaises(TypeError) as e:
PushNotifications(
instance_id=False,
secret_key='1234',
)
self.assertIn('instance_id must be a string', str(e.exception))
def test_constructor_should_fail_if_instance_id_empty_string(self):
with self.assertRaises(ValueError) as e:
PushNotifications(
instance_id='',
secret_key='1234',
)
self.assertIn('instance_id cannot be the empty string', str(e.exception))
def test_constructor_should_fail_if_secret_key_not_string(self):
with self.assertRaises(TypeError) as e:
PushNotifications(
instance_id='1234',
secret_key=False,
)
self.assertIn('secret_key must be a string', str(e.exception))
def test_constructor_should_fail_if_secret_key_empty_string(self):
with self.assertRaises(ValueError) as e:
PushNotifications(
instance_id='1234',
secret_key='',
)
self.assertIn('secret_key cannot be the empty string', str(e.exception))
def test_constructor_should_fail_if_endpoint_not_string(self):
with self.assertRaises(TypeError) as e:
PushNotifications(
instance_id='1234',
secret_key='1234',
endpoint=False,
)
self.assertIn('endpoint must be a string', str(e.exception))
def test_constructor_should_set_endpoint_default(self):
pn_client = PushNotifications(
instance_id='INSTANCE_ID',
secret_key='1234',
)
self.assertEqual(
pn_client.endpoint,
'instance_id.pushnotifications.pusher.com',
)
def test_constructor_should_accept_endpoint_override(self):
pn_client = PushNotifications(
instance_id='INSTANCE_ID',
secret_key='1234',
endpoint='example.com/push',
)
self.assertEqual(
pn_client.endpoint,
'example.com/push',
)