-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
131 lines (119 loc) · 2.82 KB
/
test.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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
from Utils import Util
import requests
import json
gateway = {
'id':
'xxxxxxxyy1',
'Name':
'...test gateway.1.',
'version':
23,
'Devices': [{
'Id':
11,
'Dev_type':
'light',
'Name':
'.....',
'Dev_model':
'2012D',
'Dev_code':
'90010A58',
'device_key': [{
'dev_key_seq': 0,
'name': '...'
}, {
'dev_key_seq': 2,
'name': '..22.'
}]
}],
'Scenes': [{
'Id':
14,
'Name':
'..',
'Scence_contents': [{
'Id': 12,
'Dev_id': 9,
'dev_key_seq': 1,
'value': 1
}, {
'Id': 13,
'Dev_id': 9,
'dev_key_seq': 2,
'value': 2
}]
}],
'Contactors': [{
'Id': 12,
'Name': '...',
'Mobile_phone': '139123xxxx'
}],
'Containers': [{
'name': ' ..',
'device_ids': [2, 34, 11]
}]
}
def main():
# print( requests.get('http://121.42.12.11:81/a').text)
# return
root_url = "http://121.42.12.11:81/api"
# test message push
data = json.dumps({
'messages': {
'dest_type':
'ios',
'dest_id':
'fcd2b568a140331e0125d4fba658fec8a11b26061c19e9eb7c7f4ad8a05014a6',
'content':
'test message'
},
'data': 'some test repo'
})
print(data)
print(json.loads(data))
# r = requests.post(root_url+'/messages', data, verify=False)
# print ('result of push-message:', r.text)
# test Add Gateway
request = {
'version': 'xx',
'addgateway': {
'sessionid': 'xxxxxxxxxxxxxxxxxxx',
'gateway': gateway
}
}
r = requests.post(root_url + '/gateway', json.dumps(request), verify=False)
print('result of add gateway:', r.text)
# test Update Gateway
request = {
'version': 'xx',
'updategateway': {
'sessionid': 'xxxxxxxxxxxxxxxxxxx',
'gateway': {
'id': 'xxxxxxxyy1',
'property_test': 1,
'version': 23
}
}
}
r = requests.put(
root_url + '/gateway/1', data=json.dumps(request), verify=False)
print('result of modify gateway:', r.text)
return
# test Delete Gateway
request = {
'version': 'xx',
'deletegateway': {
'sessionid': 'xxxxxxxxxxxxxxxxxxx',
'gateway': {
'id': 'xxxxxxxyy1',
'property_test': 1
}
}
}
r = requests.delete(
root_url + '/gateway/1', data=json.dumps(request), verify=False)
print('result of delete gateway', r.text)
if __name__ == '__main__':
main()
pass