forked from pubnub/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_stringify.py
More file actions
96 lines (70 loc) · 4.02 KB
/
test_stringify.py
File metadata and controls
96 lines (70 loc) · 4.02 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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import unittest
from pubnub.crypto import PubNubCryptodome
from pubnub.pnconfiguration import PNConfiguration
from pubnub.models.consumer.access_manager import PNAccessManagerAuditResult, PNAccessManagerGrantResult
from pubnub.models.consumer.channel_group import PNChannelGroupsListResult, PNChannelGroupsAddChannelResult, \
PNChannelGroupsRemoveGroupResult, PNChannelGroupsRemoveChannelResult
from pubnub.models.consumer.history import PNHistoryResult, PNHistoryItemResult
from pubnub.models.consumer.presence import PNHereNowResult, PNHereNowChannelData, PNHereNowOccupantsData, \
PNWhereNowResult, PNSetStateResult, PNGetStateResult
from pubnub.models.consumer.pubsub import PNPublishResult
from pubnub.models.consumer.push import PNPushListProvisionsResult, PNPushAddChannelResult, PNPushRemoveChannelResult, \
PNPushRemoveAllChannelsResult
class TestStringify(unittest.TestCase):
def test_publish(self):
assert str(PNPublishResult(None, 123123)) == "Publish success with timetoken 123123"
def test_add_channel_to_group(self):
assert str(PNChannelGroupsAddChannelResult()) == "Channel successfully added"
def test_remove_channel_from_group(self):
assert str(PNChannelGroupsRemoveChannelResult()) == "Channel successfully removed"
def test_remove_channel_group(self):
assert str(PNChannelGroupsRemoveGroupResult()) == "Group successfully removed"
def test_list_channel_group(self):
result = PNChannelGroupsListResult([
'qwer',
'asdf',
'zxcv'
])
assert str(result) == "Group contains following channels: qwer, asdf, zxcv"
def test_audit(self):
result = PNAccessManagerAuditResult(None, None, None, None, None, 3600, True, False, True, False)
assert str(result) == \
"Current permissions are valid for 3600 minutes: read True, write False, manage: True, delete: False"
def test_grant(self):
result = PNAccessManagerGrantResult(None, None, None, None, None, 3600, True, False, True, False)
assert str(result) == \
"New permissions are set for 3600 minutes: read True, write False, manage: True, delete: False"
def test_history(self):
assert str(PNHistoryResult(None, 123, 789)) == "History result for range 123..789"
def test_history_item(self):
assert str(PNHistoryItemResult({'blah': 2}, PubNubCryptodome(PNConfiguration()), 123)) == \
"History item with tt: 123 and content: {'blah': 2}"
assert str(PNHistoryItemResult({'blah': 2}, PubNubCryptodome(PNConfiguration()))) == \
"History item with tt: None and content: {'blah': 2}"
def test_here_now(self):
assert str(PNHereNowResult(7, 4, None)) == "HereNow Result total occupancy: 4, total channels: 7"
def test_here_now_channel_data(self):
assert str(PNHereNowChannelData('blah', 5, 9)) == \
"HereNow Channel Data for channel 'blah': occupancy: 5, occupants: 9"
def test_here_now_occupants_data(self):
assert str(PNHereNowOccupantsData('myuuid', {'blah': 3})) == \
"HereNow Occupants Data for 'myuuid': {'blah': 3}"
def test_where_now(self):
assert str(PNWhereNowResult(['qwer', 'asdf'])) == \
"User is currently subscribed to qwer, asdf"
def test_set_state(self):
assert str(PNSetStateResult({})) == "New state {} successfully set"
def test_get_state(self):
assert str(PNGetStateResult({})) == "Current state is {}"
def test_push_list(self):
assert str(PNPushListProvisionsResult(['qwer', 'asdf'])) == \
"Push notification enabled on following channels: qwer, asdf"
def test_push_add(self):
assert str(PNPushAddChannelResult()) == \
"Channel successfully added"
def test_push_remove(self):
assert str(PNPushRemoveChannelResult()) == \
"Channel successfully removed"
def test_push_remove_all(self):
assert str(PNPushRemoveAllChannelsResult()) == \
"All channels successfully removed"