Mercurial > hg > orthanc-tests
annotate Plugins/DicomWeb/Run.py @ 39:7412a437ab47
test
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 21 Aug 2015 15:01:05 +0200 |
parents | eb6d219af210 |
children | 97acfdf0dbce |
rev | line source |
---|---|
32
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/python |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 # Orthanc - A Lightweight, RESTful DICOM Store |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 # Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 # Department, University Hospital of Liege, Belgium |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 # |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 # modify it under the terms of the GNU General Public License as |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 # published by the Free Software Foundation, either version 3 of the |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 # License, or (at your option) any later version. |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 # |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, but |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 # WITHOUT ANY WARRANTY; without even the implied warranty of |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 # General Public License for more details. |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 # |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU General Public License |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 import os |
33 | 22 import pprint |
32
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 import sys |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 import argparse |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 import unittest |
33 | 26 from DicomWeb import * |
32
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'Tests')) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 from Toolbox import * |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 ## |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 ## Parse the command-line arguments |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 ## |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 parser = argparse.ArgumentParser(description = 'Run the integration tests for the DICOMweb plugin.') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 parser.add_argument('--server', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 default = 'localhost', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 help = 'Address of the Orthanc server to test') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 parser.add_argument('--rest', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 type = int, |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 default = 8042, |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 help = 'Port to the REST API') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 parser.add_argument('--username', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 default = 'alice', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 help = 'Username to the REST API') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 parser.add_argument('--password', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 default = 'orthanctest', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 help = 'Password to the REST API') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 parser.add_argument('--wado', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 default = '/wado', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 help = 'Path to the WADO API') |
33 | 54 parser.add_argument('--dicomweb', |
32
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 default = '/dicom-web/', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 help = 'Path to the DICOMweb API') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 parser.add_argument('--force', help = 'Do not warn the user', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 action = 'store_true') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 parser.add_argument('options', metavar = 'N', nargs = '*', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 help='Arguments to Python unittest') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 args = parser.parse_args() |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 ## |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 ## Configure the testing context |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 ## |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 if not args.force: |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 print(""" |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 WARNING: This test will remove all the content of your |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 Orthanc instance running on %s! |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 Are you sure ["yes" to go on]?""" % args.server) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 if sys.stdin.readline().strip() != 'yes': |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 print('Aborting...') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 exit(0) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 ORTHANC = DefineOrthanc(server = args.server, |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 username = args.username, |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 password = args.password, |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 restPort = args.rest) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 ## |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 ## The tests |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 ## |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 class Orthanc(unittest.TestCase): |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 def setUp(self): |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 DropOrthanc(ORTHANC) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 def test_wado_dicom(self): |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 UploadInstance(ORTHANC, 'Brainix/Flair/IM-0001-0001.dcm') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 SIZE = 169478 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 INSTANCE = '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549' |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 SERIES = '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497' |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 STUDY = '2.16.840.1.113669.632.20.1211.10000357775' |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado + '?requestType=WADO')) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado + '?objectUID=%s' % INSTANCE)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 dicom = DoGet(ORTHANC, args.wado + '?contentType=application/dicom&requestType=WADO&objectUID=%s' % INSTANCE) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 self.assertEqual(SIZE, len(dicom)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 dicom = DoGet(ORTHANC, args.wado + '?contentType=application/dicom&requestType=WADO&objectUID=%s&seriesUID=%s' % (INSTANCE, SERIES)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 self.assertEqual(SIZE, len(dicom)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 dicom = DoGet(ORTHANC, args.wado + '?contentType=application/dicom&requestType=WADO&objectUID=%s&seriesUID=%s&studyUID=%s' % (INSTANCE, SERIES, STUDY)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 self.assertEqual(SIZE, len(dicom)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 dicom = DoGet(ORTHANC, args.wado + '?contentType=application/dicom&requestType=WADO&objectUID=%s&seriesUID=%s' % (INSTANCE, SERIES)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 self.assertEqual(SIZE, len(dicom)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 dicom = DoGet(ORTHANC, args.wado + '?contentType=application/dicom&requestType=WADO&objectUID=%s&studyUID=%s' % (INSTANCE, STUDY)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 self.assertEqual(SIZE, len(dicom)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado + '?requestType=WADO&objectUID=%s&seriesUID=nope' % INSTANCE)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado + '?requestType=WADO&objectUID=%s&studyUID=nope' % INSTANCE)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado + '?requestType=WADO&objectUID=%s&seriesUID=nope&studyUID=nope' % INSTANCE)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 def test_wado_image(self): |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 UploadInstance(ORTHANC, 'Phenix/IM-0001-0001.dcm') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 INSTANCE = '1.2.840.113704.7.1.1.6632.1127829031.2' |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 im = GetImage(ORTHANC, args.wado + '?requestType=WADO&objectUID=%s' % INSTANCE) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 self.assertEqual('JPEG', im.format) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 self.assertEqual('L', im.mode) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 self.assertEqual(512, im.size[0]) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 self.assertEqual(358, im.size[1]) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 im = GetImage(ORTHANC, args.wado + '?contentType=image/jpg&requestType=WADO&objectUID=%s' % INSTANCE) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 self.assertEqual('JPEG', im.format) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 im = GetImage(ORTHANC, args.wado + '?contentType=image/png&requestType=WADO&objectUID=%s' % INSTANCE) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 self.assertEqual('PNG', im.format) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 self.assertEqual('L', im.mode) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 self.assertEqual(512, im.size[0]) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 self.assertEqual(358, im.size[1]) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 |
33 | 145 def test_stow(self): |
146 self.assertEqual(0, len(DoGet(ORTHANC, '/instances'))) | |
147 SendStow(ORTHANC, args.dicomweb + '/studies', GetDatabasePath('Phenix/IM-0001-0001.dcm')) | |
148 self.assertEqual(1, len(DoGet(ORTHANC, '/instances'))) | |
149 a = SendStow(ORTHANC, args.dicomweb + '/studies', GetDatabasePath('Phenix/IM-0001-0001.dcm')) | |
150 self.assertEqual(1, len(DoGet(ORTHANC, '/instances'))) | |
151 | |
152 self.assertEqual(0, len(a['00081198']['Value'])) # No error | |
153 self.assertEqual(1, len(a['00081199']['Value'])) # 1 success | |
154 | |
155 self.assertTrue(a['00081190']['Value'][0].endswith('studies/2.16.840.1.113669.632.20.1211.10000098591')) | |
156 self.assertTrue(a['00081199']['Value'][0]['00081190']['Value'][0]. | |
157 endswith('series/1.2.840.113704.1.111.5692.1127828999.2/instances/1.2.840.113704.7.1.1.6632.1127829031.2')) | |
158 | |
159 b = GetMultipart(a['00081190']['Value'][0]) | |
160 self.assertEqual(1, len(b)) | |
161 self.assertEqual(368852, len(b[0])) | |
162 | |
32
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 try: |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 print('\nStarting the tests...') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 unittest.main(argv = [ sys.argv[0] ] + args.options) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 finally: |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 print('\nDone') |