-
Notifications
You must be signed in to change notification settings - Fork 9
/
image.py
777 lines (675 loc) · 25.3 KB
/
image.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
#(C) Copyright Syd Logan 2017-2020
#(C) Copyright Thousand Smiles Foundation 2017-2020
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#
#You may obtain a copy of the License at
#http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
'''
unit tests for image application. Assumes django server is up
and running on the specified host and port
'''
import unittest
import getopt, sys
import json
from random import randint
from tschartslib.service.serviceapi import ServiceAPI
from tschartslib.tscharts.tscharts import Login, Logout
from tschartslib.clinic.clinic import CreateClinic, DeleteClinic
from tschartslib.station.station import CreateStation, DeleteStation
from tschartslib.patient.patient import CreatePatient, DeletePatient
class CreateImage(ServiceAPI):
def __init__(self, host, port, token):
super(CreateImage, self).__init__()
self.setHttpMethod("POST")
self.setHost(host)
self.setPort(port)
self.setToken(token)
self._payload = {}
self.setPayload(self._payload)
self.setURL("tscharts/v1/image/")
def setClinic(self, clinic):
self._payload["clinic"] = clinic
self.setPayload(self._payload)
def setStation(self, station):
self._payload["station"] = station
self.setPayload(self._payload)
def setPatient(self, patient):
self._payload["patient"] = patient
self.setPayload(self._payload)
def setData(self, data):
self._payload["data"] = data
self.setPayload(self._payload)
def setType(self, imagetype):
self._payload["type"] = imagetype
self.setPayload(self._payload)
class GetImage(ServiceAPI):
def __init__(self, host, port, token):
super(GetImage, self).__init__()
self.setHttpMethod("GET")
self.setHost(host)
self.setPort(port)
self.setToken(token)
self._clinic = None
self._station = None
self._patient = None
self._type = None
self._id = None
self._sort = None
self._newest = None
self.makeURL();
def makeURL(self):
hasQArgs = False
if not self._id == None:
base = "tscharts/v1/image/{}/".format(self._id)
else:
base = "tscharts/v1/image/"
if not self._clinic == None:
if not hasQArgs:
base += "?"
else:
base += "&"
base += "clinic={}".format(self._clinic)
hasQArgs = True
if not self._station == None:
if not hasQArgs:
base += "?"
else:
base += "&"
base += "station={}".format(self._station)
hasQArgs = True
if not self._patient == None:
if not hasQArgs:
base += "?"
else:
base += "&"
base += "patient={}".format(self._patient)
hasQArgs = True
if not self._type == None:
if not hasQArgs:
base += "?"
else:
base += "&"
base += "type={}".format(self._type)
hasQArgs = True
if not self._newest == None:
if not hasQArgs:
base += "?"
else:
base += "&"
base += "newest={}".format(self._newest)
hasQArgs = True
if not self._sort == None:
if not hasQArgs:
base += "?"
else:
base += "&"
base += "sort={}".format(self._sort)
hasQArgs = True
self.setURL(base)
def setId(self, id):
self._id = id;
self.makeURL()
def setClinic(self, clinic):
self._clinic = clinic
self.makeURL()
def setNewest(self, val):
self._newest = val
self.makeURL()
def setStation(self, station):
self._station = station
self.makeURL()
def setPatient(self, patient):
self._patient = patient
self.makeURL()
def setType(self, imagetype):
self._type = imagetype
self.makeURL()
def setSort(self, sort):
self._sort = sort
self.makeURL()
class DeleteImage(ServiceAPI):
def __init__(self, host, port, token, id):
super(DeleteImage, self).__init__()
self.setHttpMethod("DELETE")
self.setHost(host)
self.setPort(port)
self.setToken(token)
self.setURL("tscharts/v1/image/{}/".format(id))
class TestTSImage(unittest.TestCase):
def setUp(self):
login = Login(host, port, username, password)
ret = login.send(timeout=30)
self.assertEqual(ret[0], 200)
self.assertTrue("token" in ret[1])
global token
token = ret[1]["token"]
def testCreateImage(self):
x = CreateClinic(host, port, token, "Ensenada", "02/05/2016", "02/06/2016")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
self.assertTrue("id" in ret[1])
clinicid = int(ret[1]["id"])
x = CreateStation(host, port, token, "ENT")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
stationid = int(ret[1]["id"])
data = {}
data["paternal_last"] = "abcd1234"
data["maternal_last"] = "yyyyyy"
data["first"] = "zzzzzzz"
data["middle"] = ""
data["suffix"] = "Jr."
data["prefix"] = ""
data["dob"] = "04/01/1962"
data["gender"] = "Female"
data["street1"] = "1234 First Ave"
data["street2"] = ""
data["city"] = "Ensenada"
data["colonia"] = ""
data["state"] = u"Baja California"
data["phone1"] = "1-111-111-1111"
data["phone2"] = ""
data["email"] = "[email protected]"
data["emergencyfullname"] = "Maria Sanchez"
data["emergencyphone"] = "1-222-222-2222"
data["emergencyemail"] = "[email protected]"
x = CreatePatient(host, port, token, data)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
patientid = int(ret[1]["id"])
for imageType in ["Xray", "Headshot", "Audiogram", "Surgery"]:
x = CreateImage(host, port, token)
x.setPatient(patientid)
x.setClinic(clinicid)
x.setStation(stationid)
x.setType(imageType)
x.setData("ABCDEFG") # doesn't matter if it is actual image data
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
id = int(ret[1]["id"])
x = GetImage(host, port, token)
x.setId(id)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
self.assertTrue("clinic" in ret[1])
clinicId = int(ret[1]["clinic"])
self.assertTrue(clinicId == clinicid)
self.assertTrue("station" in ret[1])
stationId = int(ret[1]["station"])
self.assertTrue(stationId == stationid)
self.assertTrue("patient" in ret[1])
patientId = int(ret[1]["patient"])
self.assertTrue(patientId == patientid)
self.assertTrue("type" in ret[1])
self.assertTrue(ret[1]["type"] == imageType)
self.assertTrue("data" in ret[1])
self.assertTrue(ret[1]["data"] == "ABCDEFG")
x = DeleteImage(host, port, token, id)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
x = GetImage(host, port, token)
x.setId(id)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 404) # not found
# non-existent clinic param
x = CreateImage(host, port, token)
x.setPatient(patientid)
x.setClinic(99999)
x.setType("Headshot")
x.setData("ABCDEFG") # doesn't matter if it is actual image data
x.setStation(stationid)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 404)
# non-existent station param
x = CreateImage(host, port, token)
x.setPatient(patientid)
x.setClinic(clinicid)
x.setStation(9999)
x.setType("Headshot")
x.setData("ABCDEFG") # doesn't matter if it is actual image data
ret = x.send(timeout=30)
self.assertEqual(ret[0], 404)
# non-existent patient param
x = CreateImage(host, port, token)
x.setPatient(9999)
x.setClinic(clinicid)
x.setStation(stationid)
x.setType("Headshot")
x.setData("ABCDEFG") # doesn't matter if it is actual image data
ret = x.send(timeout=30)
self.assertEqual(ret[0], 404)
# bogus clinic param
x = CreateImage(host, port, token)
x.setPatient(patientid)
x.setClinic("fffff")
x.setStation(stationid)
x.setType("Headshot")
x.setData("ABCDEFG") # doesn't matter if it is actual image data
ret = x.send(timeout=30)
self.assertEqual(ret[0], 400)
# bogus station param
x = CreateImage(host, port, token)
x.setPatient(patientid)
x.setClinic(clinicid)
x.setStation(None)
x.setType("Headshot")
x.setData("ABCDEFG") # doesn't matter if it is actual image data
ret = x.send(timeout=30)
self.assertEqual(ret[0], 400)
# bogus patient param
x = CreateImage(host, port, token)
x.setPatient("")
x.setClinic(clinicid)
x.setStation(stationid)
x.setType("Headshot")
x.setData("ABCDEFG") # doesn't matter if it is actual image data
ret = x.send(timeout=30)
self.assertEqual(ret[0], 400)
# missing patient
x = CreateImage(host, port, token)
x.setClinic(clinicid)
x.setStation(stationid)
x.setType("Headshot")
x.setData("ABCDEFG") # doesn't matter if it is actual image data
ret = x.send(timeout=30)
self.assertEqual(ret[0], 400)
# missing clinic
x = CreateImage(host, port, token)
x.setPatient(patientid)
x.setStation(stationid)
x.setType("Headshot")
x.setData("ABCDEFG") # doesn't matter if it is actual image data
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
# missing station
x = CreateImage(host, port, token)
x.setPatient(patientid)
x.setClinic(clinicid)
x.setType("Headshot")
x.setData("ABCDEFG") # doesn't matter if it is actual image data
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
# Wrong type
x = CreateImage(host, port, token)
x.setPatient(patientid)
x.setClinic(clinicid)
x.setStation(stationid)
x.setType("Bad Type")
x.setData("ABCDEFG") # doesn't matter if it is actual image data
ret = x.send(timeout=30)
self.assertEqual(ret[0], 400)
# Missing Data
x = CreateImage(host, port, token)
x.setPatient(patientid)
x.setClinic(clinicid)
x.setStation(stationid)
x.setType("Headshot")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 400)
x = DeletePatient(host, port, token, patientid)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
x = DeleteStation(host, port, token, stationid)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
x = DeleteClinic(host, port, token, clinicid)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
def testDeleteImage(self):
x = CreateClinic(host, port, token, "Ensenada", "02/05/2016", "02/06/2016")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
self.assertTrue("id" in ret[1])
clinicid = int(ret[1]["id"])
x = CreateStation(host, port, token, "ENT")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
stationid = int(ret[1]["id"])
data = {}
data["paternal_last"] = "abcd1234"
data["maternal_last"] = "yyyyyy"
data["first"] = "zzzzzzz"
data["middle"] = ""
data["suffix"] = "Jr."
data["prefix"] = ""
data["dob"] = "04/01/1962"
data["gender"] = "Female"
data["street1"] = "1234 First Ave"
data["street2"] = ""
data["city"] = "Ensenada"
data["colonia"] = ""
data["state"] = u"Baja California"
data["phone1"] = "1-111-111-1111"
data["phone2"] = ""
data["email"] = "[email protected]"
data["emergencyfullname"] = "Maria Sanchez"
data["emergencyphone"] = "1-222-222-2222"
data["emergencyemail"] = "[email protected]"
x = CreatePatient(host, port, token, data)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
patientid = int(ret[1]["id"])
x = CreateImage(host, port, token)
x.setPatient(patientid)
x.setClinic(clinicid)
x.setStation(stationid)
x.setType("Headshot")
x.setData("ABCDEFG") # doesn't matter if it is actual image data
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
id = int(ret[1]["id"])
x = GetImage(host, port, token)
x.setId(id)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
self.assertTrue("clinic" in ret[1])
clinicId = int(ret[1]["clinic"])
self.assertTrue(clinicId == clinicid)
self.assertTrue("station" in ret[1])
stationId = int(ret[1]["station"])
self.assertTrue(stationId == stationid)
self.assertTrue("patient" in ret[1])
patientId = int(ret[1]["patient"])
self.assertTrue(patientId == patientid)
self.assertTrue("type" in ret[1])
self.assertTrue(ret[1]["type"] == "Headshot")
self.assertTrue("data" in ret[1])
self.assertTrue(ret[1]["data"] == "ABCDEFG")
x = DeleteImage(host, port, token, id)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
x = GetImage(host, port, token)
x.setId(id)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 404) # not found
x = DeleteImage(host, port, token, id)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 404)
x = DeleteImage(host, port, token, "")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 400)
x = DeleteImage(host, port, token, 9999)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 404)
x = DeleteImage(host, port, token, None)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 404)
x = DeletePatient(host, port, token, patientid)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
x = DeleteStation(host, port, token, stationid)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
x = DeleteClinic(host, port, token, clinicid)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
def testGetAllImages(self):
clinics = []
stations = []
patients = []
images = []
nclinics = 3
nstations = 4
npatients = 5
nimages = 1
for i in xrange(1, nclinics + 1):
x = CreateClinic(host, port, token, "Ensenada", "{}/05/2016".format(i), "{}/06/2016".format(i))
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
self.assertTrue("id" in ret[1])
clinics.append(int(ret[1]["id"]))
for j in xrange(1, nstations + 1):
x = CreateStation(host, port, token, "Dental{}".format(j))
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
stations.append(int(ret[1]["id"]))
for k in range(1, npatients + 1):
data = {}
data["paternal_last"] = "abcd1234{}".format(k)
data["maternal_last"] = "yyyyyy"
data["first"] = "zzzzzzz"
data["middle"] = ""
data["suffix"] = "Jr."
data["prefix"] = ""
data["dob"] = "04/01/1962"
data["gender"] = "Female"
data["street1"] = "1234 First Ave"
data["street2"] = ""
data["city"] = "Ensenada"
data["colonia"] = ""
data["state"] = u"Baja California"
data["phone1"] = "1-111-111-1111"
data["phone2"] = ""
data["email"] = "[email protected]"
data["emergencyfullname"] = "Maria Sanchez"
data["emergencyphone"] = "1-222-222-2222"
data["emergencyemail"] = "[email protected]"
x = CreatePatient(host, port, token, data)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
patients.append(int(ret[1]["id"]))
for i in clinics:
for j in stations:
for k in patients:
for l in xrange(0, nimages):
x = CreateImage(host, port, token)
x.setPatient(k)
x.setClinic(i)
x.setStation(j)
x.setType("Headshot")
x.setData("ABCDEFG{}".format(l))
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
images.append(int(ret[1]["id"]))
# query by invalid search terms
x = GetImage(host, port, token)
x.setClinic(9999)
x.setStation(stations[0])
x.setPatient(patients[0])
x.setType("Headshot")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 404)
x = GetImage(host, port, token)
x.setClinic(clinics[0])
x.setStation(9999)
x.setPatient(patients[0])
x.setType("Headshot")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 404)
x = GetImage(host, port, token)
x.setClinic(clinics[0])
x.setStation(stations[0])
x.setPatient(9999)
x.setType("Headshot")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 404)
x = GetImage(host, port, token)
x.setClinic(clinics[0])
x.setStation(stations[0])
x.setPatient(patients[0])
x.setType("yadda")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 400)
x = GetImage(host, port, token)
x.setClinic(clinics[0])
x.setStation(stations[0])
x.setPatient(patients[0])
x.setSort("yadda")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 400)
x = GetImage(host, port, token)
x.setClinic(clinics[0])
x.setStation(stations[0])
x.setPatient(patients[0])
x.setSort("False")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 400)
x = GetImage(host, port, token)
x.setClinic(clinics[0])
x.setStation(stations[0])
x.setPatient(patients[0])
x.setSort("True")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 400)
x = GetImage(host, port, token)
x.setClinic(clinics[0])
x.setStation(stations[0])
x.setPatient(patients[0])
x.setSort("false")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
x = GetImage(host, port, token)
x.setClinic(clinics[0])
x.setStation(stations[0])
x.setPatient(patients[0])
x.setSort("true")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
sort = "true"
for c in clinics:
for s in stations:
for p in patients:
if sort =="true":
sort = "false"
else:
sort = "true"
# query by type
x = GetImage(host, port, token)
x.setPatient(p)
x.setSort(sort)
x.setType("Headshot")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
# query by clinic
x = GetImage(host, port, token)
x.setClinic(c)
x.setSort(sort)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
self.assertTrue(len(ret[1]) == len(images) / nclinics)
# query by clinic and type
x = GetImage(host, port, token)
x.setSort(sort)
x.setClinic(c)
x.setType("Headshot")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
self.assertTrue(len(ret[1]) == len(images) / nclinics)
# query by station
x = GetImage(host, port, token)
x.setSort(sort)
x.setStation(s)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
self.assertTrue(len(ret[1]) == (len(images) / nstations))
# query by station and type
x = GetImage(host, port, token)
x.setStation(s)
x.setType("Headshot")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
# query by clinic and station
x = GetImage(host, port, token)
x.setSort(sort)
x.setClinic(c)
x.setStation(s)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
self.assertTrue(len(ret[1]) == len(images) / (nclinics * nstations))
# query by clinic, station and type
x = GetImage(host, port, token)
x.setSort(sort)
x.setClinic(c)
x.setStation(s)
x.setType("Headshot")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
# query by clinic and patient
x = GetImage(host, port, token)
x.setSort(sort)
x.setClinic(c)
x.setPatient(p)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
self.assertTrue(len(ret[1]) == len(images) / (nclinics * npatients))
# query by clinic, patient and type
x = GetImage(host, port, token)
x.setSort(sort)
x.setClinic(c)
x.setPatient(p)
x.setType("Headshot")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
# query by clinic, station, and patient
x = GetImage(host, port, token)
x.setSort(sort)
x.setClinic(c)
x.setStation(s)
x.setPatient(p)
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
self.assertTrue(len(ret[1]) == len(images) / (nclinics * nstations * npatients))
# query by clinic, station, patient and type
x = GetImage(host, port, token)
x.setSort(sort)
x.setClinic(c)
x.setStation(s)
x.setPatient(p)
x.setType("Headshot")
ret = x.send(timeout=30)
self.assertEqual(ret[0], 200)
for x in images:
y = DeleteImage(host, port, token, x)
ret = y.send(timeout=30)
self.assertEqual(ret[0], 200)
for x in patients:
y = DeletePatient(host, port, token, x)
ret = y.send(timeout=30)
self.assertEqual(ret[0], 200)
for x in stations:
y = DeleteStation(host, port, token, x)
ret = y.send(timeout=30)
self.assertEqual(ret[0], 200)
for x in clinics:
y = DeleteClinic(host, port, token, x)
ret = y.send(timeout=30)
self.assertEqual(ret[0], 200)
def usage():
print("image [-h host] [-p port] [-u username] [-w password]")
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "h:p:u:w:")
except getopt.GetoptError as err:
print(str(err))
usage()
sys.exit(2)
global host
host = "127.0.0.1"
global port
port = 8000
global username
username = None
global password
password = None
for o, a in opts:
if o == "-h":
host = a
elif o == "-p":
port = int(a)
elif o == "-u":
username = a
elif o == "-w":
password = a
else:
assert False, "unhandled option"
unittest.main(argv=[sys.argv[0]])
if __name__ == "__main__":
main()