Mercurial > hg > orthanc-tests
annotate Tests/Tests.py @ 211:a05cc24f84e5
test_series_status
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 04 Feb 2019 11:36:30 +0100 |
parents | 2c50c8f340c2 |
children | eba6b8c38eee |
rev | line source |
---|---|
22 | 1 #!/usr/bin/env python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 | |
3 | 5 # Orthanc - A Lightweight, RESTful DICOM Store |
73 | 6 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
3 | 7 # Department, University Hospital of Liege, Belgium |
195 | 8 # Copyright (C) 2017-2019 Osimis S.A., Belgium |
3 | 9 # |
10 # This program is free software: you can redistribute it and/or | |
11 # modify it under the terms of the GNU General Public License as | |
12 # published by the Free Software Foundation, either version 3 of the | |
13 # License, or (at your option) any later version. | |
14 # | |
15 # This program is distributed in the hope that it will be useful, but | |
16 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 # General Public License for more details. | |
19 # | |
20 # You should have received a copy of the GNU General Public License | |
21 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
22 | |
23 | |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
24 import base64 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
25 import copy |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
26 import pprint |
14 | 27 import tempfile |
3 | 28 import unittest |
29 | |
11 | 30 from PIL import ImageChops |
3 | 31 from Toolbox import * |
13 | 32 from xml.dom import minidom |
3 | 33 |
34 _LOCAL = None | |
35 _REMOTE = None | |
36 | |
37 | |
38 def SetOrthancParameters(local, remote): | |
39 global _LOCAL, _REMOTE | |
40 _LOCAL = local | |
41 _REMOTE = remote | |
42 | |
43 | |
14 | 44 def ExtractDicomTags(rawDicom, tags): |
45 with tempfile.NamedTemporaryFile(delete = True) as f: | |
46 f.write(rawDicom) | |
47 f.flush() | |
45 | 48 data = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) |
14 | 49 |
50 result = [] | |
51 for tag in tags: | |
52 match = re.search('<element[^>]+name="%s">([^>]*)</element>' % tag, data) | |
53 if match == None: | |
54 result.append('') | |
55 else: | |
56 result.append(match.group(1)) | |
57 | |
58 return result | |
59 | |
60 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
61 def CompareLists(a, b): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
62 if len(a) != len(b): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
63 return False |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
64 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
65 for i in range(len(a)): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
66 d = a[i] - b[i] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
67 if abs(d) >= 0.51: # Add some tolerance for rounding errors |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
68 return False |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
69 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
70 return True |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
71 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
72 |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
73 def CompareTags(a, b, tagsToIgnore): |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
74 for i in tagsToIgnore: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
75 if i in a: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
76 del a[i] |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
77 if i in b: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
78 del b[i] |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
79 |
123 | 80 if a.keys() == b.keys(): |
81 return True | |
82 else: | |
83 print('Mismatch in tags: %s' % str(set(a.keys()) ^ set(b.keys()))) | |
84 return False | |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
85 |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
86 |
71
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
87 def CallFindScu(args): |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
88 p = subprocess.Popen([ FindExecutable('findscu'), |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
89 '-P', '-aec', _REMOTE['DicomAet'], '-aet', _LOCAL['DicomAet'], |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
90 _REMOTE['Server'], str(_REMOTE['DicomPort']) ] + args, |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
91 stderr=subprocess.PIPE) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
92 return p.communicate()[1] |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
93 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
94 |
142 | 95 def GetMoveScuCommand(): |
96 return [ | |
97 FindExecutable('movescu'), | |
98 '--move', _LOCAL['DicomAet'], # Target AET (i.e. storescp) | |
99 '--call', _REMOTE['DicomAet'], # Called AET (i.e. Orthanc) | |
100 '--aetitle', _LOCAL['DicomAet'], # Calling AET (i.e. storescp) | |
101 _REMOTE['Server'], | |
102 str(_REMOTE['DicomPort']) | |
103 ] | |
104 | |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
105 def CallMoveScu(args): |
142 | 106 subprocess.check_call(GetMoveScuCommand() + args, |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
107 stderr=subprocess.PIPE) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
108 |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
109 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
110 |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
111 def GenerateTestSequence(): |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
112 return [ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
113 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
114 'StudyDescription': 'Hello^', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
115 'ReferencedStudySequence' : [ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
116 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
117 'StudyDescription': 'Toto', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
118 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
119 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
120 'StudyDescription': 'Tata', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
121 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
122 ] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
123 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
124 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
125 'StudyDescription': 'Sébastien^', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
126 'StudyDate' : '19700202', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
127 } |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
128 ] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
129 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
130 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
131 |
15 | 132 |
3 | 133 class Orthanc(unittest.TestCase): |
134 def setUp(self): | |
83 | 135 if (sys.version_info >= (3, 0)): |
136 # Remove annoying warnings about unclosed socket in Python 3 | |
137 import warnings | |
138 warnings.simplefilter("ignore", ResourceWarning) | |
139 | |
3 | 140 DropOrthanc(_LOCAL) |
141 DropOrthanc(_REMOTE) | |
174 | 142 UninstallLuaCallbacks(_REMOTE) |
45 | 143 #print "In test", self._testMethodName |
44
ffa542cce638
Toolbox.FindExecutable()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
144 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
145 def AssertSameImages(self, truth, url): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
146 im = GetImage(_REMOTE, url) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
147 self.assertTrue(CompareLists(truth, im.getdata())) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
148 |
3 | 149 |
150 def test_system(self): | |
177 | 151 self.assertTrue('Version' in DoGet(_REMOTE, '/system')) |
152 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
153 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
154 | |
155 systemInfo = DoGet(_REMOTE, '/system') | |
156 if systemInfo["Version"] == "mainline": | |
157 print "Skipping version checks since you're currently in mainline" | |
158 return | |
159 | |
173 | 160 self.assertTrue(IsOrthancVersionAbove(_LOCAL, 0, 8, 6)) |
161 self.assertFalse(IsOrthancVersionAbove(_LOCAL, 0, 8, 7)) | |
162 self.assertTrue(IsOrthancVersionAbove(_LOCAL, 0, 7, 6)) | |
163 self.assertFalse(IsOrthancVersionAbove(_LOCAL, 0, 9, 6)) | |
164 self.assertFalse(IsOrthancVersionAbove(_LOCAL, 1, 8, 6)) | |
3 | 165 |
166 def test_upload(self): | |
173 | 167 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) |
168 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
169 | |
170 sizeDummyCT = 2472 | |
171 sizeOverwrite = 2476 | |
172 instance = '66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d' | |
173 | |
3 | 174 u = UploadInstance(_REMOTE, 'DummyCT.dcm') |
183 | 175 self.assertEqual(instance, u['ID']) |
3 | 176 self.assertEqual('Success', u['Status']) |
173 | 177 |
183 | 178 if True: |
179 # New test for Orthanc 1.4.3 | |
180 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', u['ParentSeries']) | |
181 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', u['ParentStudy']) | |
182 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', u['ParentPatient']) | |
183 | |
173 | 184 j = int(DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % instance)) |
185 s = sizeDummyCT + j | |
186 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
187 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
188 | |
3 | 189 u = UploadInstance(_REMOTE, 'DummyCT.dcm') |
190 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
191 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
192 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
193 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
173 | 194 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) |
195 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
196 | |
197 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % instance) | |
3 | 198 self.assertEqual('20070101', i['StudyDate']) |
173 | 199 self.assertEqual('KNIX', i['PatientName']) |
200 | |
201 if IsOrthancVersionAbove(_REMOTE, 1, 4, 2): | |
202 # Overwriting | |
203 self.assertEqual('Success', u['Status']) | |
204 else: | |
205 self.assertEqual('AlreadyStored', u['Status']) | |
206 | |
207 u = UploadInstance(_REMOTE, 'DummyCT-overwrite.dcm') | |
208 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
209 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
210 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
211 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
212 | |
213 if IsOrthancVersionAbove(_REMOTE, 1, 4, 2): | |
214 # Overwriting | |
215 self.assertEqual('Success', u['Status']) | |
216 j2 = int(DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % instance)) | |
217 s2 = sizeOverwrite + j2 | |
218 self.assertNotEqual(s, s2) | |
219 self.assertNotEqual(j, j2) | |
220 self.assertEqual('%d' % s2, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
221 self.assertEqual('%d' % s2, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
222 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % instance) | |
223 self.assertEqual('ANOTHER', i['PatientName']) | |
224 else: | |
225 self.assertEqual('AlreadyStored', u['Status']) | |
226 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
227 self.assertEqual('%d' % s, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
3 | 228 |
5 | 229 def test_upload_2(self): |
3 | 230 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
231 instance = DoGet(_REMOTE, '/instances/%s' % i) | |
232 self.assertEqual(i, instance['ID']) | |
233 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', | |
234 instance['MainDicomTags']['SOPInstanceUID']) | |
235 | |
236 series = DoGet(_REMOTE, '/series/%s' % instance['ParentSeries']) | |
237 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
238 series['MainDicomTags']['SeriesInstanceUID']) | |
239 | |
240 study = DoGet(_REMOTE, '/studies/%s' % series['ParentStudy']) | |
241 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
242 study['MainDicomTags']['StudyInstanceUID']) | |
243 | |
244 patient = DoGet(_REMOTE, '/patients/%s' % study['ParentPatient']) | |
245 self.assertEqual('ozp00SjY2xG', | |
246 patient['MainDicomTags']['PatientID']) | |
247 | |
248 dicom = DoGet(_REMOTE, '/instances/%s/file' % instance['ID']) | |
249 self.assertEqual(2472, len(dicom)) | |
250 self.assertEqual('3e29b869978b6db4886355a2b1132124', ComputeMD5(dicom)) | |
251 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
252 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/simplified-tags' % i)['StationName']) | |
253 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/tags' % i)['0008,1010']['Value']) | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
254 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/tags?simplify' % i)['StationName']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
255 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/tags?short' % i)['0008,1010']) |
3 | 256 |
257 | |
5 | 258 def test_images(self): |
259 i = UploadInstance(_REMOTE, 'Phenix/IM-0001-0001.dcm')['ID'] | |
260 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
3 | 261 |
5 | 262 im = GetImage(_REMOTE, '/instances/%s/preview' % i) |
263 self.assertEqual("L", im.mode) | |
264 self.assertEqual(512, im.size[0]) | |
265 self.assertEqual(358, im.size[1]) | |
266 | |
267 im = GetImage(_REMOTE, '/instances/%s/image-uint8' % i) | |
268 self.assertEqual("L", im.mode) | |
269 self.assertEqual(512, im.size[0]) | |
270 self.assertEqual(358, im.size[1]) | |
271 | |
272 im = GetImage(_REMOTE, '/instances/%s/image-uint16' % i) | |
273 self.assertEqual(512, im.size[0]) | |
274 self.assertEqual(358, im.size[1]) | |
275 | |
276 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % i) | |
277 self.assertEqual("L", im.mode) | |
278 self.assertEqual(512, im.size[0]) | |
279 self.assertEqual(358, im.size[1]) | |
280 | |
281 im = GetImage(_REMOTE, '/instances/%s/frames/0/image-uint8' % i) | |
282 self.assertEqual("L", im.mode) | |
283 self.assertEqual(512, im.size[0]) | |
284 self.assertEqual(358, im.size[1]) | |
285 | |
286 im = GetImage(_REMOTE, '/instances/%s/frames/0/image-uint16' % i) | |
287 self.assertEqual(512, im.size[0]) | |
288 self.assertEqual(358, im.size[1]) | |
64 | 289 |
290 # This is Little Endian Explicit | |
291 self.assertEqual('1.2.840.10008.1.2.1', DoGet(_REMOTE, '/instances/%s/header?simplify' % i)['TransferSyntaxUID']) | |
292 | |
6 | 293 |
294 def test_hierarchy(self): | |
295 UploadFolder(_REMOTE, 'Brainix/Epi') | |
296 UploadFolder(_REMOTE, 'Brainix/Flair') | |
297 UploadFolder(_REMOTE, 'Knee/T1') | |
298 UploadFolder(_REMOTE, 'Knee/T2') | |
299 | |
300 p = DoGet(_REMOTE, '/patients') | |
301 s = DoGet(_REMOTE, '/studies') | |
302 t = DoGet(_REMOTE, '/series') | |
303 self.assertEqual(2, len(p)) | |
304 self.assertEqual(2, len(s)) | |
305 self.assertEqual(4, len(t)) | |
306 self.assertEqual(94, len(DoGet(_REMOTE, '/instances'))) | |
307 | |
308 brainixPatient = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' | |
309 brainixStudy = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' | |
310 brainixEpi = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
311 brainixFlair = '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
312 | |
313 kneePatient = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' | |
314 kneeStudy = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' | |
315 kneeT1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
316 kneeT2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
317 | |
318 self.assertTrue(brainixPatient in p) | |
319 self.assertTrue(kneePatient in p) | |
320 self.assertTrue(brainixStudy in s) | |
321 self.assertTrue(kneeStudy in s) | |
322 self.assertTrue(brainixEpi in t) | |
323 self.assertTrue(brainixFlair in t) | |
324 self.assertTrue(kneeT1 in t) | |
325 self.assertTrue(kneeT2 in t) | |
326 | |
327 self.assertEqual(44, len(DoGet(_REMOTE, '/patients/%s/instances' % brainixPatient))) | |
328 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/series' % brainixPatient))) | |
329 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/studies' % brainixPatient))) | |
330 | |
331 self.assertEqual(50, len(DoGet(_REMOTE, '/patients/%s/instances' % kneePatient))) | |
332 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/series' % kneePatient))) | |
333 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/studies' % kneePatient))) | |
334 | |
335 self.assertEqual(2, len(DoGet(_REMOTE, '/studies/%s/series' % brainixStudy))) | |
336 self.assertEqual(44, len(DoGet(_REMOTE, '/studies/%s/instances' % brainixStudy))) | |
337 | |
338 self.assertEqual(2, len(DoGet(_REMOTE, '/studies/%s/series' % kneeStudy))) | |
339 self.assertEqual(50, len(DoGet(_REMOTE, '/studies/%s/instances' % kneeStudy))) | |
340 | |
341 self.assertEqual(22, len(DoGet(_REMOTE, '/series/%s/instances' % brainixEpi))) | |
342 self.assertEqual(22, len(DoGet(_REMOTE, '/series/%s/instances' % brainixFlair))) | |
343 self.assertEqual(24, len(DoGet(_REMOTE, '/series/%s/instances' % kneeT1))) | |
344 self.assertEqual(26, len(DoGet(_REMOTE, '/series/%s/instances' % kneeT2))) | |
345 | |
346 for patient in p: | |
347 for study in DoGet(_REMOTE, '/patients/%s/studies' % patient): | |
348 self.assertEqual(patient, study['ParentPatient']) | |
349 for series in DoGet(_REMOTE, '/studies/%s/series' % study['ID']): | |
350 self.assertEqual(study['ID'], series['ParentStudy']) | |
211 | 351 self.assertEqual('Unknown', series['Status']) |
6 | 352 for instance in DoGet(_REMOTE, '/series/%s/instances' % series['ID']): |
353 self.assertEqual(series['ID'], instance['ParentSeries']) | |
354 | |
355 self.assertEqual(json.dumps(DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % instance['ID'])), | |
356 json.dumps(DoGet(_REMOTE, '/instances/%s/tags' % instance['ID']))) | |
357 | |
358 | |
359 r = DoDelete(_REMOTE, "/studies/%s" % brainixStudy)['RemainingAncestor'] | |
360 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
361 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
362 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
363 self.assertEqual(50, len(DoGet(_REMOTE, '/instances'))) | |
364 self.assertEqual(None, r) | |
365 | |
366 r = DoDelete(_REMOTE, "/series/%s" % kneeT2)['RemainingAncestor'] | |
367 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
368 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
369 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
370 self.assertEqual(24, len(DoGet(_REMOTE, '/instances'))) | |
371 self.assertEqual('Study', r['Type']) | |
372 self.assertEqual(kneeStudy, r['ID']) | |
373 | |
374 r = DoDelete(_REMOTE, "/instances/%s" % DoGet(_REMOTE, '/instances')[0])['RemainingAncestor'] | |
375 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
376 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
377 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
378 self.assertEqual(23, len(DoGet(_REMOTE, '/instances'))) | |
379 self.assertEqual('Series', r['Type']) | |
380 self.assertEqual(kneeT1, r['ID']) | |
381 | |
382 r = DoDelete(_REMOTE, "/patients/%s" % kneePatient)['RemainingAncestor'] | |
383 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
384 self.assertEqual(0, len(DoGet(_REMOTE, '/studies'))) | |
385 self.assertEqual(0, len(DoGet(_REMOTE, '/series'))) | |
386 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
387 self.assertEqual(None, r) | |
388 | |
389 DropOrthanc(_REMOTE) | |
390 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
391 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
7 | 392 |
393 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
394 def test_multiframe(self): |
7 | 395 i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] |
396 self.assertEqual(76, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
397 | |
398 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % i) | |
399 self.assertEqual("L", im.mode) | |
400 self.assertEqual(512, im.size[0]) | |
401 self.assertEqual(512, im.size[1]) | |
402 | |
403 DoGet(_REMOTE, '/instances/%s/frames/0/image-uint8' % i) | |
404 DoGet(_REMOTE, '/instances/%s/frames/0/image-uint16' % i) | |
405 DoGet(_REMOTE, '/instances/%s/frames/75/preview' % i) | |
406 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/aaa/preview' % i)) | |
407 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/76/preview' % i)) | |
408 | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
409 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
410 def test_changes(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
411 # Check emptiness |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
412 c = DoGet(_REMOTE, '/changes') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
413 self.assertEqual(0, len(c['Changes'])) |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
414 #self.assertEqual(0, c['Last']) # Not true anymore for Orthanc >= 1.5.2 |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
415 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
416 c = DoGet(_REMOTE, '/changes?last') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
417 self.assertEqual(0, len(c['Changes'])) |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
418 #self.assertEqual(0, c['Last']) # Not true anymore for Orthanc >= 1.5.2 |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
419 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
420 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
421 # Add 1 instance |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
422 i = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
423 c = DoGet(_REMOTE, '/changes') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
424 begin = c['Last'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
425 self.assertEqual(4, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
426 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
427 self.assertEqual(c['Changes'][-1]['Seq'], c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
428 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
429 c = DoGet(_REMOTE, '/changes?last') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
430 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
431 self.assertEqual(begin, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
432 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
433 c = DoGet(_REMOTE, '/changes?limit=1&since=' + str(begin - 1)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
434 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
435 self.assertEqual(begin, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
436 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
437 c = DoGet(_REMOTE, '/changes?limit=1&since=' + str(begin - 2)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
438 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
439 self.assertEqual(begin - 1, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
440 self.assertFalse(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
441 c = DoGet(_REMOTE, '/changes?limit=1&since=' + str(begin - 3)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
442 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
443 self.assertEqual(begin - 2, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
444 self.assertFalse(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
445 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
446 UploadFolder(_REMOTE, 'Knee/T1') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
447 UploadFolder(_REMOTE, 'Knee/T2') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
448 since = begin |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
449 countPatients = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
450 countStudies = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
451 countSeries = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
452 countInstances = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
453 completed = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
454 while True: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
455 c = DoGet(_REMOTE, '/changes', { 'since' : since, 'limit' : 3 }) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
456 since = c['Last'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
457 for i in c['Changes']: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
458 if i['ResourceType'] == 'Instance': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
459 countInstances += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
460 if i['ResourceType'] == 'Patient': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
461 countPatients += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
462 if i['ResourceType'] == 'Study': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
463 countStudies += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
464 if i['ResourceType'] == 'Series': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
465 countSeries += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
466 if i['ChangeType'] == 'NewInstance': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
467 countInstances += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
468 if i['ChangeType'] == 'NewPatient': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
469 countPatients += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
470 if i['ChangeType'] == 'NewStudy': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
471 countStudies += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
472 if i['ChangeType'] == 'NewSeries': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
473 countSeries += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
474 if i['ChangeType'] == 'CompletedSeries': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
475 completed += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
476 self.assertTrue('ID' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
477 self.assertTrue('Path' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
478 self.assertTrue('Seq' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
479 if c['Done']: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
480 break |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
481 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
482 self.assertEqual(2 * 50, countInstances) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
483 self.assertEqual(2 * 1, countPatients) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
484 self.assertEqual(2 * 1, countStudies) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
485 self.assertEqual(2 * 2, countSeries) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
486 self.assertEqual(0, completed) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
487 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
488 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
489 def test_archive(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
490 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
491 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') |
192 | 492 knee = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' |
493 | |
494 z = GetArchive(_REMOTE, '/patients/%s/archive' % knee) | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
495 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
496 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
497 z = GetArchive(_REMOTE, '/studies/%s/archive' % DoGet(_REMOTE, '/studies')[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
498 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
499 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
500 z = GetArchive(_REMOTE, '/series/%s/archive' % DoGet(_REMOTE, '/series')[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
501 self.assertEqual(1, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
502 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
503 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
192 | 504 brainix = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' |
505 | |
506 z = GetArchive(_REMOTE, '/patients/%s/archive' % knee) | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
507 self.assertEqual(2, len(z.namelist())) |
192 | 508 |
509 z = PostArchive(_REMOTE, '/tools/create-archive', { | |
510 'Resources' : [ brainix, knee ] | |
511 }) | |
512 self.assertEqual(3, len(z.namelist())) | |
513 | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
514 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
515 def test_media_archive(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
516 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
517 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
518 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
519 z = GetArchive(_REMOTE, '/patients/%s/media' % DoGet(_REMOTE, '/patients')[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
520 self.assertEqual(3, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
521 self.assertTrue('IMAGES/IM0' in z.namelist()) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
522 self.assertTrue('IMAGES/IM1' in z.namelist()) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
523 self.assertTrue('DICOMDIR' in z.namelist()) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
524 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
525 try: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
526 os.remove('/tmp/DICOMDIR') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
527 except: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
528 # The file does not exist |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
529 pass |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
530 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
531 z.extract('DICOMDIR', '/tmp') |
45 | 532 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
533 stderr = subprocess.STDOUT).split('\n') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
534 self.assertEqual(3, len(a)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
535 self.assertTrue(a[0].startswith('Warning')) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
536 self.assertEqual('BasicDirectory', a[1]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
537 self.assertEqual('', a[2]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
538 |
45 | 539 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
540 stderr = subprocess.STDOUT).split('\n') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
541 self.assertEqual(1, len(a)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
542 self.assertEqual('', a[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
543 |
45 | 544 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
545 self.assertTrue(re.search('1.3.46.670589.11.17521.5.0.3124.2008081908590448738', a) != None) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
546 self.assertTrue(re.search('1.3.46.670589.11.17521.5.0.3124.2008081909113806560', a) != None) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
547 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
548 os.remove('/tmp/DICOMDIR') |
10 | 549 |
550 | |
551 def test_protection(self): | |
552 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
553 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
554 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
555 a = DoGet(_REMOTE, '/patients')[0] | |
556 b = DoGet(_REMOTE, '/patients')[1] | |
557 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
558 DoPut(_REMOTE, '/patients/%s/protected' % a, '0', 'text/plain') | |
559 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
560 DoPut(_REMOTE, '/patients/%s/protected' % a, '1', 'text/plain') | |
561 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
562 DoPut(_REMOTE, '/patients/%s/protected' % a, '0', 'text/plain') | |
563 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
564 | |
565 | |
12 | 566 def test_raw_tags(self): |
10 | 567 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
568 | |
569 dicom = DoGet(_REMOTE, '/instances/%s/file' % i) | |
570 self.assertEqual('1a7c56cb02d6e742cc9c856a8ac182e3', ComputeMD5(dicom)) | |
571 | |
572 s = '/instances/%s/content/' % i | |
573 | |
574 self.assertEqual('LOGIQBOOK', DoGet(_REMOTE, s + '0008-1010').strip()) | |
575 self.assertRaises(Exception, lambda: DoGet(_REMOTE, s + '0008-1011')) | |
576 | |
577 self.assertEqual('Abdomen', DoGet(_REMOTE, s + '7fe1-1001/0/7fe1-1008/0/7fe1-1057').strip()) | |
578 self.assertEqual('cla_3c', DoGet(_REMOTE, s + '7fe1-1001/0/7fe1-1008/8/7fe1-1057').strip()) | |
579 | |
580 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
581 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
582 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
583 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
584 | |
585 for i in DoGet(_REMOTE, '/instances'): | |
586 aid = DoGet(_REMOTE, '/instances/%s' % i)['MainDicomTags']['SOPInstanceUID'] | |
587 self.assertEqual(aid, DoGet(_REMOTE, '/instances/%s/content/0008-0018' % i).replace(chr(0), '')) | |
588 | |
589 | |
590 def test_raw_tags_mdn(self): | |
591 # Bug reported by Cyril Paulus | |
592 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
593 self.assertAlmostEqual(0.000027, DoGet(_REMOTE, '/instances/%s/content/7053-1000' % i)) | |
594 | |
595 | |
596 def test_modify_instance(self): | |
597 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] | |
598 modified = DoPost(_REMOTE, '/instances/%s/modify' % i, | |
599 json.dumps({ | |
600 "Replace" : { | |
601 "PatientName" : "hello", | |
602 #"PatientID" : "world" | |
603 }, | |
604 "Remove" : [ "StationName" ], | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
605 "RemovePrivateTags" : True |
10 | 606 }), |
607 'application/json') | |
608 j = DoPost(_REMOTE, '/instances', modified, 'application/dicom')['ID'] | |
609 | |
610 self.assertNotEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
611 #self.assertNotEqual('world', DoGet(_REMOTE, '/instances/%s/content/0010-0020' % i).strip()) | |
83 | 612 self.assertEqual('LOGIQBOOK', DoGet(_REMOTE, '/instances/%s/content/0008-1010' % i).strip()) |
10 | 613 DoGet(_REMOTE, '/instances/%s/content/6003-1010' % i) # Some private tag |
614 | |
615 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
616 #self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/0010-0020' % j).strip()) | |
617 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/0008-1010' % j)) | |
618 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/6003-1010' % j)) | |
619 | |
620 | |
621 def test_modify_series(self): | |
622 # Upload 4 images from the same series | |
623 for i in range(4): | |
624 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
625 | |
626 origSeries = DoGet(_REMOTE, '/series')[0] | |
627 newSeries = DoPost(_REMOTE, '/series/%s/modify' % origSeries, | |
628 '{"Replace":{"PatientName":"Jodogne"}}', | |
629 'application/json')['ID'] | |
630 | |
631 self.assertEqual(origSeries, DoGet(_REMOTE, '/series/%s' % newSeries)['ModifiedFrom']) | |
632 instances = DoGet(_REMOTE, '/series/%s' % newSeries)['Instances'] | |
633 self.assertEqual(4, len(instances)) | |
634 for i in instances: | |
635 j = DoGet(_REMOTE, '/instances/%s' % i)['ModifiedFrom'] | |
636 self.assertEqual(newSeries, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
637 self.assertEqual(origSeries, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
638 | |
639 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
640 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
641 | |
642 | |
643 def test_modify_study(self): | |
644 # Upload 4 images from the 2 series of the same study | |
645 for i in range(4): | |
646 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
647 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
648 | |
649 origStudy = DoGet(_REMOTE, '/studies')[0] | |
650 newStudy = DoPost(_REMOTE, '/studies/%s/modify' % origStudy, | |
651 '{"Replace":{"PatientName":"Jodogne"}}', | |
652 'application/json')['ID'] | |
653 | |
654 self.assertEqual(origStudy, DoGet(_REMOTE, '/studies/%s' % newStudy)['ModifiedFrom']) | |
655 series = DoGet(_REMOTE, '/studies/%s' % newStudy)['Series'] | |
656 self.assertEqual(2, len(series)) | |
657 for s in series: | |
658 ss = DoGet(_REMOTE, '/series/%s' % s)['ModifiedFrom'] | |
659 self.assertEqual(newStudy, DoGet(_REMOTE, '/series/%s' % s)['ParentStudy']) | |
660 self.assertEqual(origStudy, DoGet(_REMOTE, '/series/%s' % ss)['ParentStudy']) | |
661 | |
662 instances = DoGet(_REMOTE, '/series/%s' % s)['Instances'] | |
663 for i in instances: | |
664 j = DoGet(_REMOTE, '/instances/%s' % i)['ModifiedFrom'] | |
665 self.assertEqual(s, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
666 self.assertEqual(ss, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
667 | |
668 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
669 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
670 | |
671 | |
672 def test_anonymize_series(self): | |
673 # Upload 4 images from the same series | |
674 for i in range(4): | |
675 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
676 | |
677 origSeries = DoGet(_REMOTE, '/series')[0] | |
678 newSeries = DoPost(_REMOTE, '/series/%s/anonymize' % origSeries, | |
679 '{}', | |
680 'application/json')['ID'] | |
681 | |
682 self.assertEqual(origSeries, DoGet(_REMOTE, '/series/%s' % newSeries)['AnonymizedFrom']) | |
683 instances = DoGet(_REMOTE, '/series/%s' % newSeries)['Instances'] | |
684 self.assertEqual(4, len(instances)) | |
685 for i in instances: | |
686 j = DoGet(_REMOTE, '/instances/%s' % i)['AnonymizedFrom'] | |
687 self.assertEqual(newSeries, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
688 self.assertEqual(origSeries, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
689 | |
690 DoGet(_REMOTE, '/instances/%s/content/0008-1010' % j) | |
691 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/0008-1010' % i)) | |
692 | |
693 | |
694 def test_anonymize_study(self): | |
695 # Upload 4 images from the 2 series of the same study | |
696 for i in range(4): | |
697 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
698 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
699 | |
700 origStudy = DoGet(_REMOTE, '/studies')[0] | |
701 newStudy = DoPost(_REMOTE,'/studies/%s/anonymize' % origStudy, | |
702 '{"Replace":{"PatientName":"Jodogne"}}', | |
703 'application/json')['ID'] | |
704 | |
705 self.assertEqual(origStudy, DoGet(_REMOTE, '/studies/%s' % newStudy)['AnonymizedFrom']) | |
706 series = DoGet(_REMOTE, '/studies/%s' % newStudy)['Series'] | |
707 self.assertEqual(2, len(series)) | |
708 for s in series: | |
709 ss = DoGet(_REMOTE, '/series/%s' % s)['AnonymizedFrom'] | |
710 self.assertEqual(newStudy, DoGet(_REMOTE, '/series/%s' % s)['ParentStudy']) | |
711 self.assertEqual(origStudy, DoGet(_REMOTE, '/series/%s' % ss)['ParentStudy']) | |
712 | |
713 instances = DoGet(_REMOTE, '/series/%s' % s)['Instances'] | |
714 for i in instances: | |
715 j = DoGet(_REMOTE, '/instances/%s' % i)['AnonymizedFrom'] | |
716 self.assertEqual(s, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
717 self.assertEqual(ss, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
718 | |
719 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
720 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
11 | 721 |
722 | |
723 | |
724 def test_storescu(self): | |
725 # Check emptiness | |
726 e = DoGet(_REMOTE, '/exports') | |
727 self.assertEqual(0, len(e['Exports'])) | |
728 self.assertEqual(0, e['Last']) | |
729 self.assertTrue(e['Done']) | |
730 e = DoGet(_REMOTE, '/exports?last') | |
731 self.assertEqual(0, len(e['Exports'])) | |
732 self.assertEqual(0, e['Last']) | |
733 self.assertTrue(e['Done']) | |
734 | |
735 # Add 1 instance | |
736 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
737 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
738 | |
739 # Export the instance | |
740 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') # instance | |
741 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
742 self.assertEqual(1, len(DoGet(_LOCAL, '/studies'))) | |
743 self.assertEqual(1, len(DoGet(_LOCAL, '/series'))) | |
744 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
745 | |
746 e = DoGet(_REMOTE, '/exports') | |
747 self.assertEqual(1, len(e['Exports'])) | |
748 self.assertTrue(e['Done']) | |
749 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
750 e = DoGet(_REMOTE, '/exports?limit=1') | |
751 self.assertEqual(1, len(e['Exports'])) | |
752 self.assertTrue(e['Done']) | |
753 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
754 e = DoGet(_REMOTE, '/exports?last') | |
755 self.assertEqual(1, len(e['Exports'])) | |
756 self.assertTrue(e['Done']) | |
757 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
758 seqInstance = e['Last'] | |
759 | |
760 # Export the series | |
761 j = DoPost(_REMOTE, '/modalities/orthanctest/store', 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', 'text/plain') | |
762 | |
763 e = DoGet(_REMOTE, '/exports') | |
764 self.assertEqual(2, len(e['Exports'])) | |
765 self.assertTrue(e['Done']) | |
766 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
767 seqSeries = e['Last'] | |
768 self.assertNotEqual(seqInstance, seqSeries) | |
769 e = DoGet(_REMOTE, '/exports?limit=1&since=0') | |
770 self.assertEqual(1, len(e['Exports'])) | |
771 self.assertFalse(e['Done']) | |
772 self.assertEqual(e['Exports'][-1]['Seq'], seqInstance) | |
773 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqInstance)) | |
774 self.assertEqual(1, len(e['Exports'])) | |
775 self.assertTrue(e['Done']) | |
776 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
777 e = DoGet(_REMOTE, '/exports?last') | |
778 self.assertEqual(1, len(e['Exports'])) | |
779 self.assertTrue(e['Done']) | |
780 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
781 | |
782 # Export the study | |
783 j = DoPost(_REMOTE, '/modalities/orthanctest/store', 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', 'text/plain') | |
784 seqStudy = DoGet(_REMOTE, '/exports')['Last'] | |
785 | |
786 # Export the patient | |
787 j = DoPost(_REMOTE, '/modalities/orthanctest/store', '6816cb19-844d5aee-85245eba-28e841e6-2414fae2', 'text/plain') | |
788 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
789 self.assertEqual(1, len(DoGet(_LOCAL, '/studies'))) | |
790 self.assertEqual(1, len(DoGet(_LOCAL, '/series'))) | |
791 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
792 | |
793 e = DoGet(_REMOTE, '/exports') | |
794 self.assertEqual(4, len(e['Exports'])) | |
795 self.assertTrue(e['Done']) | |
796 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
797 seqPatient = e['Last'] | |
798 self.assertNotEqual(seqInstance, seqSeries) | |
799 self.assertNotEqual(seqSeries, seqStudy) | |
800 self.assertNotEqual(seqStudy, seqPatient) | |
801 self.assertTrue(seqInstance < seqSeries) | |
802 self.assertTrue(seqSeries < seqStudy) | |
803 self.assertTrue(seqStudy < seqPatient) | |
804 e = DoGet(_REMOTE, '/exports?limit=1&since=0') | |
805 self.assertEqual(1, len(e['Exports'])) | |
806 self.assertFalse(e['Done']) | |
807 self.assertEqual(e['Exports'][-1]['Seq'], seqInstance) | |
808 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqInstance)) | |
809 self.assertEqual(1, len(e['Exports'])) | |
810 self.assertFalse(e['Done']) | |
811 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
812 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqSeries)) | |
813 self.assertEqual(1, len(e['Exports'])) | |
814 self.assertFalse(e['Done']) | |
815 self.assertEqual(e['Exports'][-1]['Seq'], seqStudy) | |
816 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqStudy)) | |
817 self.assertEqual(1, len(e['Exports'])) | |
818 self.assertTrue(e['Done']) | |
819 self.assertEqual(e['Exports'][-1]['Seq'], seqPatient) | |
820 e = DoGet(_REMOTE, '/exports?last') | |
821 self.assertEqual(1, len(e['Exports'])) | |
822 self.assertTrue(e['Done']) | |
823 self.assertEqual(e['Exports'][-1]['Seq'], seqPatient) | |
824 | |
825 | |
826 # Check the content of the logged information | |
827 e = DoGet(_REMOTE, '/exports')['Exports'] | |
828 | |
829 if 'PatientID' in e[0]: | |
830 # Since Orthanc 0.8.6 | |
831 patient = 'PatientID' | |
832 study = 'StudyInstanceUID' | |
833 series = 'SeriesInstanceUID' | |
834 instance = 'SOPInstanceUID' | |
835 else: | |
836 # Up to Orthanc 0.8.5 | |
837 patient = 'PatientId' | |
838 study = 'StudyInstanceUid' | |
839 series = 'SeriesInstanceUid' | |
840 instance = 'SopInstanceUid' | |
841 | |
842 for k in range(4): | |
843 self.assertTrue('Date' in e[k]) | |
844 self.assertTrue('Seq' in e[k]) | |
845 self.assertEqual('orthanctest', e[k]['RemoteModality']) | |
846 | |
847 self.assertEqual(10, len(e[0])) | |
848 self.assertEqual('Instance', e[0]['ResourceType']) | |
849 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', e[0]['ID']) | |
850 self.assertEqual('/instances/66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', e[0]['Path']) | |
851 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', e[0][instance]) | |
852 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', e[0][series]) | |
853 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[0][study]) | |
854 self.assertEqual('ozp00SjY2xG', e[0][patient]) | |
855 | |
856 self.assertEqual(9, len(e[1])) | |
857 self.assertEqual('Series', e[1]['ResourceType']) | |
858 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', e[1]['ID']) | |
859 self.assertEqual('/series/f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', e[1]['Path']) | |
860 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', e[1][series]) | |
861 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[1][study]) | |
862 self.assertEqual('ozp00SjY2xG', e[1][patient]) | |
863 | |
864 self.assertEqual(8, len(e[2])) | |
865 self.assertEqual('Study', e[2]['ResourceType']) | |
866 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', e[2]['ID']) | |
867 self.assertEqual('/studies/b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', e[2]['Path']) | |
868 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[2][study]) | |
869 self.assertEqual('ozp00SjY2xG', e[2][patient]) | |
870 | |
871 self.assertEqual(7, len(e[3])) | |
872 self.assertEqual('Patient', e[3]['ResourceType']) | |
873 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', e[3]['ID']) | |
874 self.assertEqual('/patients/6816cb19-844d5aee-85245eba-28e841e6-2414fae2', e[3]['Path']) | |
875 self.assertEqual('ozp00SjY2xG', e[3][patient]) | |
876 | |
877 DropOrthanc(_REMOTE) | |
878 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
879 | |
880 | |
881 def test_store_peer(self): | |
882 self.assertEqual(0, len(DoGet(_LOCAL, '/exports')['Exports'])) | |
883 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
884 | |
885 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
886 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
887 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
888 | |
889 j = DoPost(_REMOTE, '/peers/peer/store', str(i), 'text/plain') | |
890 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
891 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
892 | |
893 self.assertEqual(1, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
894 | |
895 DropOrthanc(_REMOTE) | |
896 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
897 | |
898 | |
899 def test_bulk_storescu(self): | |
900 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
901 | |
902 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
903 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
904 | |
905 j = DoPost(_REMOTE, '/modalities/orthanctest/store', [ a['ID'], b['ID'] ], 'application/json') | |
906 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
907 | |
908 DropOrthanc(_LOCAL) | |
909 | |
910 # Send using patient's UUID | |
911 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
912 j = DoPost(_REMOTE, '/modalities/orthanctest/store', | |
913 [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ], 'application/json') | |
914 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
915 | |
916 | |
917 def test_color(self): | |
918 i = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] | |
919 im = GetImage(_REMOTE, '/instances/%s/preview' % i) | |
920 self.assertEqual("RGB", im.mode) | |
921 self.assertEqual(41, im.size[0]) | |
922 self.assertEqual(41, im.size[1]) | |
923 | |
924 # http://effbot.org/zone/pil-comparing-images.htm | |
13 | 925 truth = Image.open(GetDatabasePath('ColorTestMalaterre.png')) |
11 | 926 self.assertTrue(ImageChops.difference(im, truth).getbbox() is None) |
927 | |
928 | |
12 | 929 def test_faking_ruby_put(self): |
930 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
931 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
932 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
933 a = DoGet(_REMOTE, '/patients')[0] | |
934 b = DoGet(_REMOTE, '/patients')[1] | |
935 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
936 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '0') | |
937 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
938 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '1') | |
939 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
940 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '0') | |
941 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
942 | |
943 | |
944 def test_faking_ruby_delete(self): | |
945 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
946 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
947 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
948 a = DoGet(_REMOTE, '/patients')[0] | |
949 b = DoGet(_REMOTE, '/patients')[1] | |
950 DoGet(_REMOTE, '/patients/%s' % a, data = { '_method' : 'DELETE' }) | |
951 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
952 DoGet(_REMOTE, '/patients/%s' % b, data = { '_method' : 'DELETE' }) | |
953 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
954 | |
955 | |
956 def test_faking_google_put(self): | |
957 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
958 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
959 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
960 a = DoGet(_REMOTE, '/patients')[0] | |
961 b = DoGet(_REMOTE, '/patients')[1] | |
962 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
963 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '0') | |
964 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
965 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '1') | |
966 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
967 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '0') | |
968 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
969 | |
970 | |
971 def test_faking_google_delete(self): | |
972 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
973 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
974 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
975 a = DoGet(_REMOTE, '/patients')[0] | |
976 b = DoGet(_REMOTE, '/patients')[1] | |
977 DoPost(_REMOTE, '/patients/%s' % a, headers = { 'X-HTTP-Method-Override' : 'DELETE' }) | |
978 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
979 DoPost(_REMOTE, '/patients/%s' % b, headers = { 'X-HTTP-Method-Override' : 'DELETE' }) | |
980 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
981 | |
982 | |
983 def test_lua(self): | |
984 self.assertEqual(42, DoPost(_REMOTE, '/tools/execute-script', 'print(42)')) | |
985 self.assertTrue(IsDefinedInLua(_REMOTE, 'PrintRecursive')) | |
986 self.assertFalse(IsDefinedInLua(_REMOTE, 'HelloWorld')) | |
987 | |
988 | |
989 def test_metadata(self): | |
990 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
991 p = DoGet(_REMOTE, '/patients')[0] | |
992 i = DoGet(_REMOTE, '/instances')[0] | |
993 | |
994 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
995 self.assertEqual(1, len(m)) | |
996 self.assertEqual('LastUpdate', m[0]) | |
997 | |
998 m = DoGet(_REMOTE, '/instances/%s/metadata' % i) | |
145 | 999 self.assertEqual(8, len(m)) |
12 | 1000 self.assertTrue('IndexInSeries' in m) |
1001 self.assertTrue('ReceptionDate' in m) | |
1002 self.assertTrue('RemoteAET' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1003 self.assertTrue('Origin' in m) |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1004 self.assertTrue('TransferSyntax' in m) |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1005 self.assertTrue('SopClassUid' in m) |
145 | 1006 self.assertTrue('RemoteIP' in m) |
1007 self.assertTrue('HttpUsername' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1008 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/IndexInSeries' % i), 1) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1009 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i), 'RestApi') |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1010 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i), '') # None, received by REST API |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1011 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % i), '1.2.840.10008.1.2.4.91') # JPEG2k |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1012 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % i), '1.2.840.10008.5.1.4.1.1.4') |
12 | 1013 |
1014 # Play with custom metadata | |
1015 DoPut(_REMOTE, '/patients/%s/metadata/5555' % p, 'coucou') | |
1016 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
1017 self.assertEqual(2, len(m)) | |
1018 self.assertTrue('LastUpdate' in m) | |
1019 self.assertTrue('5555' in m) | |
1020 self.assertEqual('coucou', DoGet(_REMOTE, '/patients/%s/metadata/5555' % p)) | |
1021 DoPut(_REMOTE, '/patients/%s/metadata/5555' % p, 'hello') | |
1022 self.assertEqual('hello', DoGet(_REMOTE, '/patients/%s/metadata/5555' % p)) | |
1023 DoDelete(_REMOTE, '/patients/%s/metadata/5555' % p) | |
1024 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
1025 self.assertEqual(1, len(m)) | |
1026 self.assertTrue('LastUpdate' in m) | |
13 | 1027 |
1028 | |
1029 def test_statistics(self): | |
1030 # Upload 16 instances | |
1031 for i in range(4): | |
1032 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1033 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1034 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1035 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1036 | |
1037 s = DoGet(_REMOTE, '/statistics') | |
1038 self.assertEqual(16, s['CountInstances']) | |
1039 self.assertEqual(2, s['CountPatients']) | |
1040 self.assertEqual(2, s['CountStudies']) | |
1041 self.assertEqual(4, s['CountSeries']) | |
1042 d = int(s['TotalUncompressedSize']) | |
1043 | |
1044 e = 0 | |
1045 for patient in DoGet(_REMOTE, '/patients'): | |
1046 s = DoGet(_REMOTE, '/patients/%s/statistics' % patient) | |
1047 self.assertEqual(8, s['CountInstances']) | |
1048 self.assertEqual(1, s['CountStudies']) | |
1049 self.assertEqual(2, s['CountSeries']) | |
1050 e += int(s['UncompressedSize']) | |
1051 | |
1052 for study in DoGet(_REMOTE, '/studies'): | |
1053 s = DoGet(_REMOTE, '/studies/%s/statistics' % study) | |
1054 self.assertEqual(8, s['CountInstances']) | |
1055 self.assertEqual(2, s['CountSeries']) | |
1056 e += int(s['UncompressedSize']) | |
1057 | |
1058 for series in DoGet(_REMOTE, '/series'): | |
1059 s = DoGet(_REMOTE, '/series/%s/statistics' % series) | |
1060 self.assertEqual(4, s['CountInstances']) | |
1061 e += int(s['UncompressedSize']) | |
1062 | |
1063 self.assertEqual(3 * d, e) | |
1064 | |
1065 | |
1066 def test_custom_attachment(self): | |
1067 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
1068 patient = DoGet(_REMOTE, '/patients')[0] | |
1069 instance = DoGet(_REMOTE, '/instances')[0] | |
1070 size = int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']) | |
1071 self.assertEqual(size, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1072 | |
1073 self.assertEqual(0, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1074 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) | |
1075 self.assertTrue('dicom' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) | |
1076 self.assertTrue('dicom-as-json' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) | |
1077 | |
1078 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/patients/%s/attachments/22' % patient, 'hello')) | |
1079 hello = 'hellohellohellohellohellohellohellohellohello' | |
1080 DoPut(_REMOTE, '/patients/%s/attachments/1025' % patient, hello) | |
1081 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1082 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1083 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1084 size + int(DoGet(_REMOTE, '/patients/%s/attachments/1025/compressed-size' % patient))) | |
1085 | |
1086 DoPut(_REMOTE, '/patients/%s/attachments/1026' % patient, 'world') | |
1087 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1088 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1089 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1090 size + | |
1091 int(DoGet(_REMOTE, '/patients/%s/attachments/1025/compressed-size' % patient)) + | |
1092 int(DoGet(_REMOTE, '/patients/%s/attachments/1026/compressed-size' % patient))) | |
1093 | |
1094 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1095 self.assertEqual(hello, DoGet(_REMOTE, '/patients/%s/attachments/1025/data' % patient)) | |
1096 self.assertEqual('world', DoGet(_REMOTE, '/patients/%s/attachments/1026/data' % patient)) | |
1097 DoPost(_REMOTE, '/patients/%s/attachments/1025/verify-md5' % patient) | |
1098 DoPost(_REMOTE, '/patients/%s/attachments/1026/verify-md5' % patient) | |
1099 DoPut(_REMOTE, '/patients/%s/attachments/1026' % patient, 'world2') | |
1100 self.assertEqual('world2', DoGet(_REMOTE, '/patients/%s/attachments/1026/data' % patient)) | |
1101 | |
1102 self.assertRaises(Exception, lambda: DoDelete(_REMOTE, '/instances/%s/attachments/dicom' % instance)) | |
1103 DoDelete(_REMOTE, '/patients/%s/attachments/1025' % patient) | |
1104 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1105 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1106 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1107 size + int(DoGet(_REMOTE, '/patients/%s/attachments/1026/compressed-size' % patient))) | |
1108 | |
1109 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1110 DoDelete(_REMOTE, '/patients/%s/attachments/1026' % patient) | |
1111 self.assertEqual(0, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1112 | |
1113 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), size) | |
1114 self.assertEqual(size, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1115 | |
1116 | |
1117 def test_incoming_storescu(self): | |
1118 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
45 | 1119 subprocess.check_call([ FindExecutable('storescu'), |
44
ffa542cce638
Toolbox.FindExecutable()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
1120 _REMOTE['Server'], str(_REMOTE['DicomPort']), |
13 | 1121 GetDatabasePath('ColorTestImageJ.dcm') ]) |
1122 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1123 | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1124 i = DoGet(_REMOTE, '/instances') |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1125 self.assertEqual(1, len(i)) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1126 m = DoGet(_REMOTE, '/instances/%s/metadata' % i[0]) |
145 | 1127 self.assertEqual(8, len(m)) |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1128 self.assertTrue('IndexInSeries' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1129 self.assertTrue('ReceptionDate' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1130 self.assertTrue('RemoteAET' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1131 self.assertTrue('Origin' in m) |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1132 self.assertTrue('TransferSyntax' in m) |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1133 self.assertTrue('SopClassUid' in m) |
145 | 1134 self.assertTrue('RemoteIP' in m) |
1135 self.assertTrue('CalledAET' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1136 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/IndexInSeries' % i[0]), 1) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1137 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i[0]), 'DicomProtocol') |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1138 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i[0]), 'STORESCU') |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1139 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % i[0]), '1.2.840.10008.1.2.1') |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1140 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % i[0]), '1.2.840.10008.5.1.4.1.1.7') |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1141 |
13 | 1142 |
1143 def test_incoming_findscu(self): | |
1144 UploadInstance(_REMOTE, 'Multiframe.dcm') | |
1145 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') | |
1146 | |
1147 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', '0010,0010' ]) | |
1148 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', i) | |
1149 self.assertEqual(2, len(patientNames)) | |
1150 self.assertTrue('Test Patient BG ' in patientNames) | |
1151 self.assertTrue('Anonymized' in patientNames) | |
1152 | |
1153 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,0021' ]) | |
1154 series = re.findall('\(0008,0021\).*?\[\s*(.*?)\s*\]', i) | |
1155 self.assertEqual(2, len(series)) | |
1156 self.assertTrue('20070208' in series) | |
1157 self.assertTrue('19980312' in series) | |
1158 | |
56
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1159 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,0021', '-k', 'ModalitiesInStudy=MR\\XA' ]) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1160 series = re.findall('\(0008,0021\).*?\[\s*(.*?)\s*\]', i) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1161 self.assertEqual(1, len(series)) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1162 self.assertTrue('19980312' in series) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1163 |
13 | 1164 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'PatientName=Anonymized' ]) |
1165 series = re.findall('\(0010,0010\).*?\[\s*(.*?)\s*\]', i) | |
1166 self.assertEqual(1, len(series)) | |
1167 | |
1168 # Test the "CaseSentitivePN" flag (false by default) | |
1169 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'PatientName=anonymized' ]) | |
1170 series = re.findall('\(0010,0010\).*?\[\s*(.*?)\s*\]', i) | |
1171 self.assertEqual(1, len(series)) | |
66
821d9eb73c45
Test returning sequence values
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
1172 |
70 | 1173 # Test range search (buggy if Orthanc <= 0.9.6) |
1174 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=19980312-' ]) | |
1175 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1176 self.assertEqual(2, len(studies)) | |
1177 self.assertTrue('20070208' in studies) | |
1178 self.assertTrue('19980312' in studies) | |
1179 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=19980312-19980312' ]) | |
1180 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1181 self.assertEqual(1, len(studies)) | |
1182 self.assertTrue('19980312' in studies) | |
1183 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=-19980312' ]) | |
1184 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1185 self.assertEqual(1, len(studies)) | |
1186 self.assertTrue('19980312' in studies) | |
13 | 1187 |
1188 | |
191
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1189 def test_incoming_findscu_2(self): |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1190 # This test fails if "LookupMode_DatabaseOnly" is used |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1191 # (sequences are not available in this mode, and only main |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1192 # DICOM tags are returned) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1193 UploadInstance(_REMOTE, 'Multiframe.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1194 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1195 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1196 # Test returning sequence values (only since Orthanc 0.9.5) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1197 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,2112' ]) # "ColorTestImageJ" has this sequence tag |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1198 sequences = re.findall('\(0008,2112\)', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1199 self.assertEqual(1, len(sequences)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1200 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1201 # Test returning a non-main DICOM tag, |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1202 # "SecondaryCaptureDeviceID" (0018,1010), whose value is |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1203 # "MEDPC" in "ColorTestImageJ.dcm" |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1204 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0018,1010' ]) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1205 tags = re.findall('\(0018,1010\).*MEDPC', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1206 self.assertEqual(1, len(tags)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1207 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1208 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1209 def test_incoming_findscu_3(self): |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1210 # This test fails if "LookupMode_DatabaseOnly" or |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1211 # "LookupMode_DiskOnAnswer" is used, as |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1212 # "SecondaryCaptureDeviceID" (0018,1010) is not a main DICOM |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1213 # tag, as thus a constraint cannot be applied to it |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1214 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1215 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1216 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0018,1010=MEDPC' ]) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1217 sequences = re.findall('\(0018,1010\)', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1218 self.assertEqual(1, len(sequences)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1219 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1220 |
13 | 1221 def test_incoming_movescu(self): |
1222 UploadInstance(_REMOTE, 'Multiframe.dcm') | |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1223 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1224 # No matching patient, so no job is created |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1225 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1226 CallMoveScu([ '--patient', '-k', '0008,0052=PATIENT', '-k', 'PatientID=none' ]) |
13 | 1227 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1228 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1229 # 1 Matching patient, track the job |
138 | 1230 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
1231 '--patient', | |
1232 '-k', '0008,0052=PATIENT', | |
1233 '-k', 'PatientID=12345678' | |
1234 ]))) | |
13 | 1235 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) |
1236 | |
1237 | |
1238 def test_findscu(self): | |
1239 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1240 j = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] | |
1241 k = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] | |
1242 DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1243 | |
1244 # Test the "find-patient" level | |
1245 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }) | |
1246 self.assertEqual(1, len(p)) | |
1247 self.assertEqual('ozp00SjY2xG', p[0]['PatientID']) | |
1248 | |
1249 # Test wildcards constraints. The "LO" value representation | |
1250 # for PatientID is always case-sensitive, but the "PN" for | |
1251 # PatientName might depend on the implementation: | |
1252 # "GenerateConfigurationForTests.py" will force it to be case | |
1253 # insensitive (which was the default until Orthanc 0.8.6). | |
1254 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'K*' }) | |
1255 self.assertEqual(1, len(p)) | |
1256 | |
1257 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'k*' }) | |
1258 self.assertEqual(1, len(p)) | |
1259 | |
1260 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : 'ozp*' }) | |
1261 self.assertEqual(1, len(p)) | |
1262 | |
1263 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : 'o?p*' }) | |
1264 self.assertEqual(1, len(p)) | |
1265 | |
1266 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : '0?q*' }) | |
1267 self.assertEqual(0, len(p)) | |
1268 | |
1269 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'B*' }) | |
1270 self.assertEqual(0, len(p)) | |
1271 | |
1272 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'b*' }) | |
1273 self.assertEqual(0, len(p)) | |
1274 | |
1275 DoPost(_REMOTE, '/modalities/orthanctest/store', str(j), 'text/plain') | |
1276 DoPost(_REMOTE, '/modalities/orthanctest/store', str(k), 'text/plain') | |
1277 DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }) | |
1278 self.assertEqual(3, len(DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }))) | |
1279 | |
1280 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'A*' }) | |
1281 self.assertEqual(2, len(p)) | |
1282 | |
1283 # Test the "find-study" level. This is the instance "ColorTestImageJ.dcm" | |
1284 s = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ' }) | |
1285 self.assertEqual(1, len(s)) | |
1286 self.assertEqual('20070208', s[0]['StudyDate']) | |
1287 | |
1288 # Test range searches | |
1289 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1290 'StudyDate' : '-20070101' }) | |
1291 self.assertEqual(0, len(t)) | |
1292 | |
1293 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1294 'StudyDate' : '20090101-' }) | |
1295 self.assertEqual(0, len(t)) | |
1296 | |
1297 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1298 'StudyDate' : '20070101-' }) | |
1299 self.assertEqual(1, len(t)) | |
1300 | |
1301 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1302 'StudyDate' : '-20090101' }) | |
1303 self.assertEqual(1, len(t)) | |
1304 | |
1305 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1306 'StudyDate' : '20070207-20070207' }) | |
1307 self.assertEqual(0, len(t)) | |
1308 | |
1309 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1310 'StudyDate' : '20070208-20070208' }) | |
1311 self.assertEqual(1, len(t)) | |
1312 | |
1313 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1314 'StudyDate' : '20070209-20070209' }) | |
1315 self.assertEqual(0, len(t)) | |
1316 | |
1317 # Test the ModalitiesInStudy tag | |
1318 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1319 'PatientID' : 'B9uTHKOZ', | |
1320 'ModalitiesInStudy' : 'US' }) | |
1321 self.assertEqual(0, len(t)) | |
1322 | |
1323 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1324 'PatientID' : 'B9uTHKOZ', | |
1325 'ModalitiesInStudy' : 'CT' }) | |
1326 self.assertEqual(1, len(t)) | |
1327 | |
1328 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1329 'PatientID' : 'B9uTHKOZ', | |
1330 'ModalitiesInStudy' : 'US\\CT' }) | |
1331 self.assertEqual(1, len(t)) | |
1332 | |
1333 # Test the "find-series" level | |
1334 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1335 'PatientID' : 'B9uTHKOZ', | |
1336 'StudyInstanceUID' : s[0]['StudyInstanceUID'] }) | |
1337 self.assertEqual(1, len(t)) | |
1338 | |
1339 # Test "\" separator | |
1340 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1341 'PatientID' : 'B9uTHKOZ', | |
1342 'StudyInstanceUID' : s[0]['StudyInstanceUID'], | |
1343 'Modality' : 'MR\\CT\\US' }) | |
1344 self.assertEqual(1, len(t)) | |
1345 | |
1346 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1347 'PatientID' : 'B9uTHKOZ', | |
1348 'StudyInstanceUID' : s[0]['StudyInstanceUID'], | |
1349 'Modality' : 'MR\\US' }) | |
1350 self.assertEqual(0, len(t)) | |
1351 | |
1352 | |
1353 def test_update_modalities(self): | |
1354 try: | |
1355 DoDelete(_REMOTE, '/modalities/toto') | |
1356 except: | |
1357 pass | |
1358 try: | |
1359 DoDelete(_REMOTE, '/modalities/tata') | |
1360 except: | |
1361 pass | |
1362 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/toto')) | |
1363 DoPut(_REMOTE, '/modalities/toto', [ "STORESCP", "localhost", 2000 ]) | |
116 | 1364 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'MedInria' ]) # check backward compatiblity with obsolete manufacturer |
1365 DoDelete(_REMOTE, '/modalities/tata') | |
124 | 1366 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'GenericNoUniversalWildcard' ]) |
121
1a19f953f53c
also test GenericNoWildcardInDates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
120
diff
changeset
|
1367 DoDelete(_REMOTE, '/modalities/tata') |
1a19f953f53c
also test GenericNoWildcardInDates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
120
diff
changeset
|
1368 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'GenericNoWildcardInDates' ]) |
128 | 1369 modalitiesReadback = DoGet(_REMOTE, '/modalities?expand') |
182
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1370 self.assertEqual('STORESCP', modalitiesReadback['tata']['AET']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1371 self.assertEqual('localhost', modalitiesReadback['tata']['Host']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1372 self.assertEqual(2000, modalitiesReadback['tata']['Port']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1373 self.assertEqual('GenericNoWildcardInDates', modalitiesReadback['tata']['Manufacturer']) |
116 | 1374 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/modalities/toto', [ "STORESCP", "localhost", 2000, 'InvalidManufacturerName' ])) |
13 | 1375 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/toto')) |
1376 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/tata')) | |
1377 DoDelete(_REMOTE, '/modalities/toto') | |
1378 DoDelete(_REMOTE, '/modalities/tata') | |
1379 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/toto')) | |
1380 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/tata')) | |
1381 | |
1382 | |
1383 def test_update_peers(self): | |
1384 # curl -X PUT http://localhost:8042/peers/toto -d '["http://localhost:8042/"]' -v | |
1385 try: | |
1386 DoDelete(_REMOTE, '/peers/toto') | |
1387 except: | |
1388 pass | |
1389 try: | |
1390 DoDelete(_REMOTE, '/peers/tata') | |
1391 except: | |
1392 pass | |
1393 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/toto')) | |
1394 DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/' ]) | |
1395 DoPut(_REMOTE, '/peers/tata', [ 'http://localhost:8042/', 'user', 'pass' ]) | |
128 | 1396 self.assertTrue('tata' in DoGet(_REMOTE, '/peers')) |
1397 peersReadback = DoGet(_REMOTE, '/peers?expand') | |
1398 self.assertEqual('http://localhost:8042/', peersReadback['tata']['Url']) | |
1399 self.assertEqual('user', peersReadback['tata']['Username']) | |
1400 self.assertFalse('Password' in peersReadback['tata']) # make sure no sensitive data is included | |
1401 self.assertFalse('CertificateFile' in peersReadback['tata']) # make sure no sensitive data is included | |
1402 self.assertFalse('CertificateKeyFile' in peersReadback['tata']) # make sure no sensitive data is included | |
1403 self.assertFalse('CertificateKeyPassword' in peersReadback['tata']) # make sure no sensitive data is included | |
1404 self.assertFalse('Pkcs11' in peersReadback['tata']) # make sure no sensitive data is included | |
13 | 1405 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/', 'a' ])) |
1406 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/', 'a', 'b', 'c' ])) | |
1407 self.assertTrue('store' in DoGet(_REMOTE, '/peers/toto')) | |
1408 self.assertTrue('store' in DoGet(_REMOTE, '/peers/tata')) | |
1409 DoDelete(_REMOTE, '/peers/toto') | |
1410 DoDelete(_REMOTE, '/peers/tata') | |
1411 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/toto')) | |
1412 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/tata')) | |
1413 | |
1414 | |
1415 def test_mesterhazy_modification(self): | |
1416 # When I modify a series ( eg. curl | |
1417 # http://localhost:8042/series/uidhere/modify -X POST -d | |
1418 # '{"Replace":{"SeriesDate":"19990101"}}' ) the modified | |
1419 # series is added to a new Study, instead of the existing | |
1420 # Study. Fixed in Orthanc 0.7.5 | |
1421 | |
1422 u = UploadInstance(_REMOTE, 'DummyCT.dcm') | |
1423 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' | |
1424 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
1425 | |
1426 modified = DoPost(_REMOTE, '/series/%s/modify' % series, | |
1427 json.dumps({ "Replace" : { "SeriesDate" : "19990101" }})) | |
1428 | |
1429 self.assertEqual(study, DoGet(_REMOTE, '/series/%s' % modified['ID']) ['ParentStudy']) | |
1430 | |
1431 | |
1432 def test_create(self): | |
1433 i = DoPost(_REMOTE, '/tools/create-dicom', | |
1434 json.dumps({ | |
1435 'PatientName' : 'Jodogne', | |
1436 'Modality' : 'CT', | |
58 | 1437 'SOPClassUID' : '1.2.840.10008.5.1.4.1.1.1', |
13 | 1438 'PixelData' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==' # red dot in RGBA |
1439 })) | |
1440 | |
1441 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
1442 self.assertEqual('CT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i['ID']).strip()) | |
1443 | |
1444 png = GetImage(_REMOTE, '/instances/%s/preview' % i['ID']) | |
1445 self.assertEqual((5, 5), png.size) | |
1446 | |
38 | 1447 j = DoGet(_REMOTE, i['Path']) |
1448 self.assertEqual('Instance', j['Type']) | |
1449 self.assertEqual(j['ID'], i['ID']) | |
1450 | |
13 | 1451 |
1452 def test_pilates(self): | |
1453 # "SCU failed error when accessing orthanc with osirix" by | |
1454 # Pilates Agentur (Mar 10, 2014 at 9:33 PM) | |
1455 i = UploadInstance(_REMOTE, 'PilatesArgenturGEUltrasoundOsiriX.dcm')['ID'] | |
1456 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
1457 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1458 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
1459 | |
1460 | |
1461 def test_shared_tags(self): | |
1462 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1463 b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm')['ID'] | |
1464 p = DoGet(_REMOTE, '/patients')[0] | |
1465 | |
1466 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1467 self.assertTrue('PatientName' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1468 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/shared-tags?short' % p)) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1469 |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1470 self.assertEqual('KNEE', DoGet(_REMOTE, '/patients/%s/shared-tags' % p)['0010,0010']['Value']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1471 self.assertEqual('KNEE', DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)['PatientName']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1472 self.assertEqual('KNEE', DoGet(_REMOTE, '/patients/%s/shared-tags?short' % p)['0010,0010']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1473 |
13 | 1474 self.assertTrue('0008,1030' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) |
1475 self.assertTrue('StudyDescription' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1476 self.assertTrue('0008,103e' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1477 self.assertTrue('SeriesDescription' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1478 self.assertFalse('0008,0018' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1479 self.assertFalse('SOPInstanceUID' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1480 | |
1481 self.assertTrue('0008,0018' in DoGet(_REMOTE, '/instances/%s/tags' % a)) | |
1482 self.assertTrue('SOPInstanceUID' in DoGet(_REMOTE, '/instances/%s/tags?simplify' % a)) | |
1483 | |
1484 | |
1485 def test_modules(self): | |
1486 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1487 p = DoGet(_REMOTE, '/patients')[0] | |
1488 s = DoGet(_REMOTE, '/studies')[0] | |
1489 t = DoGet(_REMOTE, '/series')[0] | |
1490 | |
1491 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/module' % p)) | |
1492 self.assertTrue('PatientName' in DoGet(_REMOTE, '/patients/%s/module?simplify' % p)) | |
1493 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/studies/%s/module-patient' % p)) | |
1494 self.assertTrue('PatientName' in DoGet(_REMOTE, '/studies/%s/module-patient?simplify' % p)) | |
1495 self.assertTrue('0008,1030' in DoGet(_REMOTE, '/studies/%s/module' % s)) | |
1496 self.assertTrue('StudyDescription' in DoGet(_REMOTE, '/studies/%s/module?simplify' % s)) | |
1497 self.assertTrue('0008,103e' in DoGet(_REMOTE, '/series/%s/module' % p)) | |
1498 self.assertTrue('SeriesDescription' in DoGet(_REMOTE, '/series/%s/module?simplify' % p)) | |
1499 self.assertTrue('0008,0018' in DoGet(_REMOTE, '/instances/%s/module' % a)) | |
1500 self.assertTrue('SOPInstanceUID' in DoGet(_REMOTE, '/instances/%s/module?simplify' % a)) | |
1501 | |
1502 | |
1503 def test_auto_directory(self): | |
1504 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1505 self.assertTrue('now' in DoGet(_REMOTE, '/tools')) | |
1506 self.assertTrue('dicom-conformance' in DoGet(_REMOTE, '/tools')) | |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
1507 self.assertTrue('invalidate-tags' in DoGet(_REMOTE, '/tools')) |
13 | 1508 self.assertTrue(len(DoGet(_REMOTE, '/tools/dicom-conformance')) > 1000) |
1509 self.assertTrue('orthanctest' in DoGet(_REMOTE, '/modalities')) | |
1510 self.assertTrue('echo' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1511 self.assertTrue('find' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1512 self.assertTrue('find-instance' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1513 self.assertTrue('find-patient' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1514 self.assertTrue('find-series' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1515 self.assertTrue('find-study' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1516 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1517 self.assertTrue('store' in DoGet(_REMOTE, '/peers/peer')) | |
1518 self.assertTrue('matlab' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) | |
79 | 1519 self.assertTrue('raw' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) |
13 | 1520 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/tools/nope')) |
28 | 1521 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope')) |
1522 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope/nope.html')) | |
1523 self.assertEqual(404, DoGetRaw(_REMOTE, '/nope')[0].status) | |
1524 self.assertEqual(404, DoGetRaw(_REMOTE, '/nope/nope.html')[0].status) | |
13 | 1525 |
1526 | |
1527 def test_echo(self): | |
1528 DoPost(_REMOTE, '/modalities/orthanctest/echo') | |
1529 | |
1530 | |
1531 def test_xml(self): | |
1532 json = DoGet(_REMOTE, '/tools', headers = { 'accept' : 'application/json' }) | |
1533 xml = minidom.parseString(DoGet(_REMOTE, '/tools', headers = { 'accept' : 'application/xml' })) | |
1534 items = xml.getElementsByTagName('root')[0].getElementsByTagName('item') | |
1535 self.assertEqual(len(items), len(json)) | |
1536 | |
1537 self.assertTrue('dicom-conformance' in json) | |
1538 | |
1539 ok = False | |
1540 for i in items: | |
1541 if i.childNodes[0].data == 'dicom-conformance': | |
1542 ok = True | |
1543 self.assertTrue(ok) | |
1544 | |
1545 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1546 def test_googlecode_issue_16(self): |
13 | 1547 i = UploadInstance(_REMOTE, 'Issue16.dcm')['ID'] |
1548 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i)['FrameIncrementPointer'] | |
1549 self.assertEqual('0018,1063', t) | |
1550 | |
1551 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1552 def test_googlecode_issue_22(self): |
13 | 1553 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] |
1554 a = [ | |
1555 "f804691f62197040438f4627c6b994f1", # Frame 0 | |
1556 "c69eee9a51eea3e8611e82e578897254", | |
1557 "315666be83e2d0111c77bc0996d84901", | |
1558 "3e27aa959d911172c48a1436443c72b1", | |
1559 "958642c9e7e9d232d3869faff546058c", | |
1560 "5e7ea8e3e4230cae707d143481355c59", | |
1561 "eda37f83558d858a596175aed8b2ad47", | |
1562 "486713bd2895c4ecbe0e97715ac7f80a", | |
1563 "091ef729eb169e67da8a0faa9631f9a8", | |
1564 "5aa2b8c7ffe0a483efaa8e12417686ca", | |
1565 "e2f39e85896fe58876654b94cd0b5013", | |
1566 "6fd2129e4950abbe1be053bc814d5da8", | |
1567 "c3331a8ba7a757f3d423735ab7fa81f9", | |
1568 "746f808582156734dd6b6fdfd3a0b72c", | |
1569 "8075ea2b227a70c60ea6b7b75a6bb190", | |
1570 "806b8b3e300c615099c11a5ec23465aa", | |
1571 "7c836aa298ba6eef96434579af631a11", | |
1572 "a0357dc9f4f72d73a885c33d7c287446", | |
1573 "f25ba3be1cc7d7fad95706adc199ea7d", | |
1574 "8b114c526b8cbed6cad8a3248b7b480c", | |
1575 "44e6670f127e612a2b4aa60a0d207698", | |
1576 "b8945f90fe02facf2ace24ca1ecbe0a5", | |
1577 "95c796c2fa8f59018b15cf2987b1f79b", | |
1578 "ce0a51ab30224205b44920221dc27351", # Frame 23 | |
1579 ] | |
1580 | |
1581 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
1582 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/24/preview' % s)) | |
1583 | |
1584 for i in range(len(a)): | |
1585 self.assertEqual(a[i], ComputeMD5(DoGet(_REMOTE, '/instances/%s/frames/%d/preview' % (s, i)))) | |
1586 | |
1587 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1588 def test_googlecode_issue_19(self): |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1589 # This is an image with "YBR_FULL" photometric interpretation, it is not supported by Orthanc |
13 | 1590 # gdcmconv -i /home/jodogne/DICOM/GdcmDatabase/US_DataSet/HDI5000_US/3EAF5E01 -w -o Issue19.dcm |
1591 | |
1592 a = UploadInstance(_REMOTE, 'Issue19.dcm')['ID'] | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1593 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/941ad3c8-05d05b88-560459f9-0eae0e20-6cddd533/preview')) |
13 | 1594 |
1595 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1596 def test_googlecode_issue_37(self): |
13 | 1597 # Same test for issues 35 and 37. Fixed in Orthanc 0.9.1 |
1598 u = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] | |
1599 | |
1600 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
1601 'CaseSensitive' : True, | |
1602 'Query' : { 'StationName' : 'SMR4-MP3' }}) | |
1603 self.assertEqual(1, len(a)) | |
14 | 1604 |
1605 | |
1606 def test_rest_find(self): | |
1607 # Upload 8 instances | |
1608 for i in range(2): | |
1609 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1610 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1611 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1612 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1613 | |
1614 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1615 'CaseSensitive' : False, | |
194
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1616 'Query' : { 'PatientName' : 'BRAINIX' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1617 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1618 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1619 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1620 'CaseSensitive' : False, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1621 'Query' : { 'PatientName' : 'BRAINIX\\KNEE\\NOPE' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1622 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1623 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1624 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1625 'CaseSensitive' : False, |
14 | 1626 'Query' : { 'PatientName' : '*n*' }}) |
1627 self.assertEqual(2, len(a)) | |
1628 | |
1629 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1630 'CaseSensitive' : True, | |
1631 'Query' : { 'PatientName' : '*n*' }}) | |
1632 self.assertEqual(0, len(a)) | |
1633 | |
1634 a = DoPost(_REMOTE, '/tools/find', { 'Expand' : True, | |
1635 'Level' : 'Patient', | |
1636 'CaseSensitive' : False, | |
1637 'Query' : { 'PatientName' : '*ne*' }}) | |
1638 self.assertEqual(1, len(a)) | |
1639 self.assertEqual('20080822', a[0]['MainDicomTags']['PatientBirthDate']) | |
1640 | |
1641 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1642 'CaseSensitive' : True, | |
1643 'Query' : { 'PatientName' : '*ne*' }}) | |
1644 self.assertEqual(0, len(a)) | |
1645 | |
1646 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', | |
1647 'CaseSensitive' : True, | |
1648 'Query' : { 'PatientName' : '*NE*' }}) | |
1649 self.assertEqual(1, len(a)) | |
1650 | |
1651 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
1652 'CaseSensitive' : True, | |
1653 'Query' : { 'PatientName' : '*NE*' }}) | |
1654 self.assertEqual(2, len(a)) | |
1655 | |
1656 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', | |
1657 'CaseSensitive' : True, | |
1658 'Query' : { 'PatientName' : '*NE*' }}) | |
1659 self.assertEqual(4, len(a)) | |
1660 | |
1661 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', 'Query' : { }}) | |
1662 self.assertEqual(2, len(a)) | |
1663 | |
1664 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', 'Query' : { }}) | |
1665 self.assertEqual(2, len(a)) | |
1666 | |
1667 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', 'Query' : { }}) | |
1668 self.assertEqual(4, len(a)) | |
1669 | |
1670 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', 'Query' : { }}) | |
1671 self.assertEqual(8, len(a)) | |
1672 | |
194
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1673 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1674 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1675 'Query' : { 'StudyDate' : '20061201-20061201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1676 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1677 self.assertEqual('BRAINIX', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1678 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1679 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1680 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1681 'Query' : { 'StudyDate' : '20061201-20091201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1682 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1683 for i in range(2): |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1684 self.assertTrue(a[i]['PatientMainDicomTags']['PatientName'] in ['BRAINIX', 'KNEE']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1685 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1686 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1687 'Query' : { 'StudyDate' : '20061202-20061202' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1688 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1689 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1690 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1691 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1692 'Query' : { 'StudyDate' : '-20061201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1693 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1694 self.assertEqual('BRAINIX', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1695 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1696 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1697 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1698 'Query' : { 'StudyDate' : '-20051201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1699 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1700 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1701 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1702 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1703 'Query' : { 'StudyDate' : '20061201-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1704 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1705 for i in range(2): |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1706 self.assertTrue(a[i]['PatientMainDicomTags']['PatientName'] in ['BRAINIX', 'KNEE']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1707 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1708 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1709 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1710 'Query' : { 'StudyDate' : '20061202-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1711 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1712 self.assertEqual('KNEE', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1713 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1714 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1715 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1716 'Query' : { 'StudyDate' : '20080819-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1717 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1718 self.assertEqual('KNEE', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1719 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1720 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1721 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1722 'Query' : { 'StudyDate' : '20080820-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1723 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1724 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1725 |
14 | 1726 |
1727 def test_rest_query_retrieve(self): | |
1728 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1729 | |
1730 # Upload 8 instances | |
1731 for i in range(2): | |
1732 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1733 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1734 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1735 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1736 | |
1737 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
1738 for p in DoGet(_REMOTE, '/patients'): | |
1739 DoPost(_REMOTE, '/modalities/orthanctest/store', p) | |
1740 DoDelete(_REMOTE, '/patients/%s' % p) | |
1741 | |
1742 for q in DoGet(_REMOTE, '/queries'): | |
1743 DoDelete(_REMOTE, '/queries/%s' % q) | |
1744 | |
1745 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1746 self.assertEqual(0, len(DoGet(_REMOTE, '/queries'))) | |
1747 a = DoPost(_REMOTE, '/modalities/orthanctest/query', { 'Level' : 'Series', | |
27 | 1748 'Query' : { |
1749 'PatientName' : '*NE*', | |
1750 'StudyDate' : '*', | |
1751 }})['ID'] | |
14 | 1752 self.assertEqual(1, len(DoGet(_REMOTE, '/queries'))) |
1753 | |
1754 b = DoGet(_REMOTE, '/queries/%s' % a) | |
1755 self.assertTrue('answers' in b) | |
1756 self.assertTrue('level' in b) | |
1757 self.assertTrue('modality' in b) | |
1758 self.assertTrue('query' in b) | |
1759 self.assertTrue('retrieve' in b) | |
1760 self.assertEqual('Series', DoGet(_REMOTE, '/queries/%s/level' % a)) | |
1761 self.assertEqual('orthanctest', DoGet(_REMOTE, '/queries/%s/modality' % a)) | |
1762 | |
1763 q = DoGet(_REMOTE, '/queries/%s/query?simplify' % a) | |
27 | 1764 self.assertEqual(2, len(q)) |
14 | 1765 self.assertTrue('PatientName' in q) |
27 | 1766 self.assertTrue('StudyDate' in q) |
14 | 1767 self.assertEqual('*NE*', q['PatientName']) |
27 | 1768 self.assertEqual('*', q['StudyDate']) |
14 | 1769 |
1770 self.assertEqual(2, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) | |
1771 | |
1772 s = DoGet(_REMOTE, '/queries/%s/answers/0' % a) | |
1773 self.assertTrue('content' in s) | |
1774 self.assertTrue('retrieve' in s) | |
1775 | |
1776 s = DoGet(_REMOTE, '/queries/%s/answers/0/content?simplify' % a) | |
1777 self.assertEqual('887', s['PatientID']) | |
1778 self.assertEqual('2.16.840.1.113669.632.20.121711.10000160881', s['StudyInstanceUID']) | |
1779 | |
1780 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1781 DoPost(_REMOTE, '/queries/%s/answers/0/retrieve' % a, 'ORTHANC') | |
1782 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1783 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
1784 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
1785 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) | |
1786 | |
112 | 1787 DoPost(_REMOTE, '/queries/%s/answers/1/retrieve' % a, 'ORTHANC', 'application/json') # make sure the issue #36 is fixed (query/retrieve Rest API: /retrieve route shall accept application/json content type) |
14 | 1788 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) |
1789 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
1790 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
1791 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
1792 | |
186
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1793 # New in Orthanc 1.4.3 |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1794 s = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % a) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1795 self.assertEqual(2, len(s)) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1796 for i in range(2): |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1797 self.assertEqual('SERIES', s[i]['QueryRetrieveLevel']) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1798 self.assertEqual('887', s[i]['PatientID']) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1799 self.assertEqual('2.16.840.1.113669.632.20.121711.10000160881', s[i]['StudyInstanceUID']) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1800 |
14 | 1801 DoDelete(_REMOTE, '/queries/%s' % a) |
1802 self.assertEqual(0, len(DoGet(_REMOTE, '/queries'))) | |
1803 | |
1804 | |
1805 def test_parent(self): | |
1806 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1807 patient = '6816cb19-844d5aee-85245eba-28e841e6-2414fae2' | |
1808 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' | |
1809 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
1810 instance = '66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d' | |
107
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
1811 self.assertEqual(instance, u) |
14 | 1812 |
1813 a = DoGet(_REMOTE, '/studies/%s/patient' % study) | |
1814 self.assertEqual('Patient', a['Type']) | |
1815 self.assertEqual(patient, a['ID']) | |
1816 | |
1817 a = DoGet(_REMOTE, '/series/%s/patient' % series) | |
1818 self.assertEqual('Patient', a['Type']) | |
1819 self.assertEqual(patient, a['ID']) | |
1820 | |
1821 a = DoGet(_REMOTE, '/series/%s/study' % series) | |
1822 self.assertEqual('Study', a['Type']) | |
1823 self.assertEqual(study, a['ID']) | |
1824 | |
1825 a = DoGet(_REMOTE, '/instances/%s/patient' % instance) | |
1826 self.assertEqual('Patient', a['Type']) | |
1827 self.assertEqual(patient, a['ID']) | |
1828 | |
1829 a = DoGet(_REMOTE, '/instances/%s/study' % instance) | |
1830 self.assertEqual('Study', a['Type']) | |
1831 self.assertEqual(study, a['ID']) | |
1832 | |
1833 a = DoGet(_REMOTE, '/instances/%s/series' % instance) | |
1834 self.assertEqual('Series', a['Type']) | |
1835 self.assertEqual(series, a['ID']) | |
1836 | |
1837 | |
1838 def test_shanon(self): | |
1839 def Anonymize(instance, replacements = {}): | |
119 | 1840 return DoPost(_REMOTE, '/instances/%s/anonymize' % instance, { |
1841 'Replace' : replacements, | |
1842 'Force' : True, | |
1843 }, 'application/json') | |
14 | 1844 |
1845 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
1846 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1847 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1848 | |
1849 tags = [ 'PatientID', 'StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID', 'DeidentificationMethod' ] | |
1850 ids = [ 'ozp00SjY2xG', | |
1851 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
1852 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
1853 '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' ] | |
1854 | |
1855 a = ExtractDicomTags(Anonymize(u), tags) | |
1856 for i in range(4): | |
1857 self.assertNotEqual(ids[i], a[i]) | |
1858 self.assertTrue(a[4].startswith('Orthanc')) | |
1859 | |
1860 a = ExtractDicomTags(Anonymize(u, { 'PatientName' : 'toto' }), tags) | |
1861 for i in range(4): | |
1862 self.assertNotEqual(ids[i], a[i]) | |
1863 self.assertFalse(a[4].startswith('Orthanc')) | |
1864 | |
1865 a = ExtractDicomTags(Anonymize(u, { 'SOPInstanceUID' : 'instance' }), tags) | |
1866 self.assertEqual('instance', a[3]) | |
1867 self.assertFalse(a[4].startswith('Orthanc')) | |
1868 | |
1869 a = ExtractDicomTags(Anonymize(u, { 'SeriesInstanceUID' : 'series' }), tags) | |
1870 self.assertEqual('series', a[2]) | |
1871 self.assertFalse(a[4].startswith('Orthanc')) | |
1872 | |
1873 a = ExtractDicomTags(Anonymize(u, { 'StudyInstanceUID' : 'study' }), tags) | |
1874 self.assertEqual('study', a[1]) | |
1875 self.assertFalse(a[4].startswith('Orthanc')) | |
1876 | |
1877 a = ExtractDicomTags(Anonymize(u, { 'PatientID' : 'patient' }), tags) | |
1878 self.assertEqual('patient', a[0]) | |
1879 self.assertFalse(a[4].startswith('Orthanc')) | |
1880 | |
1881 a = ExtractDicomTags(Anonymize(u, { 'PatientID' : 'patient', | |
1882 'StudyInstanceUID' : 'study', | |
1883 'SeriesInstanceUID' : 'series', | |
1884 'SOPInstanceUID' : 'instance' }), tags) | |
1885 self.assertEqual('patient', a[0]) | |
1886 self.assertFalse(a[4].startswith('Orthanc')) | |
1887 | |
1888 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1889 | |
1890 | |
1891 def test_shanon_2(self): | |
1892 def Modify(instance, replacements = {}): | |
119 | 1893 return DoPost(_REMOTE, '/instances/%s/modify' % instance, { |
1894 'Replace' : replacements, | |
1895 'Force': True, | |
1896 }, 'application/json') | |
14 | 1897 |
1898 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
1899 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1900 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1901 | |
1902 tags = [ 'PatientID', 'StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID', 'DeidentificationMethod' ] | |
1903 ids = [ 'ozp00SjY2xG', | |
1904 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
1905 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
1906 '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' ] | |
1907 | |
1908 a = ExtractDicomTags(Modify(u), tags) | |
1909 self.assertEqual(ids[0], a[0]) | |
1910 self.assertEqual(ids[1], a[1]) | |
1911 self.assertEqual(ids[2], a[2]) | |
1912 self.assertNotEqual(ids[3], a[3]) | |
1913 self.assertEqual(0, len(a[4])) | |
1914 | |
1915 a = ExtractDicomTags(Modify(u, { 'SOPInstanceUID' : 'instance' }), tags) | |
1916 self.assertEqual(ids[0], a[0]) | |
1917 self.assertEqual(ids[1], a[1]) | |
1918 self.assertEqual(ids[2], a[2]) | |
1919 self.assertEqual('instance', a[3]) | |
1920 | |
1921 a = ExtractDicomTags(Modify(u, { 'SeriesInstanceUID' : 'series' }), tags) | |
1922 self.assertEqual(ids[0], a[0]) | |
1923 self.assertEqual(ids[1], a[1]) | |
1924 self.assertEqual('series', a[2]) | |
1925 self.assertNotEqual(ids[3], a[3]) | |
1926 | |
1927 a = ExtractDicomTags(Modify(u, { 'StudyInstanceUID' : 'study' }), tags) | |
1928 self.assertEqual(ids[0], a[0]) | |
1929 self.assertEqual('study', a[1]) | |
1930 self.assertNotEqual(ids[2], a[2]) | |
1931 self.assertNotEqual(ids[3], a[3]) | |
1932 | |
1933 a = ExtractDicomTags(Modify(u, { 'PatientID' : 'patient' }), tags) | |
1934 self.assertEqual('patient', a[0]) | |
1935 self.assertNotEqual(ids[1], a[1]) | |
1936 self.assertNotEqual(ids[2], a[2]) | |
1937 self.assertNotEqual(ids[3], a[3]) | |
1938 | |
1939 a = ExtractDicomTags(Modify(u, { 'PatientID' : 'patient', | |
1940 'StudyInstanceUID' : 'study', | |
1941 'SeriesInstanceUID' : 'series', | |
1942 'SOPInstanceUID' : 'instance' }), tags) | |
1943 self.assertEqual('patient', a[0]) | |
1944 self.assertEqual('study', a[1]) | |
1945 self.assertEqual('series', a[2]) | |
1946 self.assertEqual('instance', a[3]) | |
1947 | |
1948 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1949 | |
1950 | |
1951 def test_instances_tags(self): | |
1952 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1953 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm')['ID'] | |
1954 #a = UploadInstance(_REMOTE, 'Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386937.676343')['ID'] | |
1955 #b = UploadInstance(_REMOTE, 'Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386925.676329')['ID'] | |
1956 | |
1957 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/patients')[0]) | |
1958 self.assertEqual(2, len(i)) | |
1959 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1960 self.assertEqual('887', i[i.keys()[1]]['PatientID']) | |
1961 | |
1962 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/studies')[0]) | |
1963 self.assertEqual(2, len(i)) | |
1964 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1965 self.assertEqual('887', i[i.keys()[1]]['PatientID']) | |
1966 | |
1967 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
1968 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/series')[0]) | |
1969 self.assertEqual(1, len(i)) | |
1970 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1971 | |
1972 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/series')[1]) | |
1973 self.assertEqual(1, len(i)) | |
1974 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1975 | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1976 i = DoGet(_REMOTE, '/patients/%s/instances-tags?short' % DoGet(_REMOTE, '/series')[1]) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1977 self.assertEqual(1, len(i)) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1978 self.assertEqual('887', i[i.keys()[0]]['0010,0020']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1979 |
14 | 1980 |
1981 def test_lookup(self): | |
1982 a = DoPost(_REMOTE, '/tools/lookup', 'ozp00SjY2xG') | |
1983 self.assertEqual(0, len(a)) | |
1984 | |
1985 UploadInstance(_REMOTE, 'DummyCT.dcm') | |
1986 | |
1987 a = DoPost(_REMOTE, '/tools/lookup', 'ozp00SjY2xG') | |
1988 self.assertEqual(1, len(a)) | |
1989 self.assertEqual('Patient', a[0]['Type']) | |
1990 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', a[0]['ID']) | |
1991 self.assertEqual('/patients/%s' % a[0]['ID'], a[0]['Path']) | |
1992 | |
1993 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390') | |
1994 self.assertEqual(1, len(a)) | |
1995 self.assertEqual('Study', a[0]['Type']) | |
1996 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', a[0]['ID']) | |
1997 self.assertEqual('/studies/%s' % a[0]['ID'], a[0]['Path']) | |
1998 | |
1999 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394') | |
2000 self.assertEqual(1, len(a)) | |
2001 self.assertEqual('Series', a[0]['Type']) | |
2002 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', a[0]['ID']) | |
2003 self.assertEqual('/series/%s' % a[0]['ID'], a[0]['Path']) | |
2004 | |
2005 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109') | |
2006 self.assertEqual(1, len(a)) | |
2007 self.assertEqual('Instance', a[0]['Type']) | |
2008 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', a[0]['ID']) | |
2009 self.assertEqual('/instances/%s' % a[0]['ID'], a[0]['Path']) | |
2010 | |
2011 DropOrthanc(_REMOTE) | |
2012 a = DoPost(_REMOTE, '/tools/lookup', '3113719P') | |
2013 self.assertEqual(0, len(a)) | |
2014 | |
15 | 2015 |
2016 def test_autorouting(self): | |
2017 knee1 = 'Knee/T1/IM-0001-0001.dcm' | |
2018 knee2 = 'Knee/T2/IM-0001-0002.dcm' | |
2019 other = 'Brainix/Flair/IM-0001-0001.dcm' | |
2020 | |
2021 # Check that this version is >= 0.8.0 | |
2022 self.assertTrue(IsDefinedInLua(_REMOTE, '_InitializeJob')) | |
2023 self.assertTrue('orthanctest' in DoGet(_REMOTE, '/modalities')) | |
2024 | |
2025 UploadInstance(_REMOTE, knee1) | |
2026 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
2027 | |
2028 DropOrthanc(_REMOTE) | |
2029 DropOrthanc(_LOCAL) | |
174 | 2030 InstallLuaScriptFromPath(_REMOTE, 'Lua/Autorouting.lua') |
15 | 2031 UploadInstance(_REMOTE, knee1) |
2032 UploadInstance(_REMOTE, knee2) | |
2033 UploadInstance(_REMOTE, other) | |
2034 WaitEmpty(_REMOTE) | |
174 | 2035 UninstallLuaCallbacks(_REMOTE) |
15 | 2036 self.assertEqual(3, len(DoGet(_LOCAL, '/instances'))) |
2037 | |
2038 DropOrthanc(_REMOTE) | |
2039 DropOrthanc(_LOCAL) | |
174 | 2040 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingConditional.lua') |
15 | 2041 UploadInstance(_REMOTE, knee1) |
2042 UploadInstance(_REMOTE, knee2) | |
2043 UploadInstance(_REMOTE, other) | |
2044 WaitEmpty(_REMOTE) | |
174 | 2045 UninstallLuaCallbacks(_REMOTE) |
15 | 2046 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
2047 | |
2048 DropOrthanc(_REMOTE) | |
2049 DropOrthanc(_LOCAL) | |
174 | 2050 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingModification.lua') |
15 | 2051 UploadInstance(_REMOTE, knee1) |
2052 WaitEmpty(_REMOTE) | |
174 | 2053 UninstallLuaCallbacks(_REMOTE) |
15 | 2054 i = DoGet(_LOCAL, '/instances') |
2055 self.assertEqual(1, len(i)) | |
2056 | |
2057 with tempfile.NamedTemporaryFile(delete = True) as f: | |
2058 f.write(DoGet(_LOCAL, '/instances/%s/file' % i[0])) | |
2059 f.flush() | |
45 | 2060 routed = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) |
15 | 2061 self.assertEqual('My Medical Device', re.search('"StationName">(.*?)<', routed).group(1).strip()) |
2062 self.assertEqual(None, re.search('"MilitaryRank"', routed)) | |
2063 self.assertEqual(None, re.search('"0051,0010"', routed)) # A private tag | |
17 | 2064 |
2065 | |
2066 def test_storescu_rf(self): | |
2067 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] | |
2068 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
2069 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
2070 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
18 | 2071 |
2072 | |
2073 def test_anonymize_instance(self): | |
2074 def AnonymizeAndUpload(instanceId, parameters): | |
2075 return DoPost(_REMOTE, '/instances', DoPost(_REMOTE, '/instances/%s/anonymize' % instanceId, parameters, | |
2076 'application/json'), 'application/dicom')['ID'] | |
2077 | |
2078 def ModifyAndUpload(instanceId, parameters): | |
2079 return DoPost(_REMOTE, '/instances', DoPost(_REMOTE, '/instances/%s/modify' % instanceId, parameters, | |
2080 'application/json'), 'application/dicom')['ID'] | |
2081 | |
2082 a = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
2083 s1 = DoGet(_REMOTE, '/instances/%s/content/PatientName' % a) | |
2084 s2 = DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % a) # Some private tag | |
2085 s3 = DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % a) | |
2086 s4 = DoGet(_REMOTE, '/instances/%s/content/SeriesDescription' % a) | |
2087 s5 = DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % a) | |
2088 | |
2089 b = AnonymizeAndUpload(a, '{}') | |
2090 self.assertNotEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2091 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2092 | |
2093 # Keep private tag (only OK since Orthanc 0.8.0) | |
2094 b = AnonymizeAndUpload(a, '{"Keep":["00e1-10c2"]}') | |
2095 self.assertNotEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2096 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2097 | |
2098 b = AnonymizeAndUpload(a, '{"Keep":["00e1,10c2","PatientName"]}') | |
2099 self.assertEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2100 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2101 | |
2102 b = AnonymizeAndUpload(a, '{"Keep":["PatientName"],"Replace":{"00e1,10c2":"Hello"}}') | |
2103 self.assertEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2104 self.assertTrue(DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b).startswith('Hello')) | |
2105 | |
2106 # Examples from the Wiki | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2107 b = AnonymizeAndUpload(a, '{"Replace":{"PatientName":"hello","0010-0020":"world"},"Keep":["StudyDescription", "SeriesDescription"],"KeepPrivateTags": true,"Force":true}') |
18 | 2108 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2109 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2110 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2111 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008,103e' % b)) | |
2112 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008-103E' % b)) | |
2113 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2114 DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % a) | |
2115 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2116 | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2117 b = ModifyAndUpload(a, '{"Replace":{"PatientName":"hello","PatientID":"world"},"Remove":["InstitutionName"],"RemovePrivateTags": true,"Force":true}') |
18 | 2118 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2119 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2120 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2121 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008,103e' % b)) | |
2122 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2123 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2124 | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2125 b = ModifyAndUpload(a, '{"Replace":{"PatientName":"hello","PatientID":"world"},"Force":true}') |
18 | 2126 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2127 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2128 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1,10c2' % b)) | |
2129 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2130 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008-103E' % b)) | |
2131 self.assertEqual(s5, DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2132 | |
2133 | |
2134 # Test modify non-existing | |
2135 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2136 json.dumps({ | |
2137 'PatientName' : 'Jodogne', | |
2138 'Modality' : 'CT', | |
2139 }))['ID'] | |
2140 | |
2141 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i).strip()) | |
2142 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % i)) | |
2143 self.assertEqual('CT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i).strip()) | |
2144 | |
2145 b = ModifyAndUpload(i, '{"Replace":{"StudyDescription":"hello","Modality":"world"}}') | |
2146 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % b).strip()) | |
2147 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % b).strip()) | |
2148 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/Modality' % b).strip()) | |
2149 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2150 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2151 def test_incoming_jpeg(self): |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2152 def storescu(image, acceptUnknownSopClassUid): |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2153 if acceptUnknownSopClassUid: |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2154 tmp = [ '-xf', GetDatabasePath('UnknownSopClassUid.cfg'), 'Default' ] |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2155 else: |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2156 tmp = [ '-xs' ] |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2157 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2158 with open(os.devnull, 'w') as FNULL: |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2159 subprocess.check_call([ FindExecutable('storescu') ] + tmp + |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2160 [ _REMOTE['Server'], str(_REMOTE['DicomPort']), |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2161 GetDatabasePath(image) ], |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2162 stderr = FNULL) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2163 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2164 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
174 | 2165 InstallLuaScriptFromPath(_REMOTE, 'Lua/TransferSyntaxDisable.lua') |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2166 self.assertRaises(Exception, lambda: storescu('Knix/Loc/IM-0001-0001.dcm', False)) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2167 self.assertRaises(Exception, lambda: storescu('UnknownSopClassUid.dcm', True)) |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2168 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
174 | 2169 InstallLuaScriptFromPath(_REMOTE, 'Lua/TransferSyntaxEnable.lua') |
62
f9c4ce95756f
removal of useless information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
61
diff
changeset
|
2170 DoPost(_REMOTE, '/tools/execute-script', "print('All special transfer syntaxes are now accepted')") |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2171 storescu('Knix/Loc/IM-0001-0001.dcm', False) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2172 storescu('UnknownSopClassUid.dcm', True) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2173 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2174 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2175 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2176 def test_storescu_jpeg(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2177 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2178 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2179 knixStudy = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' |
64 | 2180 i = UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm')['ID'] |
2181 | |
2182 # This is JPEG lossless | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2183 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header' % i)['0002,0010']['Value']) |
64 | 2184 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header?simplify' % i)['TransferSyntaxUID']) |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2185 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header?short' % i)['0002,0010']) |
64 | 2186 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2187 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0002.dcm') |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2188 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0003.dcm') |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2189 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2190 a = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2191 b = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2192 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2193 DoPost(_REMOTE, '/modalities/orthanctest/store', [ knixStudy, a, b ]) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2194 self.assertEqual(5, len(DoGet(_LOCAL, '/instances'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2195 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2196 self.assertEqual(3, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2197 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2198 DropOrthanc(_REMOTE) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2199 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2200 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2201 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2202 def test_pixel_data(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2203 jpeg = UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2204 color = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2205 phenix = UploadInstance(_REMOTE, 'Phenix/IM-0001-0001.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2206 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2207 phenixSize = 358 * 512 * 2 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2208 colorSize = 1000 * 1000 * 3 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2209 jpegSize = 51918 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2210 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2211 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010' % phenix))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2212 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010' % color))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2213 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010' % jpeg))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2214 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2215 self.assertEqual(0, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010/0' % jpeg))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2216 self.assertEqual(jpegSize, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010/1' % jpeg))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2217 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2218 self.assertEqual(phenixSize, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010/0' % phenix))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2219 self.assertEqual(colorSize, len(DoGet(_REMOTE, '/instances/%s/content/7fe0-0010/0' % color))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2220 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2221 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2222 def test_decode_brainix(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2223 brainix = [ |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2224 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'], # (*) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2225 UploadInstance(_REMOTE, 'Formats/JpegLossless.dcm')['ID'], # JPEG-LS, same as (*) (since Orthanc 0.7.6) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2226 UploadInstance(_REMOTE, 'Formats/Jpeg.dcm')['ID'], # JPEG, same as (*) (since Orthanc 0.7.6) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2227 ] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2228 h = '6fb11b932d535c2be04beabd99793ff8' |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2229 maxValue = 426.0 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2230 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2231 truth = Image.open(GetDatabasePath('Formats/Brainix.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2232 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2233 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2234 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2235 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2236 truth2 = map(lambda x: min(255, x), truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2237 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2238 self.AssertSameImages(truth2, '/instances/%s/image-uint8' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2239 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2240 truth2 = map(lambda x: x * 255.0 / maxValue, truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2241 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2242 self.AssertSameImages(truth2, '/instances/%s/preview' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2243 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2244 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2245 self.assertEqual(h, ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % i))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2246 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2247 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2248 def test_decode_color(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2249 imagej = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2250 color = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2251 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2252 for i in [ imagej, color ]: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2253 for j in [ 'image-uint8', 'image-uint16', 'image-int16' ]: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2254 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/%s' % (i, j))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2255 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2256 self.assertEqual('c14c687f7a1ea9fe022479fc87c67274', ComputeMD5(DoGet(_REMOTE, '/instances/%s/preview' % imagej))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2257 self.assertEqual('a87d122918a56f803bcfe9d2586b9125', ComputeMD5(DoGet(_REMOTE, '/instances/%s/preview' % color))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2258 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2259 self.assertEqual('30cc46bfa7aba77a40e4178f6184c25a', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % imagej))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2260 self.assertEqual('ff195005cef06b59666fd220a9b4cd9a', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % color))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2261 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2262 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2263 def test_decode_rf(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2264 rf = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2265 truth = Image.open(GetDatabasePath('Formats/KarstenHilbertRF.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2266 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2267 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint8' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2268 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2269 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2270 self.AssertSameImages(truth.getdata(), '/instances/%s/preview' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2271 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2272 self.assertEqual('42254d70efd2f4a1b8f3455909689f0e', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % rf))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2273 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2274 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2275 def test_decode_multiframe(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2276 mf = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2277 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2278 # Test the first frame |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2279 truth = Image.open(GetDatabasePath('Formats/Multiframe0.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2280 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint8' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2281 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2282 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2283 self.AssertSameImages(truth.getdata(), '/instances/%s/preview' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2284 self.assertEqual('9812b99d93bbcd4e7684ded089b5dfb3', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % mf))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2285 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2286 self.AssertSameImages(truth.getdata(), '/instances/%s/frames/0/image-uint16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2287 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2288 # Test the last frame |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2289 truth = Image.open(GetDatabasePath('Formats/Multiframe75.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2290 self.AssertSameImages(truth.getdata(), '/instances/%s/frames/75/image-uint16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2291 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2292 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2293 def test_decode_signed(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2294 signed = UploadInstance(_REMOTE, 'SignedCT.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2295 minValue = -2000 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2296 maxValue = 4042 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2297 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2298 truth = Image.open(GetDatabasePath('Formats/SignedCT.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2299 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2300 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2301 truth2 = map(lambda x: 0 if x >= 32768 else x, truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2302 self.AssertSameImages(truth2, '/instances/%s/image-uint16' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2303 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2304 truth3 = map(lambda x: 255 if x >= 256 else x, truth2) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2305 self.AssertSameImages(truth3, '/instances/%s/image-uint8' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2306 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2307 tmp = map(lambda x: x - 65536 if x >= 32768 else x, truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2308 tmp = map(lambda x: (255.0 * (x - minValue)) / (maxValue - minValue), tmp) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2309 self.AssertSameImages(tmp, '/instances/%s/preview' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2310 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2311 self.assertEqual('b57e6c872a3da50877c7da689b03a444', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % signed))) |
22 | 2312 |
2313 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
2314 def test_googlecode_issue_32(self): |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2315 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/tools/default-encoding', 'nope')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2316 self.assertEqual('Windows1251', DoPut(_REMOTE, '/tools/default-encoding', 'Windows1251')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2317 self.assertEqual('Windows1251', DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2318 |
22 | 2319 f = UploadInstance(_REMOTE, 'Issue32.dcm')['ID'] |
2320 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % f) | |
2321 self.assertEqual(u'Рентгенография', tags['SeriesDescription']) | |
2322 self.assertEqual(u'Таз', tags['BodyPartExamined']) | |
2323 self.assertEqual(u'Прямая', tags['ViewPosition']) | |
2324 | |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2325 # Replay the same test using Latin1 as default encoding: This must fail |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2326 self.assertEqual('Latin1', DoPut(_REMOTE, '/tools/default-encoding', 'Latin1')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2327 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2328 DoDelete(_REMOTE, '/instances/%s' % f) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2329 f = UploadInstance(_REMOTE, 'Issue32.dcm')['ID'] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2330 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % f) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2331 self.assertNotEqual(u'Рентгенография', tags['SeriesDescription']) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2332 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2333 |
22 | 2334 def test_encodings(self): |
23 | 2335 # Latin-1 (ISO_IR 100) |
22 | 2336 brainix = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
2337 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % brainix) | |
2338 self.assertEqual(u'IRM cérébrale, neuro-crâne', tags['StudyDescription']) | |
23 | 2339 |
2340 # Latin-2 (ISO_IR 101) | |
2341 a = UploadInstance(_REMOTE, 'MarekLatin2.dcm')['ID'] | |
2342 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % a) | |
2343 # dcm2xml MarekLatin2.dcm | iconv -f latin2 -t utf-8 | xmllint --format - | |
2344 self.assertEqual('Imię i Nazwisko osoby opisującej', | |
2345 i['ContentSequence'][4]['ConceptNameCodeSequence'][0]['CodeMeaning'].encode('utf-8')) | |
2346 | |
26
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2347 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2348 def test_storescu_custom_aet(self): |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2349 # This tests a feature introduced in Orthanc 0.9.1: "Custom |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2350 # setting of the local AET during C-Store SCU (both in Lua and |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2351 # in the REST API)." |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2352 # https://groups.google.com/forum/#!msg/orthanc-users/o5qMULformU/wZjW2iSaMcAJ |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2353 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2354 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2355 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2356 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2357 b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2358 c = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0003.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2359 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2360 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2361 'LocalAet' : 'YOP', |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2362 'Resources' : [ a['ID'], b['ID'] ] |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2363 }) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2364 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2365 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2366 self.assertEqual('YOP', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % a['ID'])) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2367 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2368 DropOrthanc(_LOCAL) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2369 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2370 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2371 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2372 'Resources' : [ c['ID'] ] |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2373 }) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2374 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2375 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2376 self.assertEqual('ORTHANC', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % c['ID'])) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2377 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2378 DropOrthanc(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2379 DropOrthanc(_LOCAL) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2380 |
174 | 2381 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingChangeAet.lua') |
26
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2382 DoPost(_REMOTE, '/tools/execute-script', 'aet = "HELLO"', 'application/lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2383 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2384 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2385 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2386 WaitEmpty(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2387 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2388 self.assertEqual('HELLO', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % a['ID'])) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2389 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2390 DoPost(_REMOTE, '/tools/execute-script', 'aet = nill', 'application/lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2391 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2392 WaitEmpty(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2393 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2394 self.assertEqual('ORTHANC', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % b['ID'])) |
34
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2395 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2396 def test_resources_since_limit(self): |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2397 # Upload 16 instances |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2398 for i in range(4): |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2399 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2400 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2401 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2402 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2403 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2404 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2405 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2406 self.assertEqual(4, len(DoGet(_REMOTE, '/series'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2407 self.assertEqual(16, len(DoGet(_REMOTE, '/instances'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2408 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2409 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/patients&since=10' % i)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2410 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/patients&limit=10' % i)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2411 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2412 self.assertEqual(0, len(DoGet(_REMOTE, '/patients?since=0&limit=0'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2413 self.assertEqual(2, len(DoGet(_REMOTE, '/patients?since=0&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2414 self.assertEqual(2, len(DoGet(_REMOTE, '/studies?since=0&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2415 self.assertEqual(4, len(DoGet(_REMOTE, '/series?since=0&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2416 self.assertEqual(16, len(DoGet(_REMOTE, '/instances?since=0&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2417 self.assertEqual(1, len(DoGet(_REMOTE, '/patients?since=1&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2418 self.assertEqual(0, len(DoGet(_REMOTE, '/patients?since=2&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2419 self.assertEqual(0, len(DoGet(_REMOTE, '/patients?since=3&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2420 self.assertEqual(1, len(DoGet(_REMOTE, '/studies?since=1&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2421 self.assertEqual(3, len(DoGet(_REMOTE, '/series?since=1&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2422 self.assertEqual(2, len(DoGet(_REMOTE, '/series?since=2&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2423 self.assertEqual(1, len(DoGet(_REMOTE, '/series?since=3&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2424 self.assertEqual(0, len(DoGet(_REMOTE, '/series?since=4&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2425 self.assertEqual(0, len(DoGet(_REMOTE, '/series?since=100&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2426 self.assertEqual(15, len(DoGet(_REMOTE, '/instances?since=1&limit=100'))) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2427 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2428 for limit in [ 1, 2, 3, 7, 16, 17 ]: |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2429 s = {} |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2430 since = 0 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2431 while True: |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2432 t = DoGet(_REMOTE, '/instances?since=%d&limit=%d' % (since, limit)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2433 if len(t) == 0: |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2434 break |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2435 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2436 since += len(t) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2437 for i in t: |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2438 s[i] = None |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2439 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2440 self.assertEqual(16, len(s)) |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2441 for instance in DoGet(_REMOTE, '/instances'): |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2442 self.assertTrue(instance in s) |
36 | 2443 |
2444 | |
2445 def test_create_pdf(self): | |
2446 # Upload 4 instances | |
2447 brainixInstance = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] | |
2448 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
2449 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
2450 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
2451 | |
2452 brainixPatient = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' | |
2453 brainixStudy = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' | |
2454 brainixEpi = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
2455 | |
2456 with open(GetDatabasePath('HelloWorld.pdf'), 'rb') as f: | |
2457 pdf = f.read() | |
2458 | |
2459 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2460 json.dumps({ | |
2461 'Tags' : { | |
2462 'PatientName' : 'Jodogne', | |
2463 'Modality' : 'CT', | |
2464 }, | |
2465 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2466 })) | |
2467 | |
2468 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2469 self.assertEqual('OT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i['ID']).strip()) | |
2470 | |
2471 b = DoGet(_REMOTE, '/instances/%s/content/0042-0011' % i['ID']) | |
2472 self.assertEqual(len(b), len(pdf) + 1) | |
2473 self.assertEqual(ComputeMD5(b), ComputeMD5(pdf + '\0')) | |
2474 | |
2475 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/tools/create-dicom', | |
2476 json.dumps({ | |
2477 'Parent' : brainixPatient, | |
2478 'Tags' : { | |
2479 'PatientName' : 'Jodogne', | |
2480 } | |
2481 }))) | |
2482 | |
2483 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2484 json.dumps({ | |
2485 'Parent' : brainixPatient, | |
2486 'Tags' : { 'StudyDescription' : 'PDF^Patient' }, | |
2487 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2488 })) | |
2489 | |
2490 self.assertEqual(brainixPatient, DoGet(_REMOTE, '/instances/%s/patient' % i['ID'])['ID']) | |
2491 | |
2492 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2493 json.dumps({ | |
2494 'Parent' : brainixStudy, | |
2495 'Tags' : { 'SeriesDescription' : 'PDF^Study' }, | |
2496 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2497 })) | |
2498 | |
2499 self.assertEqual(brainixStudy, DoGet(_REMOTE, '/instances/%s/study' % i['ID'])['ID']) | |
2500 | |
2501 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2502 json.dumps({ | |
2503 'Parent' : brainixEpi, | |
37 | 2504 'Tags' : { 'SpecificCharacterSet' : 'ISO_IR 13' }, |
36 | 2505 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) |
2506 })) | |
2507 | |
2508 self.assertEqual(brainixEpi, DoGet(_REMOTE, '/instances/%s/series' % i['ID'])['ID']) | |
2509 | |
2510 b = DoGet(_REMOTE, '/instances/%s/pdf' % i['ID']) | |
2511 self.assertEqual(len(b), len(pdf)) | |
2512 self.assertEqual(ComputeMD5(b), ComputeMD5(pdf)) | |
2513 | |
2514 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/pdf' % brainixInstance)) | |
38 | 2515 |
2516 | |
2517 def test_create_series(self): | |
2518 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2519 json.dumps({ | |
2520 'Tags' : { | |
40 | 2521 'SpecificCharacterSet' : 'ISO_IR 100', |
2522 'PatientName' : 'Sébastien Jodogne', | |
38 | 2523 'Modality' : 'CT', |
2524 }, | |
2525 'Content' : [ | |
40 | 2526 { |
2527 'Content': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', # red dot in RGBA | |
2528 'Tags' : { 'ImageComments' : 'Tutu' } | |
2529 }, | |
38 | 2530 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAoUlEQVQ4jZ2SWw3EIBREjwUsYAELa2EtoAULFUCyXAtroRZqoRbox254BdLC/DZnZjoXWJFgCDg8egW2CBEhEnDzyRk+Ecxz2KP/0AL8S99T+jQccAVs22qKwAuPuq0uyNg9cPLh3am+pe/dkHLZtqJHj6vXJrZ7nvzvxxgemXgUwnGfXqpee09mUwp8m022OYP6bLF7mVuVe0y/umxinsAXRd9z0k1ubWsAAAAASUVORK5CYII=', |
2531 ] | |
2532 })) | |
2533 | |
2534 s = DoGet(_REMOTE, i['Path']) | |
2535 self.assertEqual('Series', s['Type']) | |
2536 self.assertEqual(s['ID'], i['ID']) | |
2537 self.assertEqual(2, len(s['Instances'])) | |
39 | 2538 self.assertEqual(2, s['ExpectedNumberOfInstances']) |
2539 self.assertEqual('Complete', s['Status']) | |
40 | 2540 |
2541 a = DoGet(_REMOTE, '/instances/%s/tags?simplify' % s['Instances'][0]) | |
2542 b = DoGet(_REMOTE, '/instances/%s/tags?simplify' % s['Instances'][1]) | |
2543 self.assertTrue('ImageComments' in a or 'ImageComments' in b) | |
2544 if 'ImageComments' in a: | |
2545 self.assertEqual('Tutu', a['ImageComments']) | |
2546 else: | |
2547 self.assertEqual('Tutu', b['ImageComments']) | |
2548 | |
2549 patient = DoGet(_REMOTE, '/instances/%s/patient' % s['Instances'][0]) | |
2550 self.assertEqual(patient['MainDicomTags']['PatientName'].encode('utf-8'), | |
2551 'Sébastien Jodogne') | |
47 | 2552 |
2553 | |
2554 def test_create_binary(self): | |
2555 binary = ''.join(map(chr, range(256))) | |
2556 encoded = 'data:application/octet-stream;base64,' + base64.b64encode(binary) | |
2557 tags = { | |
2558 'PatientName' : 'Jodogne', | |
2559 '8899-8899' : encoded | |
2560 } | |
2561 | |
2562 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2563 json.dumps({ | |
2564 'Tags' : tags | |
2565 })) | |
2566 | |
2567 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2568 self.assertEqual(binary, DoGet(_REMOTE, '/instances/%s/content/8899-8899' % i['ID']).strip()) | |
2569 | |
2570 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2571 json.dumps({ | |
2572 'InterpretBinaryTags' : False, | |
2573 'Tags' : tags | |
2574 })) | |
2575 | |
2576 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2577 self.assertEqual(encoded, DoGet(_REMOTE, '/instances/%s/content/8899-8899' % i['ID'])[0:-1]) | |
48
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2578 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2579 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2580 def test_patient_ids_collision(self): |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2581 # Upload 3 instances from 3 different studies, but with the |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2582 # same PatientID |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2583 for i in range(3): |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2584 UploadInstance(_REMOTE, 'PatientIdsCollision/Image%d.dcm' % (i + 1)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2585 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2586 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2587 'Query' : { 'PatientName' : '*' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2588 self.assertEqual(1, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2589 self.assertEqual('COMMON', DoGet(_REMOTE, '/patients/%s' % a[0]) ['MainDicomTags']['PatientID']) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2590 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2591 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2592 'CaseSensitive' : True, |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2593 'Query' : { 'PatientName' : 'FOO\\HELLO' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2594 self.assertEqual(2, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2595 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2596 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2597 'CaseSensitive' : False, |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2598 'Query' : { 'PatientName' : 'Foo' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2599 self.assertEqual(1, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2600 self.assertEqual('FOO^SERIES', DoGet(_REMOTE, '/series/%s/study' % a[0]) ['MainDicomTags']['StudyDescription']) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2601 self.assertEqual('FOO', DoGet(_REMOTE, '/series/%s/study' % a[0]) ['PatientMainDicomTags']['PatientName']) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2602 self.assertEqual('COMMON', DoGet(_REMOTE, '/series/%s/study' % a[0]) ['PatientMainDicomTags']['PatientID']) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2603 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2604 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2605 'Query' : { 'PatientName' : '*' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2606 self.assertEqual(3, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2607 d = map(lambda x: DoGet(_REMOTE, '/studies/%s' % x) ['MainDicomTags']['StudyDescription'], a) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2608 self.assertTrue('FOO^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2609 self.assertTrue('HELLO^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2610 self.assertTrue('WORLD^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2611 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2612 d = map(lambda x: DoGet(_REMOTE, '/studies/%s' % x) ['PatientMainDicomTags']['PatientID'], a) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2613 self.assertEqual(1, len(set(d))) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2614 self.assertEqual('COMMON', d[0]) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2615 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2616 for i in a: |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2617 d = DoGet(_REMOTE, '/studies/%s' % i) ['MainDicomTags']['StudyDescription'] |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2618 p = DoGet(_REMOTE, '/studies/%s' % i) ['PatientMainDicomTags']['PatientName'] |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2619 self.assertEqual('%s^SERIES' % p, d) |
49
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2620 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2621 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2622 def test_bitbucket_issue_4(self): |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2623 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2624 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2625 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0003.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2626 UploadInstance(_REMOTE, 'Formats/Jpeg.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2627 UploadInstance(_REMOTE, 'Formats/JpegLossless.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2628 UploadInstance(_REMOTE, 'Formats/Rle.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2629 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2630 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2631 self.assertEqual(6, len(DoGet(_REMOTE, '/instances'))) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2632 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2633 p = DoGet(_REMOTE, '/patients') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2634 self.assertEqual(2, len(p)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2635 i1 = map(lambda x: x['ID'], DoGet(_REMOTE, '/patients/%s/instances' % p[0])) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2636 i2 = map(lambda x: x['ID'], DoGet(_REMOTE, '/patients/%s/instances' % p[1])) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2637 self.assertEqual(3, len(i1)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2638 self.assertEqual(3, len(i2)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2639 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2640 j = DoPost(_REMOTE, '/modalities/orthanctest/store', i2[0:1] + i1 + i2[1:3]) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2641 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2642 self.assertEqual(6, len(DoGet(_LOCAL, '/instances'))) |
50
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2643 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2644 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2645 def test_create_sequence(self): |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2646 i = DoPost(_REMOTE, '/tools/create-dicom', |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2647 json.dumps({ |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2648 'Tags' : { |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2649 'SpecificCharacterSet': 'ISO_IR 100', # Encode using Latin1 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2650 'PatientName': 'Jodogne^', |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2651 'ReferencedStudySequence': GenerateTestSequence(), |
50
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2652 } |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2653 }))['ID'] |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2654 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2655 self.assertEqual('Jodogne^', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2656 self.assertEqual('Hello^', DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/0/StudyDescription' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2657 self.assertEqual('Toto', DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/0/ReferencedStudySequence/0/StudyDescription' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2658 self.assertEqual('Tata', DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/0/ReferencedStudySequence/1/StudyDescription' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2659 self.assertEqual(u'Sébastien^'.encode('latin-1'), |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2660 DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/1/StudyDescription' % i)) |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2661 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2662 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2663 def test_modify_sequence(self): |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2664 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2665 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence' % i)) |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2666 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2667 j = DoPost(_REMOTE, '/instances/%s/modify' % i, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2668 json.dumps({ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2669 "Replace" : { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2670 "PatientName" : "hello", |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2671 'ReferencedStudySequence': GenerateTestSequence(), |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2672 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2673 }), |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2674 'application/json') |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2675 j = DoPost(_REMOTE, '/instances', j, 'application/dicom')['ID'] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2676 DoDelete(_REMOTE, '/instances/%s' % i) |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2677 |
52 | 2678 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence' % j))) |
2679 | |
2680 | |
2681 def test_compression(self): | |
2682 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
2683 | |
2684 data = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % i)[1] | |
2685 | |
2686 # "StorageCompression" is enabled in the Orthanc to be tested, | |
2687 # uncompress the data before running the test | |
2688 if DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i) != 0: | |
2689 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/uncompress' % i) | |
2690 | |
2691 cs = DoGet(_REMOTE, '/statistics')['TotalDiskSize'] | |
2692 us = DoGet(_REMOTE, '/statistics')['TotalUncompressedSize'] | |
2693 size = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i) | |
2694 md5 = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i) | |
2695 self.assertEqual(data, DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1]) | |
2696 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2697 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2698 | |
2699 ops = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json' % i) | |
2700 self.assertTrue('compress' in ops) | |
2701 self.assertTrue('uncompress' in ops) | |
2702 self.assertTrue('is-compressed' in ops) | |
2703 self.assertEqual(0, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2704 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2705 | |
2706 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/compress' % i) | |
2707 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2708 self.assertEqual(1, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2709 self.assertLess(cs, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
2710 self.assertEqual(us, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
2711 self.assertGreater(len(data), len(DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1])) | |
2712 self.assertGreater(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2713 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i)) | |
2714 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i)) | |
2715 self.assertNotEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2716 | |
2717 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/uncompress' % i) | |
2718 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2719 self.assertEqual(0, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2720 self.assertEqual(data, DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1]) | |
2721 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2722 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i)) | |
2723 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i)) | |
2724 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2725 self.assertEqual(cs, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
2726 self.assertEqual(us, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
53 | 2727 |
2728 | |
2729 def test_ordered_slices(self): | |
2730 i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] | |
2731 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2732 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2733 self.assertEqual('Sequence', o['Type']) | |
2734 self.assertEqual(1, len(o['Dicom'])) | |
2735 self.assertEqual('/instances/9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02/file', o['Dicom'][0]) | |
2736 self.assertEqual(76, len(o['Slices'])) | |
2737 for j in range(76): | |
2738 self.assertEqual('/instances/9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02/frames/%d' % j, o['Slices'][j]) | |
2739 | |
68 | 2740 self.assertEqual(1, len(o['SlicesShort'])) |
2741 self.assertEqual('9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02', o['SlicesShort'][0][0]) | |
2742 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2743 self.assertEqual(76, o['SlicesShort'][0][2]) | |
2744 | |
53 | 2745 i = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
2746 j = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm')['ID'] | |
2747 k = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0003.dcm')['ID'] | |
2748 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2749 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2750 | |
2751 self.assertEqual('Volume', o['Type']) | |
2752 self.assertEqual(3, len(o['Dicom'])) | |
2753 self.assertEqual(3, len(o['Slices'])) | |
2754 self.assertEqual('/instances/%s/file' % i, o['Dicom'][2]) | |
2755 self.assertEqual('/instances/%s/file' % j, o['Dicom'][1]) | |
2756 self.assertEqual('/instances/%s/file' % k, o['Dicom'][0]) | |
2757 self.assertEqual('/instances/%s/frames/0' % i, o['Slices'][2]) | |
2758 self.assertEqual('/instances/%s/frames/0' % j, o['Slices'][1]) | |
2759 self.assertEqual('/instances/%s/frames/0' % k, o['Slices'][0]) | |
2760 | |
68 | 2761 self.assertEqual(3, len(o['SlicesShort'])) |
2762 self.assertEqual(k, o['SlicesShort'][0][0]) | |
2763 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2764 self.assertEqual(1, o['SlicesShort'][0][2]) | |
2765 self.assertEqual(j, o['SlicesShort'][1][0]) | |
2766 self.assertEqual(0, o['SlicesShort'][1][1]) | |
2767 self.assertEqual(1, o['SlicesShort'][1][2]) | |
2768 self.assertEqual(i, o['SlicesShort'][2][0]) | |
2769 self.assertEqual(0, o['SlicesShort'][2][1]) | |
2770 self.assertEqual(1, o['SlicesShort'][2][2]) | |
2771 | |
53 | 2772 i = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] |
2773 j = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0002.dcm')['ID'] | |
2774 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2775 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2776 | |
2777 self.assertEqual('Sequence', o['Type']) | |
2778 self.assertEqual(2, len(o['Dicom'])) | |
2779 self.assertEqual(2, len(o['Slices'])) | |
2780 self.assertEqual('/instances/%s/file' % i, o['Dicom'][0]) | |
2781 self.assertEqual('/instances/%s/file' % j, o['Dicom'][1]) | |
2782 self.assertEqual('/instances/%s/frames/0' % i, o['Slices'][0]) | |
2783 self.assertEqual('/instances/%s/frames/0' % j, o['Slices'][1]) | |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2784 |
68 | 2785 self.assertEqual(2, len(o['SlicesShort'])) |
2786 self.assertEqual(i, o['SlicesShort'][0][0]) | |
2787 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2788 self.assertEqual(1, o['SlicesShort'][0][2]) | |
2789 self.assertEqual(j, o['SlicesShort'][1][0]) | |
2790 self.assertEqual(0, o['SlicesShort'][1][1]) | |
2791 self.assertEqual(1, o['SlicesShort'][1][2]) | |
2792 | |
2793 | |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2794 |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2795 def test_incoming_movescu_accession(self): |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2796 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2797 |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2798 # No matching patient, so no job is created |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2799 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2800 CallMoveScu([ '--study', '-k', '0008,0052=STUDY', '-k', 'AccessionNumber=nope' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2801 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2802 CallMoveScu([ '--study', '-k', '0008,0052=PATIENT', '-k', 'AccessionNumber=A10003245599' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2803 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2804 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2805 # 1 Matching patient, track the job |
138 | 2806 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
2807 '--study', | |
2808 '-k', '0008,0052=STUDY', | |
2809 '-k', 'AccessionNumber=A10003245599' | |
2810 ]))) | |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2811 |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2812 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2813 |
55 | 2814 |
2815 def test_dicom_to_json(self): | |
2816 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2817 j = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2818 |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2819 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2820 with open(GetDatabasePath('PrivateMDNTagsSimplify.json'), 'r') as f: |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
2821 self.assertTrue(CompareTags(t, json.loads(f.read()), [ |
123 | 2822 # Tags for compatibility with DCMTK 3.6.0 |
2823 'RETIRED_OtherPatientIDs', | |
2824 'OtherPatientIDs', | |
2825 'ACR_NEMA_2C_VariablePixelDataGroupLength', | |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
2826 ])) |
55 | 2827 |
2828 t = DoGet(_REMOTE, '/instances/%s/tags' % i) | |
2829 with open(GetDatabasePath('PrivateMDNTagsFull.json'), 'r') as f: | |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
2830 self.assertTrue(CompareTags(t, json.loads(f.read()), [ |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
2831 ])) |
55 | 2832 |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2833 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % j) |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2834 with open(GetDatabasePath('PrivateTagsSimplify.json'), 'r') as f: |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
2835 self.assertTrue(CompareTags(t, json.loads(f.read()), [ |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
2836 ])) |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2837 |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2838 t = DoGet(_REMOTE, '/instances/%s/tags' % j) |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2839 with open(GetDatabasePath('PrivateTagsFull.json'), 'r') as f: |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2840 a = json.loads(f.read()) |
65
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
2841 aa = json.dumps(a).replace('2e+022', '2e+22') |
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
2842 tt = json.dumps(t).replace('2e+022', '2e+22') |
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
2843 self.assertEqual(aa, tt) |
57 | 2844 |
2845 | |
2846 def test_batch_archive(self): | |
2847 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
2848 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') | |
2849 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
2850 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0002.dcm') | |
2851 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
2852 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm') | |
2853 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
2854 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0002.dcm') | |
2855 | |
2856 s = DoPost(_REMOTE, '/tools/create-archive', [ ]) | |
2857 z = zipfile.ZipFile(StringIO(s), "r") | |
2858 self.assertEqual(0, len(z.namelist())) | |
2859 | |
2860 # One patient | |
2861 s = DoPost(_REMOTE, '/tools/create-archive', [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ]) | |
2862 z = zipfile.ZipFile(StringIO(s), "r") | |
2863 self.assertEqual(4, len(z.namelist())) | |
2864 | |
2865 # One patient + twice its study + one series from other patient | |
2866 s = DoPost(_REMOTE, '/tools/create-archive', [ | |
2867 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
2868 '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918', | |
2869 '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
2870 ]) | |
2871 z = zipfile.ZipFile(StringIO(s), "r") | |
2872 self.assertEqual(6, len(z.namelist())) | |
2873 | |
2874 # One patient + one series + one instance | |
2875 s = DoPost(_REMOTE, '/tools/create-archive', [ | |
2876 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
2877 '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0', | |
2878 '1d429ccb-bdcc78a1-7d129d6a-ba4966ed-fe4dbd87' | |
2879 ]) | |
2880 z = zipfile.ZipFile(StringIO(s), "r") | |
2881 self.assertEqual(7, len(z.namelist())) | |
59
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2882 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2883 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2884 def test_decode_brainix_as_jpeg(self): |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2885 i = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2886 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2887 j = GetImage(_REMOTE, '/instances/%s/preview' % i) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2888 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2889 self.assertEqual(j.size[0], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2890 self.assertEqual(j.size[1], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2891 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2892 j = GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : '*/*' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2893 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2894 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2895 j = GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'image/*' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2896 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2897 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2898 j = GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'image/png' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2899 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2900 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2901 j = GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'image/jpeg' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2902 self.assertEqual('JPEG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2903 self.assertEqual(j.size[0], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2904 self.assertEqual(j.size[1], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2905 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2906 a = len(DoGet(_REMOTE, '/instances/%s/preview?quality=50' % i, headers = { 'Accept' : 'image/jpeg' })) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2907 b = len(DoGet(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'image/jpeg' })) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2908 self.assertLess(a, b) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2909 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2910 j = GetImage(_REMOTE, '/instances/%s/image-uint8' % i, headers = { 'Accept' : 'image/jpeg' }) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2911 self.assertEqual('JPEG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2912 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2913 # 16bit encoding is not supported with JPEG |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2914 self.assertRaises(Exception, lambda: GetImage(_REMOTE, '/instances/%s/image-uint16' % i, headers = { 'Accept' : 'image/jpeg' })) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2915 self.assertRaises(Exception, lambda: GetImage(_REMOTE, '/instances/%s/image-int16' % i, headers = { 'Accept' : 'image/jpeg' })) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2916 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2917 # No matching content type |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2918 self.assertRaises(Exception, lambda: GetImage(_REMOTE, '/instances/%s/preview' % i, headers = { 'Accept' : 'application/pdf' })) |
69
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2919 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2920 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2921 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2922 def test_media_encodings(self): |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2923 ascii = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2924 latin1 = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2925 latin2 = UploadInstance(_REMOTE, 'MarekLatin2.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2926 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2927 tmp = DoPost(_REMOTE, '/tools/create-media', [ascii,latin1,latin2]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2928 z = zipfile.ZipFile(StringIO(tmp), "r") |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2929 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2930 self.assertEqual(4, len(z.namelist())) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2931 self.assertTrue('IMAGES/IM0' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2932 self.assertTrue('IMAGES/IM1' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2933 self.assertTrue('IMAGES/IM2' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2934 self.assertTrue('DICOMDIR' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2935 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2936 try: |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2937 os.remove('/tmp/DICOMDIR') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2938 except: |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2939 # The file does not exist |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2940 pass |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2941 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2942 z.extract('DICOMDIR', '/tmp') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2943 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2944 stderr = subprocess.STDOUT).split('\n') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2945 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2946 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2947 stderr = subprocess.STDOUT).split('\n') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2948 self.assertEqual(1, len(a)) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2949 self.assertEqual('', a[0]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2950 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2951 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2952 self.assertTrue(re.search('1.3.46.670589.11.17521.5.0.3124.2008081908590448738', a) != None) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2953 self.assertTrue(re.search('1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114333648576', a) != None) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2954 self.assertTrue(re.search('1.2.826.0.1.3680043.2.1569.1.4.323026757.1700.1399452091.57', a) != None) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2955 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2956 os.remove('/tmp/DICOMDIR') |
71
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2957 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2958 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2959 def test_findscu_counters(self): |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2960 UploadInstance(_REMOTE, 'Comunix/Ct/IM-0001-0001.dcm') |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2961 UploadInstance(_REMOTE, 'Comunix/Pet/IM-0001-0001.dcm') |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2962 UploadInstance(_REMOTE, 'Comunix/Pet/IM-0001-0002.dcm') |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2963 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2964 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', 'NumberOfPatientRelatedStudies' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2965 s = re.findall('\(0020,1200\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2966 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2967 self.assertTrue('1 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2968 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2969 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', 'NumberOfPatientRelatedSeries' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2970 s = re.findall('\(0020,1202\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2971 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2972 self.assertTrue('2 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2973 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2974 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', 'NumberOfPatientRelatedInstances' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2975 s = re.findall('\(0020,1204\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2976 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2977 self.assertTrue('3 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2978 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2979 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'NumberOfStudyRelatedSeries' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2980 s = re.findall('\(0020,1206\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2981 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2982 self.assertTrue('2 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2983 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2984 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'NumberOfStudyRelatedInstances' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2985 s = re.findall('\(0020,1208\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2986 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2987 self.assertTrue('3 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2988 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2989 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'NumberOfSeriesRelatedInstances' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2990 s = re.findall('\(0020,1209\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2991 self.assertEqual(2, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2992 self.assertTrue('1 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2993 self.assertTrue('2 ' in s) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2994 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2995 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'ModalitiesInStudy' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2996 s = re.findall('\(0008,0061\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2997 self.assertEqual(1, len(s)) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2998 t = map(lambda x: x.strip(), s[0].split('\\')) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2999 self.assertTrue('PT' in t) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3000 self.assertTrue('CT' in t) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3001 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3002 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'SOPClassesInStudy' ]) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3003 s = re.findall('\(0008,0062\).*?\[(.*?)\]', i) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3004 self.assertEqual(1, len(s)) |
176
48cc188ffb09
strip trailing 0 char that appears with some findscu versions
am@osimis.io
parents:
175
diff
changeset
|
3005 t = map(lambda x: x.strip('\x00'), s[0].split('\\')) |
71
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3006 self.assertTrue('1.2.840.10008.5.1.4.1.1.2' in t) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3007 self.assertTrue('1.2.840.10008.5.1.4.1.1.128' in t) |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3008 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3009 |
78
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3010 def test_decode_transfer_syntax(self): |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3011 def Check(t, md5): |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3012 i = UploadInstance(_REMOTE, 'TransferSyntaxes/%s.dcm' % t)['ID'] |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3013 |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3014 if t != '1.2.840.10008.1.2': # This file has no meta header |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3015 transferSyntax = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % i) |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3016 self.assertEqual(t, transferSyntax) |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3017 |
78
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3018 if md5 == None: |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3019 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/preview' % i)) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3020 else: |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3021 m = ComputeMD5(DoGet(_REMOTE, '/instances/%s/preview' % i)) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3022 self.assertEqual(m, md5) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3023 |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3024 Check('1.2.840.10008.1.2.1', 'fae08d5415c4c0cd2cdbae4522408631') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3025 Check('1.2.840.10008.1.2.2', 'f3d9784768b8feb54d6a50b6d5c37682') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3026 Check('1.2.840.10008.1.2.4.50', '496326046974eea718dbc16b997c646b') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3027 Check('1.2.840.10008.1.2.4.51', 'ccbe75909fe5c9f7361b48416a53fc41') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3028 Check('1.2.840.10008.1.2.4.57', '7bbefe11d976b1be4e568915c6a82fc3') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3029 Check('1.2.840.10008.1.2.4.70', '7132cfbc457305b04b59787030c785d2') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3030 Check('1.2.840.10008.1.2.4.80', '6ff51ae525d362e0d04f550a64075a0e') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3031 Check('1.2.840.10008.1.2.4.81', '801579ae7cbf28e604ea74f2c99fa2ca') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3032 Check('1.2.840.10008.1.2.5', '6ff51ae525d362e0d04f550a64075a0e') # RLE, supported since Orthanc 1.0.1 |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3033 Check('1.2.840.10008.1.2', 'd54aed9f67a100984b42942cc2e9939b') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3034 Check('1.2.840.10008.1.2.4.90', None) # JPEG-2000 image, not supported |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3035 Check('1.2.840.10008.1.2.4.91', None) # JPEG-2000 image, not supported |
79 | 3036 |
3037 | |
3038 def test_raw_frame(self): | |
3039 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] | |
3040 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3041 a = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3042 self.assertEqual(512 * 512 * 2, len(a)) | |
3043 self.assertEqual(512 * 512 * 2, len(DoGet(_REMOTE, '/instances/%s/frames/23/raw' % s))) | |
3044 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/24/raw' % s)) | |
3045 self.assertEqual('1914287dc4d958eca21fdaacfb3482fa', ComputeMD5(a)) | |
3046 | |
3047 s = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] | |
3048 self.assertEqual(76, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3049 self.assertEqual(186274, len(DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s))) | |
3050 self.assertEqual(189424, len(DoGet(_REMOTE, '/instances/%s/frames/75/raw' % s))) | |
3051 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/76/raw' % s)) | |
3052 im = GetImage(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3053 self.assertEqual("L", im.mode) | |
3054 self.assertEqual(512, im.size[0]) | |
3055 self.assertEqual(512, im.size[1]) | |
3056 | |
3057 # Test an image with 2 JPEG frames spread over multiple fragments | |
3058 s = UploadInstance(_REMOTE, 'LenaTwiceWithFragments.dcm')['ID'] | |
3059 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3060 a = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3061 b = DoGet(_REMOTE, '/instances/%s/frames/1/raw' % s) | |
3062 self.assertEqual(69214, len(a)) | |
3063 self.assertEqual(ComputeMD5(a), ComputeMD5(b)) | |
3064 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/2/raw' % s)) | |
3065 im = GetImage(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3066 self.assertEqual("RGB", im.mode) | |
3067 self.assertEqual(512, im.size[0]) | |
3068 self.assertEqual(512, im.size[1]) | |
3069 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % s) | |
3070 self.assertEqual("RGB", im.mode) | |
3071 self.assertEqual(512, im.size[0]) | |
3072 self.assertEqual(512, im.size[1]) | |
81 | 3073 |
3074 | |
3075 | |
3076 def test_rest_movescu(self): | |
3077 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3078 | |
3079 # Upload 4 instances | |
3080 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
3081 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0002.dcm') | |
3082 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
3083 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
3084 | |
3085 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3086 for p in DoGet(_REMOTE, '/patients'): | |
3087 DoPost(_REMOTE, '/modalities/orthanctest/store', p) | |
3088 DoDelete(_REMOTE, '/patients/%s' % p) | |
3089 | |
3090 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3091 | |
3092 # Upload instance Brainix/Flair/IM-0001-0001.dcm | |
3093 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Instance', | |
3094 'Resources' : [ | |
3095 { | |
3096 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3097 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497', | |
3098 'SOPInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549', | |
3099 } | |
3100 ]}) | |
3101 | |
3102 # Upload series Brainix/Flair/* | |
3103 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3104 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3105 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
3106 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
3107 | |
3108 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Series', | |
3109 'Resources' : [ | |
3110 { | |
3111 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3112 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497', | |
3113 } | |
3114 ]}) | |
3115 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3116 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3117 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
3118 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) | |
3119 | |
3120 # Upload series Brainix/Epi/* | |
3121 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Series', | |
3122 'Resources' : [ | |
3123 { | |
3124 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3125 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314125550', | |
3126 } | |
3127 ]}) | |
3128 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3129 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3130 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
3131 self.assertEqual(3, len(DoGet(_REMOTE, '/instances'))) | |
3132 | |
3133 # Upload study Knee/* | |
3134 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Study', | |
3135 'Resources' : [ | |
3136 { | |
3137 'StudyInstanceUID' : '2.16.840.1.113669.632.20.121711.10000160881', | |
3138 } | |
3139 ]}) | |
3140 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3141 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) | |
3142 self.assertEqual(3, len(DoGet(_REMOTE, '/series'))) | |
3143 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
3144 | |
3145 # Reset | |
3146 for p in DoGet(_REMOTE, '/patients'): | |
3147 DoDelete(_REMOTE, '/patients/%s' % p) | |
3148 | |
3149 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3150 | |
3151 | |
3152 # Upload all at once | |
3153 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Study', | |
3154 'Resources' : [ | |
3155 { | |
3156 'StudyInstanceUID' : '2.16.840.1.113669.632.20.121711.10000160881', | |
3157 }, | |
3158 { | |
3159 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3160 } | |
3161 ]}) | |
3162 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3163 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) | |
3164 self.assertEqual(3, len(DoGet(_REMOTE, '/series'))) | |
3165 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
3166 | |
86
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3167 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3168 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3169 def test_reconstruct_json(self): |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3170 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3171 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3172 instance = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3173 first = DoGet(_REMOTE, '/instances/%s/tags' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3174 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3175 self.assertEqual('TWINOW', first['0008,1010']['Value']) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3176 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3177 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3178 # Cannot delete the "DICOM" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3179 self.assertRaises(Exception, lambda: DoDelete(_REMOTE, '/instances/%s/attachments/dicom' % instance)) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3180 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3181 # Can delete the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3182 r = DoDelete(_REMOTE, '/instances/%s/attachments/dicom-as-json' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3183 self.assertTrue(type(r) is dict and len(r) == 0) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3184 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3185 # Only the "DICOM" attachment subsists |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3186 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3187 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3188 # Cannot manually reconstruct the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3189 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/patients/%s/attachments/dicom-as-json' % patient, 'hello')) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3190 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3191 # Transparently reconstruct the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3192 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json' % instance)) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3193 second = DoGet(_REMOTE, '/instances/%s/tags' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3194 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3195 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3196 third = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3197 self.assertEqual(str(first), str(second)) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3198 self.assertEqual(str(first), str(third)) |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3199 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3200 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3201 def test_reconstruct_json2(self): |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3202 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3203 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3204 a = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3205 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm')['ID'] |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3206 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3207 self.assertEqual('BRAINIX', DoGet(_REMOTE, '/instances/%s/tags?simplify' % a)['PatientName']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3208 self.assertEqual('KNEE', DoGet(_REMOTE, '/instances/%s/tags?simplify' % b)['PatientName']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3209 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3210 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % a))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3211 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % b))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3212 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3213 DoPost(_REMOTE, '/tools/invalidate-tags', '', 'text/plain') |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3214 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3215 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % a))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3216 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % b))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3217 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3218 self.assertEqual('BRAINIX', DoGet(_REMOTE, '/instances/%s/tags?simplify' % a)['PatientName']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3219 self.assertEqual('KNEE', DoGet(_REMOTE, '/instances/%s/tags?simplify' % b)['PatientName']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3220 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3221 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % a))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3222 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % b))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3223 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3224 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3225 def test_private_tags(self): |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3226 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3227 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3228 self.assertEqual('1.2.840.113704.1.111.6320.1342451261.21', t['PET-CT Multi Modality Name']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3229 self.assertEqual('p37s0_na_ctac.img', t['Original Image Filename']) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3230 |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3231 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3232 def test_findscu_encoding(self): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3233 # Check out ../Database/Encodings/Generate.sh |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3234 TEST = u'Test-éüäöòДΘĝדصķћ๛ネİ' |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3235 ENCODINGS = { |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3236 'Arabic' : [ 'ISO_IR 127' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3237 'Ascii' : [ 'ISO_IR 6' ], # More accurately, ISO 646 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3238 'Cyrillic' : [ 'ISO_IR 144' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3239 'Greek' : [ 'ISO_IR 126' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3240 'Hebrew' : [ 'ISO_IR 138' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3241 'Japanese' : [ 'ISO_IR 13', 'shift-jis' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3242 'Latin1' : [ 'ISO_IR 100' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3243 'Latin2' : [ 'ISO_IR 101' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3244 'Latin3' : [ 'ISO_IR 109' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3245 'Latin4' : [ 'ISO_IR 110' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3246 'Latin5' : [ 'ISO_IR 148' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3247 'Thai' : [ 'ISO_IR 166', 'tis-620' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3248 'Utf8' : [ 'ISO_IR 192' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3249 } |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3250 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3251 for name in ENCODINGS.iterkeys(): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3252 if len(ENCODINGS[name]) == 1: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3253 ENCODINGS[name].append(name.lower()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3254 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3255 UploadInstance(_REMOTE, 'Encodings/Lena-utf8.dcm') |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3256 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3257 for name in ENCODINGS.iterkeys(): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3258 self.assertEqual(name, DoPut(_REMOTE, '/tools/default-encoding', name)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3259 self.assertEqual(name, DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3260 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3261 i = CallFindScu([ '-k', '0008,0052=STUDY', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3262 '-k', 'SpecificCharacterSet', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3263 '-k', 'PatientName' ]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3264 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3265 characterSet = re.findall('\(0008,0005\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3266 self.assertEqual(1, len(characterSet)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3267 self.assertEqual(ENCODINGS[name][0], characterSet[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3268 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3269 patientName = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3270 self.assertEqual(1, len(patientName)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3271 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3272 expected = TEST.encode(ENCODINGS[name][1], 'ignore') |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3273 self.assertEqual(expected, patientName[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3274 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3275 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3276 #for master in ENCODINGS: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3277 for master in [ 'Latin1', 'Utf8', 'Cyrillic' ]: # Shortcut to speedup tests |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3278 self.assertEqual(master, DoPut(_REMOTE, '/tools/default-encoding', master)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3279 self.assertEqual(master, DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3280 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3281 for name in ENCODINGS: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3282 DropOrthanc(_REMOTE) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3283 UploadInstance(_REMOTE, 'Encodings/Lena-%s.dcm' % ENCODINGS[name][1]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3284 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3285 i = CallFindScu([ '-k', '0008,0052=STUDY', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3286 '-k', 'PatientID', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3287 '-k', 'SpecificCharacterSet', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3288 '-k', 'PatientName' ]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3289 i = i.decode(ENCODINGS[master][1]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3290 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3291 characterSet = re.findall('\(0008,0005\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3292 self.assertEqual(1, len(characterSet)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3293 self.assertEqual(ENCODINGS[master][0], characterSet[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3294 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3295 patientId = re.findall('\(0010,0020\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3296 self.assertEqual(1, len(patientId)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3297 self.assertEqual(ENCODINGS[name][1], patientId[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3298 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3299 patientName = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3300 self.assertEqual(1, len(patientName)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3301 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3302 tmp = ENCODINGS[name][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3303 expected = TEST.encode(tmp, 'ignore').decode(tmp) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3304 tmp = ENCODINGS[master][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3305 expected = expected.encode(tmp, 'ignore').decode(tmp) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3306 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3307 self.assertEqual(expected, patientName[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3308 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3309 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3310 a = DoPost(_REMOTE, '/tools/find', { 'Expand' : True, |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3311 'Level' : 'Study', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3312 'Query' : { }}) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3313 self.assertEqual(1, len(a)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3314 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3315 tmp = ENCODINGS[name][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3316 self.assertEqual(TEST.encode(tmp, 'ignore').decode(tmp), a[0]["PatientMainDicomTags"]["PatientName"]) |
96
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3317 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3318 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3319 def test_reconstruct(self): |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3320 def CompareMainDicomTag(expected, instance, level, tag): |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3321 self.assertEqual(expected, DoGet(_REMOTE, '/instances/%s/%s' % (instance, level))['MainDicomTags'][tag].strip()) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3322 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3323 a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3324 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3325 studies = DoGet(_REMOTE, '/studies/') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3326 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3327 self.assertEqual(1, len(studies)) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3328 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3329 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3330 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3331 modified = DoPost(_REMOTE, '/studies/%s/modify' % studies[0], { |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3332 "Replace" : { |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3333 "StudyDescription" : "hello", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3334 "SeriesDescription" : "world", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3335 "SOPClassUID" : "test", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3336 "SOPInstanceUID" : "myid", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3337 }, |
119 | 3338 "Keep" : [ "StudyInstanceUID", "SeriesInstanceUID" ], |
3339 "Force" : True | |
96
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3340 }) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3341 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3342 instances = DoGet(_REMOTE, '/instances/') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3343 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3344 self.assertEqual(1, len(DoGet(_REMOTE, '/studies/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3345 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3346 self.assertEqual(2, len(instances)) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3347 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3348 b = instances[0] if instances[1] == a else instances[1] |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3349 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3350 CompareMainDicomTag('Knee (R)', a, 'study', 'StudyDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3351 CompareMainDicomTag('AX. FSE PD', a, 'series', 'SeriesDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3352 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', a, '', 'SOPInstanceUID') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3353 CompareMainDicomTag('myid', b, '', 'SOPInstanceUID') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3354 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % a).strip()) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3355 self.assertEqual('test', DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % b).strip()) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3356 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3357 DoPost(_REMOTE, '/instances/%s/reconstruct' % b, {}) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3358 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3359 CompareMainDicomTag('hello', a, 'study', 'StudyDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3360 CompareMainDicomTag('world', a, 'series', 'SeriesDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3361 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', a, '', 'SOPInstanceUID') |
102 | 3362 |
104 | 3363 def test_httpClient_lua(self): |
3364 with open(GetDatabasePath('Lua/HttpClient.lua'), 'r') as f: | |
102 | 3365 result = DoPost(_REMOTE, '/tools/execute-script', f.read(), 'application/lua') |
3366 | |
3367 self.assertIn('OK', result) | |
107
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3368 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3369 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3370 def test_bitbucket_issue_44(self): |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3371 # https://bitbucket.org/sjodogne/orthanc/issues/44/bad-interpretation-of-photometric |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3372 UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3373 UploadInstance(_REMOTE, 'Issue44/Monochrome2.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3374 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3375 # dcmcjpeg +ua +eb Monochrome1.dcm Monochrome1-Jpeg.dcm |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3376 UploadInstance(_REMOTE, 'Issue44/Monochrome1-Jpeg.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3377 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3378 # dcmcjpeg +ua Monochrome1.dcm Monochrome1-JpegLS.dcm |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3379 UploadInstance(_REMOTE, 'Issue44/Monochrome1-JpegLS.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3380 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3381 monochrome1 = 'bcdd600a-a6a9c522-5f0a6e84-8657c9f3-b76e59b7' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3382 monochrome1_jpeg = '9df82121-208a2da8-0038674a-3d7a773b-b7008cd2' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3383 monochrome1_jpegls = '0486d1a2-9165573f-b1976b20-e927b016-6b8d67ab' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3384 monochrome2 = 'f00947b7-f61f7164-c93414d1-c6fbda6a-9e92ed20' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3385 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3386 for i in [ monochrome1, monochrome1_jpeg, monochrome1_jpegls ]: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3387 im = GetImage(_REMOTE, '/instances/%s/preview' % i) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3388 self.assertEqual("L", im.mode) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3389 self.assertEqual(2010, im.size[0]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3390 self.assertEqual(2446, im.size[1]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3391 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3392 # This is the chest image, with MONOCHROME1. Raw background is |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3393 # white (255), should be rendered as black (0) => invert |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3394 if i == monochrome1_jpeg: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3395 # Add some tolerance because of JPEG destructive compression |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3396 self.assertGreater(10, im.getpixel((0,0))) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3397 else: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3398 self.assertEqual(0, im.getpixel((0,0))) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3399 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3400 im = GetImage(_REMOTE, '/instances/%s/preview' % monochrome2) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3401 self.assertEqual("L", im.mode) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3402 self.assertEqual(1572, im.size[0]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3403 self.assertEqual(2010, im.size[1]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3404 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3405 # This is the key image, with MONOCHROME2. Raw background is |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3406 # white (255), should be rendered as white (255) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3407 self.assertEqual(255, im.getpixel((0,0))) |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3408 |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3409 |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3410 def test_bitbucket_issue_42(self): |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3411 # https://bitbucket.org/sjodogne/orthanc/issues/42/fails-to-modify-a-dicom-video-file |
123 | 3412 # This test fails on DCMTK 3.6.0, but succeeds in DCMTK 3.6.1 snapshots and DCMTK 3.6.2 |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3413 UploadInstance(_REMOTE, 'Issue42.dcm')['ID'] |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3414 modified = DoPost(_REMOTE, |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3415 '/patients/da128605-e040d0c4-310615d2-3475da63-df2d1ef4/modify', |
119 | 3416 '{"Replace":{"PatientID":"Hello","PatientName":"Sample patient name"},"Force":true}', |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3417 'application/json') |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3418 self.assertTrue('PatientID' in modified) |
113
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3419 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3420 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3421 def test_rest_find_limit(self): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3422 # Check the "Since" and "Limit" parameters in URI "/tools/find" |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3423 # Related to issue 53: https://bitbucket.org/sjodogne/orthanc/issues/53 |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3424 |
113
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3425 # Upload 6 instances |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3426 brainix = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3427 knee = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3428 for i in range(2): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3429 brainix.append(UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) ['ID']) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3430 brainix.append(UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) ['ID']) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3431 knee.append(UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) ['ID']) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3432 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3433 # Check using BRAINIX |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3434 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3435 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3436 'Limit' : 10 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3437 self.assertEqual(4, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3438 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3439 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3440 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3441 'Limit' : 4 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3442 self.assertEqual(4, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3443 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3444 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3445 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3446 'Since' : 2, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3447 'Limit' : 4 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3448 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3449 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3450 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3451 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3452 'Limit' : 3 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3453 self.assertEqual(3, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3454 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3455 b = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3456 for i in range(4): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3457 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3458 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3459 'Limit' : 1, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3460 'Since' : i }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3461 self.assertEqual(1, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3462 b.append(a[0]) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3463 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3464 # Check whether the two sets are equal through symmetric difference |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3465 self.assertEqual(0, len(set(b) ^ set(brainix))) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3466 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3467 # Check using KNEE |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3468 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3469 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3470 'Limit' : 10 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3471 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3472 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3473 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3474 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3475 'Limit' : 2 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3476 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3477 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3478 b = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3479 for i in range(2): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3480 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3481 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3482 'Limit' : 1, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3483 'Since' : i }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3484 self.assertEqual(1, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3485 b.append(a[0]) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3486 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3487 self.assertEqual(0, len(set(b) ^ set(knee))) |
115
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3488 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3489 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3490 def test_bitbucket_issue_46(self): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3491 # "PHI remaining after anonymization" |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3492 # https://bitbucket.org/sjodogne/orthanc/issues/46 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3493 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3494 def GetAnonymizedTags(study, version): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3495 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3496 { 'DicomVersion' : version }, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3497 'application/json') ['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3498 a = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3499 self.assertEqual(1, len(a)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3500 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3501 instance = a[0]['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3502 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3503 return (instance, DoGet(_REMOTE, '/instances/%s/tags' % instance)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3504 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3505 UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm') |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3506 origStudy = '6068a14b-d4df27af-9ec22145-538772d8-74f228ff' |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3507 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3508 # Add the 0032,1033 (Requesting Service) and the 0010,1060 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3509 # (Patient's Mother's Birth Name) tags |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3510 newStudy = DoPost(_REMOTE, '/studies/%s/modify' % origStudy, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3511 '{"Replace":{"0010,1060":"OSIMIS","0032,1033":"MOTHER"}}', |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3512 'application/json')['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3513 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3514 # Use Table E.1-1 from PS 3.15-2008 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3515 # https://raw.githubusercontent.com/jodogne/dicom-specification/master/2008/08_15pu.pdf |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3516 (instance, tags) = GetAnonymizedTags(newStudy, "2008") |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3517 self.assertTrue('0032,1033' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3518 self.assertTrue('0010,1060' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3519 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3520 # Use Table E.1-1 from PS 3.15-2011 (only if Orthanc >= 1.2.1) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3521 # https://raw.githubusercontent.com/jodogne/dicom-specification/master/2008/08_15pu.pdf |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3522 (instance, tags) = GetAnonymizedTags(newStudy, "2017c") |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3523 self.assertFalse('0032,1033' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3524 self.assertFalse('0010,1060' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3525 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3526 t = {} |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3527 for (key, value) in tags.iteritems(): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3528 t[value['Name']] = value['Value'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3529 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3530 self.assertEqual('', t['StudyDate']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3531 self.assertEqual('', t['StudyTime']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3532 self.assertEqual('', t['PatientSex']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3533 self.assertFalse('SeriesDate' in t) # Type 3 tag => null |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3534 self.assertFalse('SeriesTime' in t) # Type 3 tag => null |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3535 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3536 with tempfile.NamedTemporaryFile(delete = True) as f: |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3537 # Run "dciodvfy" on the anonymized file to be sure it is still valid |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3538 f.write(DoGet(_REMOTE, '/instances/%s/file' % instance)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3539 f.flush() |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3540 subprocess.check_output([ FindExecutable('dciodvfy'), f.name ], |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3541 stderr = subprocess.STDOUT).split('\n') |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3542 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3543 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3544 def test_bitbucket_issue_55(self): |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3545 def Run(modify, query): |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3546 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3547 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3548 operation = 'modify' if modify else 'anonymize' |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3549 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3550 self.assertRaises(Exception, lambda: DoPost( |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3551 _REMOTE, '/studies/%s/%s' % (study, operation), query)) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3552 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3553 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3554 query["Force"] = True |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3555 a = DoPost(_REMOTE, '/studies/%s/%s' % (study, operation), query)['Path'] |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3556 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3557 DoDelete(_REMOTE, a) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3558 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3559 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3560 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3561 UploadInstance(_REMOTE, 'DummyCT.dcm') |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3562 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3563 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3564 Run(True, { "Replace" : { "StudyInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3565 Run(True, { "Replace" : { "SeriesInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3566 Run(True, { "Replace" : { "SOPInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3567 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3568 Run(False, { "Keep" : [ "StudyInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3569 Run(False, { "Keep" : [ "SeriesInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3570 Run(False, { "Keep" : [ "SOPInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3571 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3572 Run(False, { "Replace" : { "StudyInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3573 Run(False, { "Replace" : { "SeriesInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3574 Run(False, { "Replace" : { "SOPInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3575 |
120
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3576 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3577 def test_bitbucket_issue_56(self): |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3578 # Case-insensitive matching over accents. This test assumes |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3579 # that the "CaseSensitivePN" configuration option of Orthanc |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3580 # is set to "false" (default value). |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3581 # https://bitbucket.org/sjodogne/orthanc/issues/56 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3582 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3583 def Check(name, expected, expectedSensitive): |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3584 a = CallFindScu([ '-k', '0008,0005=ISO_IR 192', # Use UTF-8 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3585 '-k', '0008,0052=PATIENT', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3586 '-k', 'PatientName=%s' % name ]) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3587 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', a) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3588 self.assertEqual(expected, len(patientNames)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3589 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3590 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3591 'CaseSensitive' : False, |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3592 'Query' : { 'PatientName' : name }}) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3593 self.assertEqual(expected, len(a)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3594 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3595 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3596 'CaseSensitive' : True, |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3597 'Query' : { 'PatientName' : name }}) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3598 self.assertEqual(expectedSensitive, len(a)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3599 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3600 UploadInstance(_REMOTE, 'Encodings/Lena-latin1.dcm') |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3601 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3602 # WildcardConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3603 Check('TeSt*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3604 Check('TeSt-a*', 0, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3605 Check('TeSt-É*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3606 Check('TeSt-é*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3607 Check('Test-é*', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3608 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3609 # ListConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3610 Check('Test-éüäöò\\nope', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3611 Check('Test-ÉÜÄÖÒ\\nope', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3612 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3613 # ValueConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3614 Check('Test-éüäöò', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3615 Check('Test-ÉÜÄÖÒ', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3616 |
125 | 3617 |
3618 def test_gbk_alias(self): | |
3619 # https://groups.google.com/d/msg/orthanc-users/WMM8LMbjpUc/02-1f_yFCgAJ | |
3620 # This test fails on Orthanc <= 1.3.0 | |
3621 i = UploadInstance(_REMOTE, '2017-09-19-GBK-Tumashu.dcm')['ID'] | |
3622 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
3623 self.assertEqual(tags['PatientName'], u'徐浩凯') | |
3624 self.assertEqual(tags['InstitutionName'], u'灌云县疾病预防控制中心') | |
126 | 3625 |
3626 | |
3627 def test_long_tag(self): | |
3628 i = UploadInstance(_REMOTE, 'DummyCTWithLongTag.dcm')['ID'] | |
3629 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
3630 | |
3631 tags = DoGet(_REMOTE, '/instances/%s/tags' % i) | |
3632 self.assertTrue('0018,1020' in tags) | |
3633 self.assertEqual('SoftwareVersions', tags['0018,1020']['Name']) | |
3634 self.assertEqual('TooLong', tags['0018,1020']['Type']) | |
3635 self.assertEqual(None, tags['0018,1020']['Value']) | |
3636 | |
3637 tags = DoGet(_REMOTE, '/instances/%s/tags?ignore-length=0018-1020' % i) | |
3638 self.assertTrue('0018,1020' in tags) | |
3639 self.assertEqual('SoftwareVersions', tags['0018,1020']['Name']) | |
3640 self.assertEqual('String', tags['0018,1020']['Type']) | |
3641 self.assertTrue(tags['0018,1020']['Value'].startswith('Lorem ipsum dolor sit amet')) | |
3642 | |
3643 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
3644 self.assertTrue('SoftwareVersions' in tags) | |
3645 self.assertEqual(None, tags['SoftwareVersions']) | |
3646 self.assertTrue('HeartRate' in tags) | |
3647 self.assertEqual(474, int(tags['HeartRate'])) | |
3648 | |
3649 tags = DoGet(_REMOTE, '/instances/%s/simplified-tags' % i) | |
3650 self.assertTrue('SoftwareVersions' in tags) | |
3651 self.assertEqual(None, tags['SoftwareVersions']) | |
3652 | |
3653 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify&ignore-length=0018-1020' % i) | |
3654 self.assertTrue('SoftwareVersions' in tags) | |
3655 self.assertTrue(tags['SoftwareVersions'].startswith('Lorem ipsum dolor sit amet')) | |
3656 | |
3657 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify&ignore-length=SoftwareVersions' % i) | |
3658 self.assertTrue('SoftwareVersions' in tags) | |
3659 self.assertTrue(tags['SoftwareVersions'].startswith('Lorem ipsum dolor sit amet')) | |
3660 | |
3661 tags = DoGet(_REMOTE, '/series/%s/instances-tags' % series) | |
3662 self.assertEqual(1, len(tags)) | |
3663 self.assertTrue(i in tags.keys()) | |
3664 self.assertTrue('0018,1020' in tags[i]) | |
3665 self.assertEqual('TooLong', tags[i]['0018,1020']['Type']) | |
3666 | |
3667 tags = DoGet(_REMOTE, '/series/%s/instances-tags?ignore-length=SoftwareVersions' % series) | |
3668 self.assertEqual(1, len(tags)) | |
3669 self.assertTrue(i in tags.keys()) | |
3670 self.assertTrue('0018,1020' in tags[i]) | |
3671 self.assertEqual('String', tags[i]['0018,1020']['Type']) | |
3672 self.assertTrue(tags[i]['0018,1020']['Value'].startswith('Lorem ipsum dolor sit amet')) | |
3673 | |
127
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3674 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3675 def test_extended_media(self): |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3676 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3677 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3678 z = GetArchive(_REMOTE, '/patients/%s/media?extended' % DoGet(_REMOTE, '/patients')[0]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3679 self.assertEqual(2, len(z.namelist())) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3680 self.assertTrue('IMAGES/IM0' in z.namelist()) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3681 self.assertTrue('DICOMDIR' in z.namelist()) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3682 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3683 try: |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3684 os.remove('/tmp/DICOMDIR') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3685 except: |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3686 # The file does not exist |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3687 pass |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3688 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3689 z.extract('DICOMDIR', '/tmp') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3690 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3691 stderr = subprocess.STDOUT).split('\n') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3692 self.assertEqual(5, len(a)) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3693 self.assertTrue(a[0].startswith('Warning')) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3694 self.assertEqual('BasicDirectory', a[1]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3695 self.assertTrue('not present in standard DICOM IOD' in a[2]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3696 self.assertTrue('not present in standard DICOM IOD' in a[3]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3697 self.assertEqual('', a[4]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3698 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3699 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3700 stderr = subprocess.STDOUT).split('\n') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3701 self.assertEqual(1, len(a)) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3702 self.assertEqual('', a[0]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3703 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3704 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3705 self.assertTrue(re.search('1.3.46.670589.11.17521.5.0.3124.2008081908590448738', a) != None) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3706 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3707 # Check the presence of the series description (extended tag) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3708 self.assertTrue(re.search('T1W_aTSE', a) != None) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3709 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3710 os.remove('/tmp/DICOMDIR') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3711 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3712 |
132
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3713 def test_anonymize_relationships_1(self): |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3714 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3715 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
132
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3716 study = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3717 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3718 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3719 '{}', |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3720 'application/json')['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3721 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3722 a = DoGet(_REMOTE, '/studies/%s/instances' % study) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3723 self.assertEqual(2, len(a)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3724 a1 = a[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3725 a2 = a[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3726 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3727 b = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3728 self.assertEqual(2, len(b)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3729 b1 = b[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3730 b2 = b[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3731 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3732 SEQUENCE = '/instances/%s/content/ReferencedImageSequence' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3733 SOP = '/instances/%s/content/ReferencedImageSequence/%d/ReferencedSOPInstanceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3734 CLASS = '/instances/%s/content/ReferencedImageSequence/%d/ReferencedSOPClassUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3735 FRAME = '/instances/%s/content/FrameOfReferenceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3736 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3737 self.assertEqual(DoGet(_REMOTE, FRAME % a1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3738 DoGet(_REMOTE, FRAME % a2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3739 self.assertEqual(DoGet(_REMOTE, FRAME % b1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3740 DoGet(_REMOTE, FRAME % b2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3741 self.assertNotEqual(DoGet(_REMOTE, FRAME % a1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3742 DoGet(_REMOTE, FRAME % b1)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3743 self.assertNotEqual(DoGet(_REMOTE, FRAME % a2), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3744 DoGet(_REMOTE, FRAME % b2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3745 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3746 self.assertEqual(3, len(DoGet(_REMOTE, SEQUENCE % a1))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3747 self.assertEqual(3, len(DoGet(_REMOTE, SEQUENCE % a2))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3748 self.assertEqual(3, len(DoGet(_REMOTE, SEQUENCE % b1))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3749 self.assertEqual(3, len(DoGet(_REMOTE, SEQUENCE % b2))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3750 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3751 for i in range(3): |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3752 self.assertEqual(DoGet(_REMOTE, SOP % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3753 DoGet(_REMOTE, SOP % (a2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3754 self.assertEqual(DoGet(_REMOTE, SOP % (b1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3755 DoGet(_REMOTE, SOP % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3756 self.assertNotEqual(DoGet(_REMOTE, SOP % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3757 DoGet(_REMOTE, SOP % (b1, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3758 self.assertNotEqual(DoGet(_REMOTE, SOP % (a2, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3759 DoGet(_REMOTE, SOP % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3760 self.assertEqual(DoGet(_REMOTE, CLASS % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3761 DoGet(_REMOTE, CLASS % (b1, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3762 self.assertEqual(DoGet(_REMOTE, CLASS % (a2, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3763 DoGet(_REMOTE, CLASS % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3764 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3765 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3766 def test_anonymize_relationships_2(self): |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3767 UploadInstance(_REMOTE, 'Comunix/Ct/IM-0001-0001.dcm') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3768 UploadInstance(_REMOTE, 'Comunix/Ct/IM-0001-0002.dcm') |
132
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3769 study = '6c65289b-db2fcb71-7eaf73f4-8e12470c-a4d6d7cf' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3770 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3771 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3772 '{}', |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3773 'application/json')['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3774 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3775 a = DoGet(_REMOTE, '/studies/%s/instances' % study) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3776 self.assertEqual(2, len(a)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3777 a1 = a[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3778 a2 = a[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3779 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3780 b = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3781 self.assertEqual(2, len(b)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3782 b1 = b[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3783 b2 = b[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3784 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3785 SEQUENCE = '/instances/%s/content/SourceImageSequence' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3786 SOP = '/instances/%s/content/SourceImageSequence/%d/ReferencedSOPInstanceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3787 CLASS = '/instances/%s/content/SourceImageSequence/%d/ReferencedSOPClassUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3788 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3789 self.assertEqual(1, len(DoGet(_REMOTE, SEQUENCE % a1))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3790 self.assertEqual(1, len(DoGet(_REMOTE, SEQUENCE % a2))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3791 self.assertEqual(1, len(DoGet(_REMOTE, SEQUENCE % b1))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3792 self.assertEqual(1, len(DoGet(_REMOTE, SEQUENCE % b2))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3793 self.assertEqual(DoGet(_REMOTE, SOP % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3794 DoGet(_REMOTE, SOP % (a2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3795 self.assertEqual(DoGet(_REMOTE, SOP % (b1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3796 DoGet(_REMOTE, SOP % (b2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3797 self.assertNotEqual(DoGet(_REMOTE, SOP % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3798 DoGet(_REMOTE, SOP % (b1, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3799 self.assertNotEqual(DoGet(_REMOTE, SOP % (a2, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3800 DoGet(_REMOTE, SOP % (b2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3801 self.assertEqual(DoGet(_REMOTE, CLASS % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3802 DoGet(_REMOTE, CLASS % (b1, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3803 self.assertEqual(DoGet(_REMOTE, CLASS % (a2, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3804 DoGet(_REMOTE, CLASS % (b2, 0))) |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3805 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3806 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3807 def test_anonymize_relationships_3(self): |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3808 sr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/StructuredReports/IM0')['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3809 mr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/StructuredReports/IM631')['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3810 study = 'ef351eb2-c1147229-062736b8-35a151e3-e32d526b' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3811 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3812 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3813 { "Keep" : [ "ContentSequence" ] }) ['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3814 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3815 a = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3816 self.assertEqual(2, len(a)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3817 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3818 if DoGet(_REMOTE, '/instances/%s/content/Modality' % a[0]['ID']) == 'SR': |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3819 sr2 = a[0]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3820 mr2 = a[1]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3821 else: |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3822 sr2 = a[1]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3823 mr2 = a[0]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3824 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3825 self.assertEqual(DoGet(_REMOTE, '/instances/%s/content/Modality' % sr1), |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3826 DoGet(_REMOTE, '/instances/%s/content/Modality' % sr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3827 self.assertEqual(DoGet(_REMOTE, '/instances/%s/content/Modality' % mr1), |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3828 DoGet(_REMOTE, '/instances/%s/content/Modality' % mr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3829 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3830 mrUid1 = DoGet(_REMOTE, '/instances/%s' % mr1)['MainDicomTags']['SOPInstanceUID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3831 mrUid2 = DoGet(_REMOTE, '/instances/%s' % mr2)['MainDicomTags']['SOPInstanceUID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3832 mrSeries1 = DoGet(_REMOTE, '/instances/%s/content/SeriesInstanceUID' % mr1).strip('\x00') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3833 mrSeries2 = DoGet(_REMOTE, '/instances/%s/content/SeriesInstanceUID' % mr2).strip('\x00') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3834 mrStudy1 = DoGet(_REMOTE, '/instances/%s/content/StudyInstanceUID' % mr1).strip('\x00') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3835 mrStudy2 = DoGet(_REMOTE, '/instances/%s/content/StudyInstanceUID' % mr2).strip('\x00') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3836 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3837 PATH1 = '/instances/%s/content/CurrentRequestedProcedureEvidenceSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3838 PATH2 = PATH1 + '/0/ReferencedSeriesSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3839 PATH3 = PATH2 + '/0/ReferencedSOPSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3840 PATH4 = PATH3 + '/0/ReferencedSOPInstanceUID' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3841 PATH5 = PATH3 + '/0/ReferencedSOPClassUID' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3842 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3843 self.assertEqual(1, len(DoGet(_REMOTE, PATH1 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3844 self.assertEqual(1, len(DoGet(_REMOTE, PATH2 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3845 self.assertEqual(1, len(DoGet(_REMOTE, PATH3 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3846 self.assertEqual(DoGet(_REMOTE, PATH4 % sr1), mrUid1) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3847 self.assertEqual(mrSeries1, DoGet(_REMOTE, (PATH2 + '/0/SeriesInstanceUID') % sr1).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3848 self.assertEqual(mrStudy1, DoGet(_REMOTE, (PATH1 + '/0/StudyInstanceUID') % sr1).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3849 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3850 self.assertEqual(1, len(DoGet(_REMOTE, PATH1 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3851 self.assertEqual(1, len(DoGet(_REMOTE, PATH2 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3852 self.assertEqual(1, len(DoGet(_REMOTE, PATH3 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3853 self.assertEqual(DoGet(_REMOTE, PATH5 % sr1), DoGet(_REMOTE, PATH5 % sr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3854 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3855 self.assertEqual(mrUid2, DoGet(_REMOTE, PATH4 % sr2).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3856 self.assertEqual(mrSeries2, DoGet(_REMOTE, (PATH2 + '/0/SeriesInstanceUID') % sr2).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3857 self.assertEqual(mrStudy2, DoGet(_REMOTE, (PATH1 + '/0/StudyInstanceUID') % sr2).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3858 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3859 content1 = DoGet(_REMOTE, '/instances/%s/tags?simplify' % sr1) ['ContentSequence'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3860 content2 = DoGet(_REMOTE, '/instances/%s/tags?simplify' % sr2) ['ContentSequence'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3861 self.assertEqual(str(content1), str(content2)) |
141
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3862 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3863 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3864 def test_bitbucket_issue_94(self): |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3865 # "a simple instance modification should not modify FrameOfReferenceUID + ..." |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3866 # https://bitbucket.org/sjodogne/orthanc/issues/94 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3867 i = UploadInstance(_REMOTE, 'Issue94.dcm')['ID'] |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3868 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3869 source = DoGet(_REMOTE, '/instances/%s/attachments/dicom/data' % i) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3870 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3871 modified = DoPost(_REMOTE, '/instances/%s/modify' % i, |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3872 { "Replace" : {"PatientID" : "toto"}, "Force": True}) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3873 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3874 anonymized = DoPost(_REMOTE, '/instances/%s/anonymize' % i) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3875 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3876 a = ExtractDicomTags(source, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3877 self.assertEqual(1, len(a)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3878 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3879 b = ExtractDicomTags(modified, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3880 self.assertEqual(1, len(b)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3881 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3882 c = ExtractDicomTags(anonymized, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3883 self.assertEqual(1, len(c)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3884 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3885 self.assertEqual(a, b) # Modified DICOM |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3886 self.assertNotEqual(a, c) # Anonymized DICOM |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3887 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3888 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3889 def test_metadata_origin(self): |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3890 # Upload using the REST API |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3891 i = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3892 self.assertEqual('RestApi', DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3893 self.assertEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3894 self.assertNotEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteIP' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3895 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/metadata/CalledAET' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3896 self.assertEqual('alice', DoGet(_REMOTE, '/instances/%s/metadata/HttpUsername' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3897 |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3898 m = DoGet(_REMOTE, '/instances/%s/metadata?expand' % i) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3899 self.assertEqual('RestApi', m['Origin']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3900 self.assertEqual('', m['RemoteAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3901 self.assertNotEqual('', m['RemoteIP']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3902 self.assertFalse('CalledAET' in m) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3903 self.assertEqual('alice', m['HttpUsername']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3904 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3905 self.assertEqual('1.2.840.10008.1.2.4.91', m['TransferSyntax']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3906 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', m['SopClassUid']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3907 self.assertEqual('1', m['IndexInSeries']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3908 self.assertTrue('ReceptionDate' in m) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3909 |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3910 DoDelete(_REMOTE, '/instances/%s' % i) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3911 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3912 # Upload using the DICOM protocol |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3913 subprocess.check_call([ FindExecutable('storescu'), |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3914 _REMOTE['Server'], str(_REMOTE['DicomPort']), |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3915 GetDatabasePath('Knee/T1/IM-0001-0001.dcm'), |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3916 '-xw' ]) # Propose JPEG2000 |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3917 self.assertEqual('DicomProtocol', DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3918 self.assertEqual('STORESCU', DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3919 self.assertNotEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteIP' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3920 self.assertEqual('ANY-SCP', DoGet(_REMOTE, '/instances/%s/metadata/CalledAET' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3921 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/metadata/HttpUsername' % i)) |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3922 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3923 m = DoGet(_REMOTE, '/instances/%s/metadata?expand' % i) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3924 self.assertEqual('DicomProtocol', m['Origin']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3925 self.assertEqual('STORESCU', m['RemoteAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3926 self.assertNotEqual('', m['RemoteIP']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3927 self.assertEqual('ANY-SCP', m['CalledAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3928 self.assertFalse('HttpUsername' in m) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3929 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3930 self.assertEqual('1.2.840.10008.1.2.4.91', m['TransferSyntax']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3931 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', m['SopClassUid']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3932 self.assertEqual('1', m['IndexInSeries']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3933 self.assertTrue('ReceptionDate' in m) |
147 | 3934 |
3935 | |
3936 def test_lua_deadlock(self): | |
3937 # Rana Asim Wajid (2018-07-14): "It does seem that the issue | |
3938 # is with the lua script I'm using for conversion of images to | |
3939 # JPEG2000. When the script is used with 1.4.0 the first | |
3940 # instance appears to be stored and then everything just | |
3941 # halts, ie Orthanc wont respond to anything after that." | |
3942 # https://groups.google.com/d/msg/orthanc-users/Rc-Beb42xc8/JUgdzrmCAgAJ | |
174 | 3943 InstallLuaScriptFromPath(_REMOTE, 'Lua/Jpeg2000Conversion.lua') |
147 | 3944 |
3945 subprocess.check_call([ FindExecutable('storescu'), | |
3946 _REMOTE['Server'], str(_REMOTE['DicomPort']), | |
3947 GetDatabasePath('Brainix/Flair/IM-0001-0001.dcm'), | |
3948 GetDatabasePath('Brainix/Flair/IM-0001-0002.dcm'), | |
3949 ]) | |
3950 | |
3951 instances = DoGet(_REMOTE, '/instances') | |
3952 self.assertEqual(2, len(instances)) | |
3953 | |
3954 t1 = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % instances[0]) | |
3955 t2 = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % instances[1]) | |
175 | 3956 self.assertEqual('1.2.840.10008.1.2.4.90', t1) # this will fail if libgdcm-tools is not installed |
147 | 3957 self.assertEqual(t1, t2); |
154
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3958 |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3959 |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3960 def test_find_group_length(self): |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3961 # Orthanc <= 1.4.1 fails to answer C-FIND queries that contain |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3962 # one of the Generic Group Length tags (*, 0x0000) |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3963 a = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3964 result = CallFindScu([ '-k', '0008,0052=STUDY', '-k', '0008,0000=80' ]) |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3965 self.assertFalse('UnableToProcess' in result) |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3966 self.assertFalse('E:' in result) |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3967 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3968 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3969 def test_split(self): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3970 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3971 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3972 study = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3973 t1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3974 t2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3975 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3976 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3977 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3978 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3979 info = DoGet(_REMOTE, '/studies/%s' % study) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3980 self.assertTrue('ReferringPhysicianName' in info['MainDicomTags']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3981 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3982 job = MonitorJob2(_REMOTE, lambda: DoPost |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3983 (_REMOTE, '/studies/%s/split' % study, { |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3984 'Series' : [ t2 ], |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3985 'Replace' : { 'PatientName' : 'Hello' }, |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3986 'Remove' : [ 'ReferringPhysicianName' ], |
181 | 3987 'KeepSource' : False, |
3988 'Asynchronous' : True | |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3989 })) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3990 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3991 self.assertNotEqual(None, job) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3992 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3993 studies = set(DoGet(_REMOTE, '/studies')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3994 self.assertEqual(2, len(studies)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3995 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3996 series = set(DoGet(_REMOTE, '/series')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3997 self.assertEqual(2, len(series)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3998 self.assertTrue(t1 in series) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3999 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4000 study2 = DoGet(_REMOTE, '/jobs/%s' % job)['Content']['TargetStudy'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4001 self.assertTrue(study in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4002 self.assertTrue(study2 in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4003 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4004 info = DoGet(_REMOTE, '/studies/%s' % study2) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4005 self.assertTrue('Hello', info['PatientMainDicomTags']['PatientName']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4006 self.assertFalse('ReferringPhysicianName' in info['MainDicomTags']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4007 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4008 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4009 def test_merge(self): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4010 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4011 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4012 knee = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4013 t1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4014 brainix = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4015 flair = '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4016 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4017 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4018 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4019 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4020 job = MonitorJob2(_REMOTE, lambda: DoPost |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4021 (_REMOTE, '/studies/%s/merge' % knee, { |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4022 'Resources' : [ brainix ], |
181 | 4023 'KeepSource' : True, |
4024 'Synchronous' : False | |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4025 })) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4026 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4027 self.assertNotEqual(None, job) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4028 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4029 studies = set(DoGet(_REMOTE, '/studies')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4030 self.assertEqual(2, len(studies)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4031 self.assertTrue(knee in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4032 self.assertTrue(brainix in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4033 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4034 series = set(DoGet(_REMOTE, '/studies/%s' % knee)['Series']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4035 self.assertTrue(t1 in series) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4036 series.remove(t1) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4037 self.assertEqual(1, len(series)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4038 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4039 instances = DoGet(_REMOTE, '/series/%s' % list(series)[0])['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4040 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4041 merged = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4042 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4043 instances = DoGet(_REMOTE, '/series/%s' % t1)['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4044 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4045 a = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4046 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4047 instances = DoGet(_REMOTE, '/series/%s' % flair)['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4048 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4049 b = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4050 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4051 tags = DoGet(_REMOTE, '/studies/%s' % knee) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4052 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4053 for key in tags['PatientMainDicomTags']: |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4054 self.assertEqual(a[key], merged[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4055 if (key in b and key != 'PatientSex'): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4056 self.assertNotEqual(a[key], b[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4057 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4058 for key in tags['MainDicomTags']: |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4059 # Not in the patient/study module |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4060 if (not key in [ 'InstitutionName', |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4061 'RequestingPhysician', |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4062 'RequestedProcedureDescription', ]): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4063 self.assertEqual(a[key], merged[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4064 if (key in b): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4065 self.assertNotEqual(a[key], b[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4066 |
187 | 4067 |
4068 def test_async_archive(self): | |
4069 # Testing the asynchronous generation of archives/medias (new | |
4070 # in Orthanc 1.4.3) | |
4071 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
4072 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
4073 | |
4074 kneeT1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
4075 kneeT2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
4076 | |
4077 job = MonitorJob2(_REMOTE, lambda: DoPost | |
4078 (_REMOTE, '/studies/%s/archive' % kneeT1, { | |
4079 'Synchronous' : False | |
4080 })) | |
4081 | |
4082 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4083 self.assertEqual(1, len(z.namelist())) | |
4084 self.assertFalse('DICOMDIR' in z.namelist()) | |
4085 | |
4086 job2 = MonitorJob2(_REMOTE, lambda: DoPost | |
4087 (_REMOTE, '/studies/%s/media' % kneeT1, { | |
4088 'Synchronous' : False | |
4089 })) | |
4090 | |
4091 # The archive from the first job has been replaced by the | |
4092 # archive from second job (as MediaArchiveSize == 1) | |
4093 self.assertRaises(Exception, lambda: GetArchive(_REMOTE, '/jobs/%s/archive' % job)) | |
4094 | |
4095 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job2) | |
4096 self.assertEqual(2, len(z.namelist())) | |
4097 self.assertTrue('DICOMDIR' in z.namelist()) | |
4098 | |
4099 job = MonitorJob2(_REMOTE, lambda: DoPost | |
4100 (_REMOTE, '/tools/create-archive', { | |
4101 'Synchronous' : False, | |
4102 'Resources' : [ kneeT1, kneeT2 ], | |
4103 })) | |
4104 | |
4105 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4106 self.assertEqual(2, len(z.namelist())) | |
4107 self.assertFalse('DICOMDIR' in z.namelist()) | |
4108 | |
4109 job = MonitorJob2(_REMOTE, lambda: DoPost | |
4110 (_REMOTE, '/tools/create-media', { | |
4111 'Synchronous' : False, | |
4112 'Resources' : [ kneeT1, kneeT2 ], | |
4113 })) | |
4114 | |
4115 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4116 self.assertEqual(3, len(z.namelist())) | |
4117 self.assertTrue('DICOMDIR' in z.namelist()) | |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4118 |
187 | 4119 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4120 def test_queries_hierarchy(self): |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4121 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4122 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4123 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4124 tags = { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4125 'NumberOfPatientRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4126 'NumberOfPatientRelatedSeries' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4127 'NumberOfPatientRelatedStudies' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4128 'NumberOfStudyRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4129 'NumberOfStudyRelatedSeries' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4130 'NumberOfSeriesRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4131 } |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4132 |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4133 tags2 = copy.copy(tags) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4134 tags2['PatientID'] = '887' # Only consider the "Knee" patient |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4135 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4136 patient = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4137 'Level' : 'Patient', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4138 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4139 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4140 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4141 study = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4142 'Level' : 'Study', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4143 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4144 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4145 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4146 series = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4147 'Level' : 'Series', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4148 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4149 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4150 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4151 instance = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4152 'Level' : 'Instance', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4153 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4154 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4155 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4156 p = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % patient) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4157 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4158 self.assertEqual('887', p[0]['PatientID']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4159 self.assertEqual('1', p[0]['NumberOfPatientRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4160 self.assertEqual('1', p[0]['NumberOfPatientRelatedSeries']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4161 self.assertEqual('1', p[0]['NumberOfPatientRelatedStudies']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4162 self.assertFalse('NumberOfStudyRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4163 self.assertFalse('NumberOfStudyRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4164 self.assertFalse('NumberOfSeriesRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4165 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4166 p = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % study) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4167 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4168 self.assertEqual('2.16.840.1.113669.632.20.121711.10000160881', p[0]['StudyInstanceUID']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4169 self.assertEqual('1', p[0]['NumberOfStudyRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4170 self.assertEqual('1', p[0]['NumberOfStudyRelatedSeries']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4171 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4172 self.assertFalse('NumberOfPatientRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4173 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4174 self.assertFalse('NumberOfSeriesRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4175 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4176 p = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % series) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4177 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4178 self.assertEqual('1.3.46.670589.11.17521.5.0.3124.2008081908564160709', p[0]['SeriesInstanceUID']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4179 self.assertEqual('1', p[0]['NumberOfSeriesRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4180 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4181 self.assertFalse('NumberOfPatientRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4182 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4183 self.assertFalse('NumberOfStudyRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4184 self.assertFalse('NumberOfStudyRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4185 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4186 p = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4187 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4188 self.assertEqual('1.3.46.670589.11.17521.5.0.3124.2008081908590448738', p[0]['SOPInstanceUID']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4189 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4190 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-studies' % patient, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4191 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4192 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4193 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % study)) |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4194 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4195 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-series' % patient, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4196 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4197 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4198 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % series)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4199 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4200 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-instances' % patient, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4201 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4202 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4203 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4204 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4205 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-series' % study, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4206 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4207 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4208 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % series)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4209 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4210 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-instances' % study, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4211 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4212 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4213 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4214 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4215 j = DoPost(_REMOTE, '/queries/%s/answers/0/query-instances' % series, |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4216 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4217 self.assertEqual(DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % j), |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4218 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4219 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4220 |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4221 def test_dicom_disk_size(self): |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4222 dicomSize = 0 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4223 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4224 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4225 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4226 for i in range(2): |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4227 p = 'Knee/T%d/IM-0001-0001.dcm' % (i + 1) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4228 UploadInstance(_REMOTE, p) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4229 dicomSize += os.path.getsize(GetDatabasePath(p)) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4230 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4231 s = DoGet(_REMOTE, '/patients/ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17/statistics') # Consider Knee patient |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4232 self.assertEqual(2, s['CountInstances']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4233 self.assertEqual(2, s['CountSeries']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4234 self.assertEqual(1, s['CountStudies']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4235 self.assertEqual(dicomSize, int(s['DicomDiskSize'])) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4236 self.assertEqual(dicomSize, int(s['DicomUncompressedSize'])) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4237 self.assertLess(dicomSize, int(s['UncompressedSize'])) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4238 self.assertEqual(s['UncompressedSize'], s['DiskSize']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4239 |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4240 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4241 def test_changes_2(self): |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4242 # More consistent behavior since Orthanc 1.5.2 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4243 # https://groups.google.com/d/msg/orthanc-users/QhzB6vxYeZ0/YxabgqpfBAAJ |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4244 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4245 # Make sure that this is not the first change |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4246 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4247 a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4248 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4249 DoDelete(_REMOTE, '/instances/%s' % a) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4250 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4251 # No more instance, but there were previous changes |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4252 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4253 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4254 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4255 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4256 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4257 seq = c['Last'] |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4258 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4259 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4260 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4261 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4262 self.assertEqual(seq, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4263 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4264 c = DoGet(_REMOTE, '/changes?since=%d' % (seq + 1000)) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4265 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4266 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4267 self.assertEqual(seq, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4268 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4269 # Add one instance |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4270 UploadInstance(_REMOTE, 'DummyCT.dcm') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4271 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4272 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4273 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4274 self.assertEqual(4, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4275 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4276 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4277 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4278 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4279 self.assertEqual(1, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4280 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4281 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4282 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4283 c = DoGet(_REMOTE, '/changes?since=%d' % (seq + 1000)) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4284 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4285 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4286 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4287 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4288 # Remove the uploaded instance |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4289 DoDelete(_REMOTE, '/instances/%s' % a) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4290 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4291 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4292 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4293 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4294 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4295 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4296 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4297 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4298 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4299 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4300 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4301 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4302 c = DoGet(_REMOTE, '/changes?since=%d' % (seq + 1000)) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4303 self.assertEqual(0, len(c['Changes'])) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4304 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4305 self.assertEqual(seq + 4, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4306 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4307 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4308 def test_bitbucket_issue_124(self): |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4309 a = UploadInstance(_REMOTE, 'Issue124.dcm')['ID'] |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4310 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4311 z = GetArchive(_REMOTE, '/patients/%s/media' % a) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4312 self.assertEqual(2, len(z.namelist())) |
207
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4313 |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4314 |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4315 def test_invalid_findscp(self): |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4316 UploadInstance(_REMOTE, 'DummyCT.dcm') |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4317 findscu = CallFindScu([ '-S', '-k', '8,52=IMAGE', '-k', '8,16', '-k', '2,2' ]) |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4318 self.assertEqual(0, len(re.findall('\(0002,0002\)', findscu))) |
208
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4319 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4320 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4321 def test_bitbucket_issue_90(self): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4322 def CountDicomResults(sex): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4323 a = CallFindScu([ '-S', '-k', '8,52=STUDY', '-k', sex ]) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4324 return len(re.findall('\(0010,0040\)', a)) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4325 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4326 def CountRestResults(sex): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4327 a = DoPost(_REMOTE, '/tools/find', |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4328 { 'Level' : 'Study', 'Query' : { 'PatientSex' : sex } }) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4329 return len(a) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4330 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4331 # Just like the "CR000000.dcm" of the issue, the test image |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4332 # "DummyCT.dcm" has the tag PatientSex (0010,0040) unset |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4333 UploadInstance(_REMOTE, 'DummyCT.dcm') |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4334 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4335 # Test that the behavior of DICOM vs. REST API is consistent on missing tags |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4336 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4337 # In wildcard constraints, the patient sex must be set for a match to occur |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4338 self.assertEqual(0, CountDicomResults('PatientSex=*')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4339 self.assertEqual(0, CountRestResults('*')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4340 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4341 # In single-valued constraints, the patient sex must be set |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4342 self.assertEqual(0, CountDicomResults('PatientSex=F')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4343 self.assertEqual(0, CountDicomResults('PatientSex=M')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4344 self.assertEqual(0, CountRestResults('F')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4345 self.assertEqual(0, CountRestResults('M')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4346 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4347 # Empty constraints are only used to ask the actual value of |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4348 # the tag to be added to the *answer*. The tag should not used |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4349 # as a filter in such a situation. |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4350 self.assertEqual(1, CountDicomResults('PatientSex')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4351 self.assertEqual(1, CountDicomResults('PatientSex=')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4352 self.assertEqual(1, CountRestResults('')) # This check fails on Orthanc <= 1.5.2 (issue 90) |
210
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4353 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4354 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4355 def test_rest_modalities_in_study(self): |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4356 # Tests a regression that is present in Orthanc 1.5.2 and 1.5.3 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4357 # https://groups.google.com/d/msg/orthanc-users/7lZyG3wpx-M/uOXzAzVCFwAJ |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4358 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4359 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4360 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4361 'Query' : { 'ModalitiesInStudy' : 'US' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4362 self.assertEqual(0, len(a)) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4363 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4364 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4365 'Query' : { 'ModalitiesInStudy' : 'US\\CT' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4366 self.assertEqual(1, len(a)) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4367 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4368 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4369 'Query' : { 'ModalitiesInStudy' : 'CT' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4370 self.assertEqual(1, len(a)) |
211 | 4371 |
4372 | |
4373 def test_series_status(self): | |
4374 def HasCompletedInChanges(): | |
4375 for c in DoGet(_REMOTE, '/changes?limit=1000&since=0')['Changes']: | |
4376 if c['ChangeType'] == 'CompletedSeries': | |
4377 return True; | |
4378 | |
4379 return False | |
4380 | |
4381 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm') | |
4382 series = '8ea120d7-5057d919-837dfbcc-ccd04e0f-7f3a94aa' | |
4383 self.assertEqual('Unknown', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4384 self.assertFalse(HasCompletedInChanges()) | |
4385 | |
4386 series = 'ce25ecb6-ed79d004-5ae43ca7-3fc89bc5-67511614' | |
4387 | |
4388 for i in range(3): | |
4389 UploadInstance(_REMOTE, 'Series/Lena-%d.dcm' % (i + 1)) | |
4390 self.assertEqual('Missing', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4391 self.assertFalse(HasCompletedInChanges()) | |
4392 | |
4393 UploadInstance(_REMOTE, 'Series/Lena-4.dcm') | |
4394 self.assertEqual('Complete', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4395 self.assertTrue(HasCompletedInChanges()) | |
4396 | |
4397 DoDelete(_REMOTE, '/changes') | |
4398 self.assertFalse(HasCompletedInChanges()) | |
4399 | |
4400 UploadInstance(_REMOTE, 'Series/Lena-5.dcm') | |
4401 self.assertEqual('Inconsistent', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4402 self.assertFalse(HasCompletedInChanges()) | |
4403 |