blob: a823e449c2f5ed05275702709e10c8228dce0341 (
plain)
| 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
97
98
99
100
101
102
103
104
105
106
107
 | from Pubnub import Pubnub
import time
import random
pubnub = Pubnub("demo","demo")
pubnub.set_u(True)
def rand_str(s):
	return str(s) + '-' + str(random.randint(1, 100000000000))
def test_1():
	channel 		= rand_str('channel')
	channel2 		= rand_str('channel')
	channel_group 	= rand_str('group')
	channel_group2  = rand_str('group')
	namespace       = rand_str('ns')
	resp = pubnub.channel_group_add_channel(channel_group=namespace + ':' + channel_group, channel=channel)
	assert resp['status'] 	== 200
	assert resp['message'] 	== 'OK'
	assert resp['error'] 	== False
	resp = pubnub.channel_group_add_channel(channel_group=namespace + ':' + channel_group, channel=channel2)
	assert resp['status'] 	== 200
	assert resp['message'] 	== 'OK'
	assert resp['error'] 	== False
	resp = pubnub.channel_group_add_channel(channel_group=namespace + ':' + channel_group2, channel=channel)
	assert resp['status'] 	== 200
	assert resp['message'] 	== 'OK'
	assert resp['error'] 	== False
	resp = pubnub.channel_group_add_channel(channel_group=namespace + ':' + channel_group2, channel=channel2)
	assert resp['status'] 	== 200
	assert resp['message'] 	== 'OK'
	assert resp['error'] 	== False
	resp = pubnub.channel_group_list_channels(channel_group=namespace + ':' + channel_group)
	assert channel in resp['payload']['channels']
	assert channel2 in resp['payload']['channels']
	assert len(resp['payload']['channels']) == 2
	resp = pubnub.channel_group_remove_channel(channel_group=namespace + ':' + channel_group, channel=channel2)
	print resp
	assert resp['status'] 	== 200
	assert resp['message'] 	== 'OK'
	assert resp['error'] 	== False
	resp = pubnub.channel_group_list_channels(channel_group=namespace + ':' + channel_group)
	print resp
	assert channel in resp['payload']['channels']
	assert len(resp['payload']['channels']) == 1
	resp = pubnub.channel_group_list_channels(channel_group=namespace + ':' + channel_group2)
	assert channel in resp['payload']['channels']
	assert channel2 in resp['payload']['channels']
	assert len(resp['payload']['channels']) == 2
	resp = pubnub.channel_group_remove_channel(channel_group=namespace + ':' + channel_group2, channel=channel2)
	print resp
	assert resp['status'] 	== 200
	assert resp['message'] 	== 'OK'
	assert resp['error'] 	== False
	resp = pubnub.channel_group_list_channels(channel_group=namespace + ':' + channel_group2)
	print resp
	assert channel in resp['payload']['channels']
	assert len(resp['payload']['channels']) == 1
	resp = pubnub.channel_group_list_groups(namespace=namespace)
	assert channel_group in resp['payload']['groups']
	assert channel_group2 in resp['payload']['groups']
	assert len(resp['payload']['groups']) == 2
	resp = pubnub.channel_group_remove_group(channel_group=namespace + ':' + channel_group2)
	print resp
	assert resp['status'] 	== 200
	assert resp['message'] 	== 'OK'
	assert resp['error'] 	== False
	resp = pubnub.channel_group_list_groups(namespace=namespace)
	assert channel_group in resp['payload']['groups']
	assert len(resp['payload']['groups']) == 1
	resp = pubnub.channel_group_list_namespaces()
	assert namespace in resp['payload']['namespaces']
	resp = pubnub.channel_group_remove_namespace(namespace=namespace)
	print resp
	assert resp['status'] 	== 200
	assert resp['message'] 	== 'OK'
	assert resp['error'] 	== False
	resp = pubnub.channel_group_list_namespaces()
	assert namespace not in resp['payload']['namespaces']
 |