1
|
|
|
import unittest |
2
|
|
|
from django.core.urlresolvers import reverse |
3
|
|
|
from django.test import Client |
4
|
|
|
from .models import Version, Location, LocationAttrs, UserBlackList, GlobalBlackList, SpeedDial, PipeLimit, Mtree, Mtrees, Htable |
5
|
|
|
from django.contrib.auth.models import User |
6
|
|
|
from django.contrib.auth.models import Group |
7
|
|
|
from django.contrib.contenttypes.models import ContentType |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
def create_django_contrib_auth_models_user(**kwargs): |
11
|
|
|
defaults = {} |
12
|
|
|
defaults["username"] = "username" |
13
|
|
|
defaults["email"] = "[email protected]" |
14
|
|
|
defaults.update(**kwargs) |
15
|
|
|
return User.objects.create(**defaults) |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
def create_django_contrib_auth_models_group(**kwargs): |
19
|
|
|
defaults = {} |
20
|
|
|
defaults["name"] = "group" |
21
|
|
|
defaults.update(**kwargs) |
22
|
|
|
return Group.objects.create(**defaults) |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
def create_django_contrib_contenttypes_models_contenttype(**kwargs): |
26
|
|
|
defaults = {} |
27
|
|
|
defaults.update(**kwargs) |
28
|
|
|
return ContentType.objects.create(**defaults) |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
def create_version(**kwargs): |
32
|
|
|
defaults = {} |
33
|
|
|
defaults["table_name"] = "table_name" |
34
|
|
|
defaults["table_version"] = "table_version" |
35
|
|
|
defaults.update(**kwargs) |
36
|
|
|
return Version.objects.create(**defaults) |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
def create_location(**kwargs): |
40
|
|
|
defaults = {} |
41
|
|
|
defaults["ruid"] = "ruid" |
42
|
|
|
defaults["username"] = "username" |
43
|
|
|
defaults["domain"] = "domain" |
44
|
|
|
defaults["contact"] = "contact" |
45
|
|
|
defaults["received"] = "received" |
46
|
|
|
defaults["path"] = "path" |
47
|
|
|
defaults["expires"] = "expires" |
48
|
|
|
defaults["q"] = "q" |
49
|
|
|
defaults["callid"] = "callid" |
50
|
|
|
defaults["cseq"] = "cseq" |
51
|
|
|
defaults["last_modified"] = "last_modified" |
52
|
|
|
defaults["flags"] = "flags" |
53
|
|
|
defaults["cfags"] = "cfags" |
54
|
|
|
defaults["user_agent"] = "user_agent" |
55
|
|
|
defaults["socket"] = "socket" |
56
|
|
|
defaults["methods"] = "methods" |
57
|
|
|
defaults["instance"] = "instance" |
58
|
|
|
defaults["reg_id"] = "reg_id" |
59
|
|
|
defaults["server_id"] = "server_id" |
60
|
|
|
defaults["connection_id"] = "connection_id" |
61
|
|
|
defaults["keepalive"] = "keepalive" |
62
|
|
|
defaults["partition"] = "partition" |
63
|
|
|
defaults.update(**kwargs) |
64
|
|
|
return Location.objects.create(**defaults) |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
def create_locationattrs(**kwargs): |
68
|
|
|
defaults = {} |
69
|
|
|
defaults["ruid"] = "ruid" |
70
|
|
|
defaults["username"] = "username" |
71
|
|
|
defaults["domain"] = "domain" |
72
|
|
|
defaults["aname"] = "aname" |
73
|
|
|
defaults["atype"] = "atype" |
74
|
|
|
defaults["avalue"] = "avalue" |
75
|
|
|
defaults["last_modified"] = "last_modified" |
76
|
|
|
defaults.update(**kwargs) |
77
|
|
|
return LocationAttrs.objects.create(**defaults) |
78
|
|
|
|
79
|
|
|
|
80
|
|
|
def create_userblacklist(**kwargs): |
81
|
|
|
defaults = {} |
82
|
|
|
defaults["username"] = "username" |
83
|
|
|
defaults["domain"] = "domain" |
84
|
|
|
defaults["prefix"] = "prefix" |
85
|
|
|
defaults["whitelist"] = "whitelist" |
86
|
|
|
defaults.update(**kwargs) |
87
|
|
|
return UserBlackList.objects.create(**defaults) |
88
|
|
|
|
89
|
|
|
|
90
|
|
|
def create_globalblacklist(**kwargs): |
91
|
|
|
defaults = {} |
92
|
|
|
defaults["prefix"] = "prefix" |
93
|
|
|
defaults["whitelist"] = "whitelist" |
94
|
|
|
defaults["description"] = "description" |
95
|
|
|
defaults.update(**kwargs) |
96
|
|
|
return GlobalBlackList.objects.create(**defaults) |
97
|
|
|
|
98
|
|
|
|
99
|
|
|
def create_speeddial(**kwargs): |
100
|
|
|
defaults = {} |
101
|
|
|
defaults["username"] = "username" |
102
|
|
|
defaults["domain"] = "domain" |
103
|
|
|
defaults["sd_username"] = "sd_username" |
104
|
|
|
defaults["sd_domain"] = "sd_domain" |
105
|
|
|
defaults["new_uri"] = "new_uri" |
106
|
|
|
defaults["fname"] = "fname" |
107
|
|
|
defaults["lname"] = "lname" |
108
|
|
|
defaults["description"] = "description" |
109
|
|
|
defaults.update(**kwargs) |
110
|
|
|
return SpeedDial.objects.create(**defaults) |
111
|
|
|
|
112
|
|
|
|
113
|
|
|
def create_pipelimit(**kwargs): |
114
|
|
|
defaults = {} |
115
|
|
|
defaults["pipeid"] = "pipeid" |
116
|
|
|
defaults["algorithm"] = "algorithm" |
117
|
|
|
defaults["plimit"] = "plimit" |
118
|
|
|
defaults.update(**kwargs) |
119
|
|
|
return PipeLimit.objects.create(**defaults) |
120
|
|
|
|
121
|
|
|
|
122
|
|
|
def create_mtree(**kwargs): |
123
|
|
|
defaults = {} |
124
|
|
|
defaults["tprefix"] = "tprefix" |
125
|
|
|
defaults["tvalue"] = "tvalue" |
126
|
|
|
defaults.update(**kwargs) |
127
|
|
|
return Mtree.objects.create(**defaults) |
128
|
|
|
|
129
|
|
|
|
130
|
|
|
def create_mtrees(**kwargs): |
131
|
|
|
defaults = {} |
132
|
|
|
defaults["tname"] = "tname" |
133
|
|
|
defaults["tprefix"] = "tprefix" |
134
|
|
|
defaults["tvalue"] = "tvalue" |
135
|
|
|
defaults.update(**kwargs) |
136
|
|
|
return Mtrees.objects.create(**defaults) |
137
|
|
|
|
138
|
|
|
|
139
|
|
|
def create_htable(**kwargs): |
140
|
|
|
defaults = {} |
141
|
|
|
defaults["key_name"] = "key_name" |
142
|
|
|
defaults["key_type"] = "key_type" |
143
|
|
|
defaults["value_type"] = "value_type" |
144
|
|
|
defaults["key_value"] = "key_value" |
145
|
|
|
defaults["expires"] = "expires" |
146
|
|
|
defaults.update(**kwargs) |
147
|
|
|
return Htable.objects.create(**defaults) |
148
|
|
|
|
149
|
|
|
|
150
|
|
View Code Duplication |
class VersionViewTest(unittest.TestCase): |
|
|
|
|
151
|
|
|
''' |
152
|
|
|
Tests for Version |
153
|
|
|
''' |
154
|
|
|
def setUp(self): |
155
|
|
|
self.client = Client() |
156
|
|
|
|
157
|
|
|
def test_list_version(self): |
158
|
|
|
url = reverse('kamailio_version_list') |
159
|
|
|
response = self.client.get(url) |
160
|
|
|
self.assertEqual(response.status_code, 200) |
161
|
|
|
|
162
|
|
|
def test_create_version(self): |
163
|
|
|
url = reverse('kamailio_version_create') |
164
|
|
|
data = { |
165
|
|
|
"table_name": "table_name", |
166
|
|
|
"table_version": "table_version", |
167
|
|
|
} |
168
|
|
|
response = self.client.post(url, data=data) |
169
|
|
|
self.assertEqual(response.status_code, 302) |
170
|
|
|
|
171
|
|
|
def test_detail_version(self): |
172
|
|
|
version = create_version() |
173
|
|
|
url = reverse('kamailio_version_detail', args=[version.pk,]) |
174
|
|
|
response = self.client.get(url) |
175
|
|
|
self.assertEqual(response.status_code, 200) |
176
|
|
|
|
177
|
|
|
def test_update_version(self): |
178
|
|
|
version = create_version() |
179
|
|
|
data = { |
180
|
|
|
"table_name": "table_name", |
181
|
|
|
"table_version": "table_version", |
182
|
|
|
} |
183
|
|
|
url = reverse('kamailio_version_update', args=[version.pk,]) |
184
|
|
|
response = self.client.post(url, data) |
185
|
|
|
self.assertEqual(response.status_code, 302) |
186
|
|
|
|
187
|
|
|
|
188
|
|
View Code Duplication |
class LocationViewTest(unittest.TestCase): |
|
|
|
|
189
|
|
|
''' |
190
|
|
|
Tests for Location |
191
|
|
|
''' |
192
|
|
|
def setUp(self): |
193
|
|
|
self.client = Client() |
194
|
|
|
|
195
|
|
|
def test_list_location(self): |
196
|
|
|
url = reverse('kamailio_location_list') |
197
|
|
|
response = self.client.get(url) |
198
|
|
|
self.assertEqual(response.status_code, 200) |
199
|
|
|
|
200
|
|
|
def test_create_location(self): |
201
|
|
|
url = reverse('kamailio_location_create') |
202
|
|
|
data = { |
203
|
|
|
"ruid": "ruid", |
204
|
|
|
"username": "username", |
205
|
|
|
"domain": "domain", |
206
|
|
|
"contact": "contact", |
207
|
|
|
"received": "received", |
208
|
|
|
"path": "path", |
209
|
|
|
"expires": "expires", |
210
|
|
|
"q": "q", |
211
|
|
|
"callid": "callid", |
212
|
|
|
"cseq": "cseq", |
213
|
|
|
"last_modified": "last_modified", |
214
|
|
|
"flags": "flags", |
215
|
|
|
"cfags": "cfags", |
216
|
|
|
"user_agent": "user_agent", |
217
|
|
|
"socket": "socket", |
218
|
|
|
"methods": "methods", |
219
|
|
|
"instance": "instance", |
220
|
|
|
"reg_id": "reg_id", |
221
|
|
|
"server_id": "server_id", |
222
|
|
|
"connection_id": "connection_id", |
223
|
|
|
"keepalive": "keepalive", |
224
|
|
|
"partition": "partition", |
225
|
|
|
} |
226
|
|
|
response = self.client.post(url, data=data) |
227
|
|
|
self.assertEqual(response.status_code, 302) |
228
|
|
|
|
229
|
|
|
def test_detail_location(self): |
230
|
|
|
location = create_location() |
231
|
|
|
url = reverse('kamailio_location_detail', args=[location.pk,]) |
232
|
|
|
response = self.client.get(url) |
233
|
|
|
self.assertEqual(response.status_code, 200) |
234
|
|
|
|
235
|
|
|
def test_update_location(self): |
236
|
|
|
location = create_location() |
237
|
|
|
data = { |
238
|
|
|
"ruid": "ruid", |
239
|
|
|
"username": "username", |
240
|
|
|
"domain": "domain", |
241
|
|
|
"contact": "contact", |
242
|
|
|
"received": "received", |
243
|
|
|
"path": "path", |
244
|
|
|
"expires": "expires", |
245
|
|
|
"q": "q", |
246
|
|
|
"callid": "callid", |
247
|
|
|
"cseq": "cseq", |
248
|
|
|
"last_modified": "last_modified", |
249
|
|
|
"flags": "flags", |
250
|
|
|
"cfags": "cfags", |
251
|
|
|
"user_agent": "user_agent", |
252
|
|
|
"socket": "socket", |
253
|
|
|
"methods": "methods", |
254
|
|
|
"instance": "instance", |
255
|
|
|
"reg_id": "reg_id", |
256
|
|
|
"server_id": "server_id", |
257
|
|
|
"connection_id": "connection_id", |
258
|
|
|
"keepalive": "keepalive", |
259
|
|
|
"partition": "partition", |
260
|
|
|
} |
261
|
|
|
url = reverse('kamailio_location_update', args=[location.pk,]) |
262
|
|
|
response = self.client.post(url, data) |
263
|
|
|
self.assertEqual(response.status_code, 302) |
264
|
|
|
|
265
|
|
|
|
266
|
|
View Code Duplication |
class LocationAttrsViewTest(unittest.TestCase): |
|
|
|
|
267
|
|
|
''' |
268
|
|
|
Tests for LocationAttrs |
269
|
|
|
''' |
270
|
|
|
def setUp(self): |
271
|
|
|
self.client = Client() |
272
|
|
|
|
273
|
|
|
def test_list_locationattrs(self): |
274
|
|
|
url = reverse('kamailio_locationattrs_list') |
275
|
|
|
response = self.client.get(url) |
276
|
|
|
self.assertEqual(response.status_code, 200) |
277
|
|
|
|
278
|
|
|
def test_create_locationattrs(self): |
279
|
|
|
url = reverse('kamailio_locationattrs_create') |
280
|
|
|
data = { |
281
|
|
|
"ruid": "ruid", |
282
|
|
|
"username": "username", |
283
|
|
|
"domain": "domain", |
284
|
|
|
"aname": "aname", |
285
|
|
|
"atype": "atype", |
286
|
|
|
"avalue": "avalue", |
287
|
|
|
"last_modified": "last_modified", |
288
|
|
|
} |
289
|
|
|
response = self.client.post(url, data=data) |
290
|
|
|
self.assertEqual(response.status_code, 302) |
291
|
|
|
|
292
|
|
|
def test_detail_locationattrs(self): |
293
|
|
|
locationattrs = create_locationattrs() |
294
|
|
|
url = reverse('kamailio_locationattrs_detail', args=[locationattrs.pk,]) |
295
|
|
|
response = self.client.get(url) |
296
|
|
|
self.assertEqual(response.status_code, 200) |
297
|
|
|
|
298
|
|
|
def test_update_locationattrs(self): |
299
|
|
|
locationattrs = create_locationattrs() |
300
|
|
|
data = { |
301
|
|
|
"ruid": "ruid", |
302
|
|
|
"username": "username", |
303
|
|
|
"domain": "domain", |
304
|
|
|
"aname": "aname", |
305
|
|
|
"atype": "atype", |
306
|
|
|
"avalue": "avalue", |
307
|
|
|
"last_modified": "last_modified", |
308
|
|
|
} |
309
|
|
|
url = reverse('kamailio_locationattrs_update', args=[locationattrs.pk,]) |
310
|
|
|
response = self.client.post(url, data) |
311
|
|
|
self.assertEqual(response.status_code, 302) |
312
|
|
|
|
313
|
|
|
|
314
|
|
View Code Duplication |
class UserBlackListViewTest(unittest.TestCase): |
|
|
|
|
315
|
|
|
''' |
316
|
|
|
Tests for UserBlackList |
317
|
|
|
''' |
318
|
|
|
def setUp(self): |
319
|
|
|
self.client = Client() |
320
|
|
|
|
321
|
|
|
def test_list_userblacklist(self): |
322
|
|
|
url = reverse('kamailio_userblacklist_list') |
323
|
|
|
response = self.client.get(url) |
324
|
|
|
self.assertEqual(response.status_code, 200) |
325
|
|
|
|
326
|
|
|
def test_create_userblacklist(self): |
327
|
|
|
url = reverse('kamailio_userblacklist_create') |
328
|
|
|
data = { |
329
|
|
|
"username": "username", |
330
|
|
|
"domain": "domain", |
331
|
|
|
"prefix": "prefix", |
332
|
|
|
"whitelist": "whitelist", |
333
|
|
|
} |
334
|
|
|
response = self.client.post(url, data=data) |
335
|
|
|
self.assertEqual(response.status_code, 302) |
336
|
|
|
|
337
|
|
|
def test_detail_userblacklist(self): |
338
|
|
|
userblacklist = create_userblacklist() |
339
|
|
|
url = reverse('kamailio_userblacklist_detail', args=[userblacklist.pk,]) |
340
|
|
|
response = self.client.get(url) |
341
|
|
|
self.assertEqual(response.status_code, 200) |
342
|
|
|
|
343
|
|
|
def test_update_userblacklist(self): |
344
|
|
|
userblacklist = create_userblacklist() |
345
|
|
|
data = { |
346
|
|
|
"username": "username", |
347
|
|
|
"domain": "domain", |
348
|
|
|
"prefix": "prefix", |
349
|
|
|
"whitelist": "whitelist", |
350
|
|
|
} |
351
|
|
|
url = reverse('kamailio_userblacklist_update', args=[userblacklist.pk,]) |
352
|
|
|
response = self.client.post(url, data) |
353
|
|
|
self.assertEqual(response.status_code, 302) |
354
|
|
|
|
355
|
|
|
|
356
|
|
View Code Duplication |
class GlobalBlackListViewTest(unittest.TestCase): |
|
|
|
|
357
|
|
|
''' |
358
|
|
|
Tests for GlobalBlackList |
359
|
|
|
''' |
360
|
|
|
def setUp(self): |
361
|
|
|
self.client = Client() |
362
|
|
|
|
363
|
|
|
def test_list_globalblacklist(self): |
364
|
|
|
url = reverse('kamailio_globalblacklist_list') |
365
|
|
|
response = self.client.get(url) |
366
|
|
|
self.assertEqual(response.status_code, 200) |
367
|
|
|
|
368
|
|
|
def test_create_globalblacklist(self): |
369
|
|
|
url = reverse('kamailio_globalblacklist_create') |
370
|
|
|
data = { |
371
|
|
|
"prefix": "prefix", |
372
|
|
|
"whitelist": "whitelist", |
373
|
|
|
"description": "description", |
374
|
|
|
} |
375
|
|
|
response = self.client.post(url, data=data) |
376
|
|
|
self.assertEqual(response.status_code, 302) |
377
|
|
|
|
378
|
|
|
def test_detail_globalblacklist(self): |
379
|
|
|
globalblacklist = create_globalblacklist() |
380
|
|
|
url = reverse('kamailio_globalblacklist_detail', args=[globalblacklist.pk,]) |
381
|
|
|
response = self.client.get(url) |
382
|
|
|
self.assertEqual(response.status_code, 200) |
383
|
|
|
|
384
|
|
|
def test_update_globalblacklist(self): |
385
|
|
|
globalblacklist = create_globalblacklist() |
386
|
|
|
data = { |
387
|
|
|
"prefix": "prefix", |
388
|
|
|
"whitelist": "whitelist", |
389
|
|
|
"description": "description", |
390
|
|
|
} |
391
|
|
|
url = reverse('kamailio_globalblacklist_update', args=[globalblacklist.pk,]) |
392
|
|
|
response = self.client.post(url, data) |
393
|
|
|
self.assertEqual(response.status_code, 302) |
394
|
|
|
|
395
|
|
|
|
396
|
|
View Code Duplication |
class SpeedDialViewTest(unittest.TestCase): |
|
|
|
|
397
|
|
|
''' |
398
|
|
|
Tests for SpeedDial |
399
|
|
|
''' |
400
|
|
|
def setUp(self): |
401
|
|
|
self.client = Client() |
402
|
|
|
|
403
|
|
|
def test_list_speeddial(self): |
404
|
|
|
url = reverse('kamailio_speeddial_list') |
405
|
|
|
response = self.client.get(url) |
406
|
|
|
self.assertEqual(response.status_code, 200) |
407
|
|
|
|
408
|
|
|
def test_create_speeddial(self): |
409
|
|
|
url = reverse('kamailio_speeddial_create') |
410
|
|
|
data = { |
411
|
|
|
"username": "username", |
412
|
|
|
"domain": "domain", |
413
|
|
|
"sd_username": "sd_username", |
414
|
|
|
"sd_domain": "sd_domain", |
415
|
|
|
"new_uri": "new_uri", |
416
|
|
|
"fname": "fname", |
417
|
|
|
"lname": "lname", |
418
|
|
|
"description": "description", |
419
|
|
|
} |
420
|
|
|
response = self.client.post(url, data=data) |
421
|
|
|
self.assertEqual(response.status_code, 302) |
422
|
|
|
|
423
|
|
|
def test_detail_speeddial(self): |
424
|
|
|
speeddial = create_speeddial() |
425
|
|
|
url = reverse('kamailio_speeddial_detail', args=[speeddial.pk,]) |
426
|
|
|
response = self.client.get(url) |
427
|
|
|
self.assertEqual(response.status_code, 200) |
428
|
|
|
|
429
|
|
|
def test_update_speeddial(self): |
430
|
|
|
speeddial = create_speeddial() |
431
|
|
|
data = { |
432
|
|
|
"username": "username", |
433
|
|
|
"domain": "domain", |
434
|
|
|
"sd_username": "sd_username", |
435
|
|
|
"sd_domain": "sd_domain", |
436
|
|
|
"new_uri": "new_uri", |
437
|
|
|
"fname": "fname", |
438
|
|
|
"lname": "lname", |
439
|
|
|
"description": "description", |
440
|
|
|
} |
441
|
|
|
url = reverse('kamailio_speeddial_update', args=[speeddial.pk,]) |
442
|
|
|
response = self.client.post(url, data) |
443
|
|
|
self.assertEqual(response.status_code, 302) |
444
|
|
|
|
445
|
|
|
|
446
|
|
View Code Duplication |
class PipeLimitViewTest(unittest.TestCase): |
|
|
|
|
447
|
|
|
''' |
448
|
|
|
Tests for PipeLimit |
449
|
|
|
''' |
450
|
|
|
def setUp(self): |
451
|
|
|
self.client = Client() |
452
|
|
|
|
453
|
|
|
def test_list_pipelimit(self): |
454
|
|
|
url = reverse('kamailio_pipelimit_list') |
455
|
|
|
response = self.client.get(url) |
456
|
|
|
self.assertEqual(response.status_code, 200) |
457
|
|
|
|
458
|
|
|
def test_create_pipelimit(self): |
459
|
|
|
url = reverse('kamailio_pipelimit_create') |
460
|
|
|
data = { |
461
|
|
|
"pipeid": "pipeid", |
462
|
|
|
"algorithm": "algorithm", |
463
|
|
|
"plimit": "plimit", |
464
|
|
|
} |
465
|
|
|
response = self.client.post(url, data=data) |
466
|
|
|
self.assertEqual(response.status_code, 302) |
467
|
|
|
|
468
|
|
|
def test_detail_pipelimit(self): |
469
|
|
|
pipelimit = create_pipelimit() |
470
|
|
|
url = reverse('kamailio_pipelimit_detail', args=[pipelimit.pk,]) |
471
|
|
|
response = self.client.get(url) |
472
|
|
|
self.assertEqual(response.status_code, 200) |
473
|
|
|
|
474
|
|
|
def test_update_pipelimit(self): |
475
|
|
|
pipelimit = create_pipelimit() |
476
|
|
|
data = { |
477
|
|
|
"pipeid": "pipeid", |
478
|
|
|
"algorithm": "algorithm", |
479
|
|
|
"plimit": "plimit", |
480
|
|
|
} |
481
|
|
|
url = reverse('kamailio_pipelimit_update', args=[pipelimit.pk,]) |
482
|
|
|
response = self.client.post(url, data) |
483
|
|
|
self.assertEqual(response.status_code, 302) |
484
|
|
|
|
485
|
|
|
|
486
|
|
View Code Duplication |
class MtreeViewTest(unittest.TestCase): |
|
|
|
|
487
|
|
|
''' |
488
|
|
|
Tests for Mtree |
489
|
|
|
''' |
490
|
|
|
def setUp(self): |
491
|
|
|
self.client = Client() |
492
|
|
|
|
493
|
|
|
def test_list_mtree(self): |
494
|
|
|
url = reverse('kamailio_mtree_list') |
495
|
|
|
response = self.client.get(url) |
496
|
|
|
self.assertEqual(response.status_code, 200) |
497
|
|
|
|
498
|
|
|
def test_create_mtree(self): |
499
|
|
|
url = reverse('kamailio_mtree_create') |
500
|
|
|
data = { |
501
|
|
|
"tprefix": "tprefix", |
502
|
|
|
"tvalue": "tvalue", |
503
|
|
|
} |
504
|
|
|
response = self.client.post(url, data=data) |
505
|
|
|
self.assertEqual(response.status_code, 302) |
506
|
|
|
|
507
|
|
|
def test_detail_mtree(self): |
508
|
|
|
mtree = create_mtree() |
509
|
|
|
url = reverse('kamailio_mtree_detail', args=[mtree.pk,]) |
510
|
|
|
response = self.client.get(url) |
511
|
|
|
self.assertEqual(response.status_code, 200) |
512
|
|
|
|
513
|
|
|
def test_update_mtree(self): |
514
|
|
|
mtree = create_mtree() |
515
|
|
|
data = { |
516
|
|
|
"tprefix": "tprefix", |
517
|
|
|
"tvalue": "tvalue", |
518
|
|
|
} |
519
|
|
|
url = reverse('kamailio_mtree_update', args=[mtree.pk,]) |
520
|
|
|
response = self.client.post(url, data) |
521
|
|
|
self.assertEqual(response.status_code, 302) |
522
|
|
|
|
523
|
|
|
|
524
|
|
View Code Duplication |
class MtreesViewTest(unittest.TestCase): |
|
|
|
|
525
|
|
|
''' |
526
|
|
|
Tests for Mtrees |
527
|
|
|
''' |
528
|
|
|
def setUp(self): |
529
|
|
|
self.client = Client() |
530
|
|
|
|
531
|
|
|
def test_list_mtrees(self): |
532
|
|
|
url = reverse('kamailio_mtrees_list') |
533
|
|
|
response = self.client.get(url) |
534
|
|
|
self.assertEqual(response.status_code, 200) |
535
|
|
|
|
536
|
|
|
def test_create_mtrees(self): |
537
|
|
|
url = reverse('kamailio_mtrees_create') |
538
|
|
|
data = { |
539
|
|
|
"tname": "tname", |
540
|
|
|
"tprefix": "tprefix", |
541
|
|
|
"tvalue": "tvalue", |
542
|
|
|
} |
543
|
|
|
response = self.client.post(url, data=data) |
544
|
|
|
self.assertEqual(response.status_code, 302) |
545
|
|
|
|
546
|
|
|
def test_detail_mtrees(self): |
547
|
|
|
mtrees = create_mtrees() |
548
|
|
|
url = reverse('kamailio_mtrees_detail', args=[mtrees.pk,]) |
549
|
|
|
response = self.client.get(url) |
550
|
|
|
self.assertEqual(response.status_code, 200) |
551
|
|
|
|
552
|
|
|
def test_update_mtrees(self): |
553
|
|
|
mtrees = create_mtrees() |
554
|
|
|
data = { |
555
|
|
|
"tname": "tname", |
556
|
|
|
"tprefix": "tprefix", |
557
|
|
|
"tvalue": "tvalue", |
558
|
|
|
} |
559
|
|
|
url = reverse('kamailio_mtrees_update', args=[mtrees.pk,]) |
560
|
|
|
response = self.client.post(url, data) |
561
|
|
|
self.assertEqual(response.status_code, 302) |
562
|
|
|
|
563
|
|
|
|
564
|
|
View Code Duplication |
class HtableViewTest(unittest.TestCase): |
|
|
|
|
565
|
|
|
''' |
566
|
|
|
Tests for Htable |
567
|
|
|
''' |
568
|
|
|
def setUp(self): |
569
|
|
|
self.client = Client() |
570
|
|
|
|
571
|
|
|
def test_list_htable(self): |
572
|
|
|
url = reverse('kamailio_htable_list') |
573
|
|
|
response = self.client.get(url) |
574
|
|
|
self.assertEqual(response.status_code, 200) |
575
|
|
|
|
576
|
|
|
def test_create_htable(self): |
577
|
|
|
url = reverse('kamailio_htable_create') |
578
|
|
|
data = { |
579
|
|
|
"key_name": "key_name", |
580
|
|
|
"key_type": "key_type", |
581
|
|
|
"value_type": "value_type", |
582
|
|
|
"key_value": "key_value", |
583
|
|
|
"expires": "expires", |
584
|
|
|
} |
585
|
|
|
response = self.client.post(url, data=data) |
586
|
|
|
self.assertEqual(response.status_code, 302) |
587
|
|
|
|
588
|
|
|
def test_detail_htable(self): |
589
|
|
|
htable = create_htable() |
590
|
|
|
url = reverse('kamailio_htable_detail', args=[htable.pk,]) |
591
|
|
|
response = self.client.get(url) |
592
|
|
|
self.assertEqual(response.status_code, 200) |
593
|
|
|
|
594
|
|
|
def test_update_htable(self): |
595
|
|
|
htable = create_htable() |
596
|
|
|
data = { |
597
|
|
|
"key_name": "key_name", |
598
|
|
|
"key_type": "key_type", |
599
|
|
|
"value_type": "value_type", |
600
|
|
|
"key_value": "key_value", |
601
|
|
|
"expires": "expires", |
602
|
|
|
} |
603
|
|
|
url = reverse('kamailio_htable_update', args=[htable.pk,]) |
604
|
|
|
response = self.client.post(url, data) |
605
|
|
|
self.assertEqual(response.status_code, 302) |
606
|
|
|
|
607
|
|
|
|
608
|
|
|
|