-
Notifications
You must be signed in to change notification settings - Fork 1
/
fakeMsg.py
164 lines (139 loc) · 5.8 KB
/
fakeMsg.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import uuid
from datetime import datetime
import urllib2
import urllib
def make_request(msg,phone="18182124554"):
data = urllib.urlencode({ "message" : msg,
"number" : phone,
"uuid" : str(uuid.uuid4()) })
return urllib2.Request(
data=data,url="http://localhost:6543/interface/send/8")
def test_consumer_messages():
account = "ijr495"
token = 38902754073
response = urllib2.urlopen(make_request("bal." + account))
print("----------------------------")
print("testing english balance")
print(response.read())
print("-----------------------------")
response = urllib2.urlopen(make_request("bal.1234"))
print("----------------------------")
print("testing english balance fail conition")
print(response.read())
print("-----------------------------")
response = urllib2.urlopen(make_request("solde." + account))
print("----------------------------")
print("testing french balance")
print(response.read())
print("----------------------------")
response = urllib2.urlopen(make_request("solde.12345"))
print("----------------------------")
print("testing french balance fail conition")
print(response.read())
print("----------------------------")
response = urllib2.urlopen(make_request("prim." + account + ".18182124554"))
print("----------------------------")
print("set primary number english")
print(response.read())
print("----------------------------")
response = urllib2.urlopen(make_request("tel." + account + ".18185846103"))
print("----------------------------")
print("set primary number fr")
print(response.read())
print("----------------------------")
response = urllib2.urlopen(
make_request("add." + account + "." + str(token)))
print("----------------------------")
print("add credit in en")
print(response.read())
print("----------------------------")
response = urllib2.urlopen(
make_request("recharge." + account +"." + str(token)))
print("----------------------------")
print("add credit in fr")
print(response.read())
print("----------------------------")
response = urllib2.urlopen(make_request("on." + account))
print("----------------------------")
print("turn the circuit on fr/en ")
print(response.read())
print("----------------------------")
response = urllib2.urlopen(make_request("off." + account))
print("----------------------------")
print("turn the circuit off fr/en ")
print(response.read())
print("----------------------------")
response = urllib2.urlopen(make_request("use." + account))
print("----------------------------")
print("testing use en")
print(response.read())
print("----------------------------")
response = urllib2.urlopen(make_request("conso." + account))
print("----------------------------")
print("testing use fr")
print(response.read())
print("----------------------------")
response = urllib2.urlopen(make_request("this should fail" + account))
print("----------------------------")
print("test failure with a response")
print(response.read())
print("----------------------------")
def test_meter_messages():
cid = "192.168.1.201"
meter_name = "demo001"
# test primary log
response = urllib2.urlopen(
make_request("(job=pp&cid=" + cid + "&mid=" + meter_name + "&wh=10.00&tu=12.12&ts=20110107192318&cr=20.10&status=1)",phone="18185846103"))
print("----------------------------")
print("testing primary log")
print(response.read())
print("----------------------------")
response = urllib2.urlopen(
make_request("(job=delete&status=1&tu=2256&ts=20110107192318&wh=9.7&cr=475.95&jobid=90&ct=CIRCUIT)",phone="13474594669"))
print("----------------------------")
print("testing primary log")
print(response.read())
print("----------------------------")
response = urllib2.urlopen(
make_request("(job=alerts&mid=" +
meter_name + "&cid=" + cid + "&alert=md)",phone="18185846103"))
print("----------------------------")
print("testing alert meter down")
print(response.read())
print("----------------------------")
# test meter sd card not found
response = urllib2.urlopen(
make_request("(job=alerts&mid=" +
meter_name + "&cid=" + cid + "&alert=sdc)",phone="18185846103"))
print("----------------------------")
print("testing alert test meter sd card not found")
print(response.read())
print("----------------------------")
# test circuit low credit
response = urllib2.urlopen(
make_request("(job=alerts&mid=" +
meter_name + "&cid=" + cid
+ "&alert=lcw&cr=10.00)",phone="18185846103"))
print("----------------------------")
print("testing alert low credit")
print(response.read())
print("----------------------------")
# test circuit no credit
response = urllib2.urlopen(
make_request("(job=alerts&mid="
+ meter_name + "&cid="
+ cid + "&alert=nocw&cr=00.00)",phone="18185846103"))
print("----------------------------")
print("testing alert no credit")
print(response.read())
print("----------------------------")
# test circuit compontent failure
response = urllib2.urlopen(
make_request("(job=alerts&mid="
+ meter_name + "&cid=" + cid + "&alert=ce)",phone="18185846103"))
print("----------------------------")
print("testing alert ce")
print(response.read())
print("----------------------------")
test_consumer_messages()
#test_meter_messages()