Mercurial > hg > orthanc-tests
annotate Tests/Tests.py @ 213:eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
author | amazy |
---|---|
date | Tue, 05 Feb 2019 11:26:58 +0100 |
parents | a05cc24f84e5 |
children | 13fa120c54a0 |
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 |
213
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
393 def test_delete_cascade(self): |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
394 # make sure deleting the last instance of a study deletes the series, study and patient |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
395 |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
396 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) # make sure orthanc is empty when starting the test |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
397 a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
398 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
399 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
400 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
401 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
402 |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
403 DoDelete(_REMOTE, '/instances/%s' % a) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
404 |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
405 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
406 self.assertEqual(0, len(DoGet(_REMOTE, '/series'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
407 self.assertEqual(0, len(DoGet(_REMOTE, '/studies'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
408 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
409 |
7 | 410 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
411 def test_multiframe(self): |
7 | 412 i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] |
413 self.assertEqual(76, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
414 | |
415 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % i) | |
416 self.assertEqual("L", im.mode) | |
417 self.assertEqual(512, im.size[0]) | |
418 self.assertEqual(512, im.size[1]) | |
419 | |
420 DoGet(_REMOTE, '/instances/%s/frames/0/image-uint8' % i) | |
421 DoGet(_REMOTE, '/instances/%s/frames/0/image-uint16' % i) | |
422 DoGet(_REMOTE, '/instances/%s/frames/75/preview' % i) | |
423 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/aaa/preview' % i)) | |
424 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/76/preview' % i)) | |
425 | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
426 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
427 def test_changes(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
428 # Check emptiness |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
429 c = DoGet(_REMOTE, '/changes') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
430 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
|
431 #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
|
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?last') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
434 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
|
435 #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
|
436 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
437 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
438 # Add 1 instance |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
439 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
|
440 c = DoGet(_REMOTE, '/changes') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
441 begin = c['Last'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
442 self.assertEqual(4, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
443 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
444 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
|
445 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
446 c = DoGet(_REMOTE, '/changes?last') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
447 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
448 self.assertEqual(begin, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
449 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
450 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
|
451 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
452 self.assertEqual(begin, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
453 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
454 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
|
455 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
456 self.assertEqual(begin - 1, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
457 self.assertFalse(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
458 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
|
459 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
460 self.assertEqual(begin - 2, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
461 self.assertFalse(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
462 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
463 UploadFolder(_REMOTE, 'Knee/T1') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
464 UploadFolder(_REMOTE, 'Knee/T2') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
465 since = begin |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
466 countPatients = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
467 countStudies = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
468 countSeries = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
469 countInstances = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
470 completed = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
471 while True: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
472 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
|
473 since = c['Last'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
474 for i in c['Changes']: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
475 if i['ResourceType'] == 'Instance': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
476 countInstances += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
477 if i['ResourceType'] == 'Patient': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
478 countPatients += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
479 if i['ResourceType'] == 'Study': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
480 countStudies += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
481 if i['ResourceType'] == 'Series': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
482 countSeries += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
483 if i['ChangeType'] == 'NewInstance': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
484 countInstances += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
485 if i['ChangeType'] == 'NewPatient': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
486 countPatients += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
487 if i['ChangeType'] == 'NewStudy': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
488 countStudies += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
489 if i['ChangeType'] == 'NewSeries': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
490 countSeries += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
491 if i['ChangeType'] == 'CompletedSeries': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
492 completed += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
493 self.assertTrue('ID' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
494 self.assertTrue('Path' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
495 self.assertTrue('Seq' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
496 if c['Done']: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
497 break |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
498 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
499 self.assertEqual(2 * 50, countInstances) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
500 self.assertEqual(2 * 1, countPatients) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
501 self.assertEqual(2 * 1, countStudies) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
502 self.assertEqual(2 * 2, countSeries) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
503 self.assertEqual(0, completed) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
504 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
505 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
506 def test_archive(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
507 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
|
508 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') |
192 | 509 knee = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' |
510 | |
511 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
|
512 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
513 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
514 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
|
515 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
516 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
517 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
|
518 self.assertEqual(1, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
519 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
520 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
192 | 521 brainix = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' |
522 | |
523 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
|
524 self.assertEqual(2, len(z.namelist())) |
192 | 525 |
526 z = PostArchive(_REMOTE, '/tools/create-archive', { | |
527 'Resources' : [ brainix, knee ] | |
528 }) | |
529 self.assertEqual(3, len(z.namelist())) | |
530 | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
531 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
532 def test_media_archive(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
533 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
|
534 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
|
535 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
536 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
|
537 self.assertEqual(3, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
538 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
|
539 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
|
540 self.assertTrue('DICOMDIR' in z.namelist()) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
541 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
542 try: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
543 os.remove('/tmp/DICOMDIR') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
544 except: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
545 # The file does not exist |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
546 pass |
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 z.extract('DICOMDIR', '/tmp') |
45 | 549 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
|
550 stderr = subprocess.STDOUT).split('\n') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
551 self.assertEqual(3, len(a)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
552 self.assertTrue(a[0].startswith('Warning')) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
553 self.assertEqual('BasicDirectory', a[1]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
554 self.assertEqual('', a[2]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
555 |
45 | 556 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
|
557 stderr = subprocess.STDOUT).split('\n') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
558 self.assertEqual(1, len(a)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
559 self.assertEqual('', a[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
560 |
45 | 561 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
|
562 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
|
563 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
|
564 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
565 os.remove('/tmp/DICOMDIR') |
10 | 566 |
567 | |
568 def test_protection(self): | |
569 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
570 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
571 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
572 a = DoGet(_REMOTE, '/patients')[0] | |
573 b = DoGet(_REMOTE, '/patients')[1] | |
574 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
575 DoPut(_REMOTE, '/patients/%s/protected' % a, '0', 'text/plain') | |
576 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
577 DoPut(_REMOTE, '/patients/%s/protected' % a, '1', 'text/plain') | |
578 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
579 DoPut(_REMOTE, '/patients/%s/protected' % a, '0', 'text/plain') | |
580 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
581 | |
582 | |
12 | 583 def test_raw_tags(self): |
10 | 584 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
585 | |
586 dicom = DoGet(_REMOTE, '/instances/%s/file' % i) | |
587 self.assertEqual('1a7c56cb02d6e742cc9c856a8ac182e3', ComputeMD5(dicom)) | |
588 | |
589 s = '/instances/%s/content/' % i | |
590 | |
591 self.assertEqual('LOGIQBOOK', DoGet(_REMOTE, s + '0008-1010').strip()) | |
592 self.assertRaises(Exception, lambda: DoGet(_REMOTE, s + '0008-1011')) | |
593 | |
594 self.assertEqual('Abdomen', DoGet(_REMOTE, s + '7fe1-1001/0/7fe1-1008/0/7fe1-1057').strip()) | |
595 self.assertEqual('cla_3c', DoGet(_REMOTE, s + '7fe1-1001/0/7fe1-1008/8/7fe1-1057').strip()) | |
596 | |
597 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
598 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
599 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
600 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
601 | |
602 for i in DoGet(_REMOTE, '/instances'): | |
603 aid = DoGet(_REMOTE, '/instances/%s' % i)['MainDicomTags']['SOPInstanceUID'] | |
604 self.assertEqual(aid, DoGet(_REMOTE, '/instances/%s/content/0008-0018' % i).replace(chr(0), '')) | |
605 | |
606 | |
607 def test_raw_tags_mdn(self): | |
608 # Bug reported by Cyril Paulus | |
609 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
610 self.assertAlmostEqual(0.000027, DoGet(_REMOTE, '/instances/%s/content/7053-1000' % i)) | |
611 | |
612 | |
613 def test_modify_instance(self): | |
614 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] | |
615 modified = DoPost(_REMOTE, '/instances/%s/modify' % i, | |
616 json.dumps({ | |
617 "Replace" : { | |
618 "PatientName" : "hello", | |
619 #"PatientID" : "world" | |
620 }, | |
621 "Remove" : [ "StationName" ], | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
622 "RemovePrivateTags" : True |
10 | 623 }), |
624 'application/json') | |
625 j = DoPost(_REMOTE, '/instances', modified, 'application/dicom')['ID'] | |
626 | |
627 self.assertNotEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
628 #self.assertNotEqual('world', DoGet(_REMOTE, '/instances/%s/content/0010-0020' % i).strip()) | |
83 | 629 self.assertEqual('LOGIQBOOK', DoGet(_REMOTE, '/instances/%s/content/0008-1010' % i).strip()) |
10 | 630 DoGet(_REMOTE, '/instances/%s/content/6003-1010' % i) # Some private tag |
631 | |
632 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
633 #self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/0010-0020' % j).strip()) | |
634 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/0008-1010' % j)) | |
635 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/6003-1010' % j)) | |
636 | |
637 | |
638 def test_modify_series(self): | |
639 # Upload 4 images from the same series | |
640 for i in range(4): | |
641 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
642 | |
643 origSeries = DoGet(_REMOTE, '/series')[0] | |
644 newSeries = DoPost(_REMOTE, '/series/%s/modify' % origSeries, | |
645 '{"Replace":{"PatientName":"Jodogne"}}', | |
646 'application/json')['ID'] | |
647 | |
648 self.assertEqual(origSeries, DoGet(_REMOTE, '/series/%s' % newSeries)['ModifiedFrom']) | |
649 instances = DoGet(_REMOTE, '/series/%s' % newSeries)['Instances'] | |
650 self.assertEqual(4, len(instances)) | |
651 for i in instances: | |
652 j = DoGet(_REMOTE, '/instances/%s' % i)['ModifiedFrom'] | |
653 self.assertEqual(newSeries, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
654 self.assertEqual(origSeries, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
655 | |
656 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
657 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
658 | |
659 | |
660 def test_modify_study(self): | |
661 # Upload 4 images from the 2 series of the same study | |
662 for i in range(4): | |
663 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
664 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
665 | |
666 origStudy = DoGet(_REMOTE, '/studies')[0] | |
667 newStudy = DoPost(_REMOTE, '/studies/%s/modify' % origStudy, | |
668 '{"Replace":{"PatientName":"Jodogne"}}', | |
669 'application/json')['ID'] | |
670 | |
671 self.assertEqual(origStudy, DoGet(_REMOTE, '/studies/%s' % newStudy)['ModifiedFrom']) | |
672 series = DoGet(_REMOTE, '/studies/%s' % newStudy)['Series'] | |
673 self.assertEqual(2, len(series)) | |
674 for s in series: | |
675 ss = DoGet(_REMOTE, '/series/%s' % s)['ModifiedFrom'] | |
676 self.assertEqual(newStudy, DoGet(_REMOTE, '/series/%s' % s)['ParentStudy']) | |
677 self.assertEqual(origStudy, DoGet(_REMOTE, '/series/%s' % ss)['ParentStudy']) | |
678 | |
679 instances = DoGet(_REMOTE, '/series/%s' % s)['Instances'] | |
680 for i in instances: | |
681 j = DoGet(_REMOTE, '/instances/%s' % i)['ModifiedFrom'] | |
682 self.assertEqual(s, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
683 self.assertEqual(ss, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
684 | |
685 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
686 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
687 | |
688 | |
689 def test_anonymize_series(self): | |
690 # Upload 4 images from the same series | |
691 for i in range(4): | |
692 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
693 | |
694 origSeries = DoGet(_REMOTE, '/series')[0] | |
695 newSeries = DoPost(_REMOTE, '/series/%s/anonymize' % origSeries, | |
696 '{}', | |
697 'application/json')['ID'] | |
698 | |
699 self.assertEqual(origSeries, DoGet(_REMOTE, '/series/%s' % newSeries)['AnonymizedFrom']) | |
700 instances = DoGet(_REMOTE, '/series/%s' % newSeries)['Instances'] | |
701 self.assertEqual(4, len(instances)) | |
702 for i in instances: | |
703 j = DoGet(_REMOTE, '/instances/%s' % i)['AnonymizedFrom'] | |
704 self.assertEqual(newSeries, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
705 self.assertEqual(origSeries, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
706 | |
707 DoGet(_REMOTE, '/instances/%s/content/0008-1010' % j) | |
708 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/0008-1010' % i)) | |
709 | |
710 | |
711 def test_anonymize_study(self): | |
712 # Upload 4 images from the 2 series of the same study | |
713 for i in range(4): | |
714 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
715 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
716 | |
717 origStudy = DoGet(_REMOTE, '/studies')[0] | |
718 newStudy = DoPost(_REMOTE,'/studies/%s/anonymize' % origStudy, | |
719 '{"Replace":{"PatientName":"Jodogne"}}', | |
720 'application/json')['ID'] | |
721 | |
722 self.assertEqual(origStudy, DoGet(_REMOTE, '/studies/%s' % newStudy)['AnonymizedFrom']) | |
723 series = DoGet(_REMOTE, '/studies/%s' % newStudy)['Series'] | |
724 self.assertEqual(2, len(series)) | |
725 for s in series: | |
726 ss = DoGet(_REMOTE, '/series/%s' % s)['AnonymizedFrom'] | |
727 self.assertEqual(newStudy, DoGet(_REMOTE, '/series/%s' % s)['ParentStudy']) | |
728 self.assertEqual(origStudy, DoGet(_REMOTE, '/series/%s' % ss)['ParentStudy']) | |
729 | |
730 instances = DoGet(_REMOTE, '/series/%s' % s)['Instances'] | |
731 for i in instances: | |
732 j = DoGet(_REMOTE, '/instances/%s' % i)['AnonymizedFrom'] | |
733 self.assertEqual(s, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
734 self.assertEqual(ss, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
735 | |
736 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
737 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
11 | 738 |
739 | |
740 | |
741 def test_storescu(self): | |
742 # Check emptiness | |
743 e = DoGet(_REMOTE, '/exports') | |
744 self.assertEqual(0, len(e['Exports'])) | |
745 self.assertEqual(0, e['Last']) | |
746 self.assertTrue(e['Done']) | |
747 e = DoGet(_REMOTE, '/exports?last') | |
748 self.assertEqual(0, len(e['Exports'])) | |
749 self.assertEqual(0, e['Last']) | |
750 self.assertTrue(e['Done']) | |
751 | |
752 # Add 1 instance | |
753 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
754 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
755 | |
756 # Export the instance | |
757 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') # instance | |
758 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
759 self.assertEqual(1, len(DoGet(_LOCAL, '/studies'))) | |
760 self.assertEqual(1, len(DoGet(_LOCAL, '/series'))) | |
761 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
762 | |
763 e = DoGet(_REMOTE, '/exports') | |
764 self.assertEqual(1, len(e['Exports'])) | |
765 self.assertTrue(e['Done']) | |
766 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
767 e = DoGet(_REMOTE, '/exports?limit=1') | |
768 self.assertEqual(1, len(e['Exports'])) | |
769 self.assertTrue(e['Done']) | |
770 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
771 e = DoGet(_REMOTE, '/exports?last') | |
772 self.assertEqual(1, len(e['Exports'])) | |
773 self.assertTrue(e['Done']) | |
774 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
775 seqInstance = e['Last'] | |
776 | |
777 # Export the series | |
778 j = DoPost(_REMOTE, '/modalities/orthanctest/store', 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', 'text/plain') | |
779 | |
780 e = DoGet(_REMOTE, '/exports') | |
781 self.assertEqual(2, len(e['Exports'])) | |
782 self.assertTrue(e['Done']) | |
783 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
784 seqSeries = e['Last'] | |
785 self.assertNotEqual(seqInstance, seqSeries) | |
786 e = DoGet(_REMOTE, '/exports?limit=1&since=0') | |
787 self.assertEqual(1, len(e['Exports'])) | |
788 self.assertFalse(e['Done']) | |
789 self.assertEqual(e['Exports'][-1]['Seq'], seqInstance) | |
790 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqInstance)) | |
791 self.assertEqual(1, len(e['Exports'])) | |
792 self.assertTrue(e['Done']) | |
793 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
794 e = DoGet(_REMOTE, '/exports?last') | |
795 self.assertEqual(1, len(e['Exports'])) | |
796 self.assertTrue(e['Done']) | |
797 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
798 | |
799 # Export the study | |
800 j = DoPost(_REMOTE, '/modalities/orthanctest/store', 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', 'text/plain') | |
801 seqStudy = DoGet(_REMOTE, '/exports')['Last'] | |
802 | |
803 # Export the patient | |
804 j = DoPost(_REMOTE, '/modalities/orthanctest/store', '6816cb19-844d5aee-85245eba-28e841e6-2414fae2', 'text/plain') | |
805 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
806 self.assertEqual(1, len(DoGet(_LOCAL, '/studies'))) | |
807 self.assertEqual(1, len(DoGet(_LOCAL, '/series'))) | |
808 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
809 | |
810 e = DoGet(_REMOTE, '/exports') | |
811 self.assertEqual(4, len(e['Exports'])) | |
812 self.assertTrue(e['Done']) | |
813 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
814 seqPatient = e['Last'] | |
815 self.assertNotEqual(seqInstance, seqSeries) | |
816 self.assertNotEqual(seqSeries, seqStudy) | |
817 self.assertNotEqual(seqStudy, seqPatient) | |
818 self.assertTrue(seqInstance < seqSeries) | |
819 self.assertTrue(seqSeries < seqStudy) | |
820 self.assertTrue(seqStudy < seqPatient) | |
821 e = DoGet(_REMOTE, '/exports?limit=1&since=0') | |
822 self.assertEqual(1, len(e['Exports'])) | |
823 self.assertFalse(e['Done']) | |
824 self.assertEqual(e['Exports'][-1]['Seq'], seqInstance) | |
825 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqInstance)) | |
826 self.assertEqual(1, len(e['Exports'])) | |
827 self.assertFalse(e['Done']) | |
828 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
829 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqSeries)) | |
830 self.assertEqual(1, len(e['Exports'])) | |
831 self.assertFalse(e['Done']) | |
832 self.assertEqual(e['Exports'][-1]['Seq'], seqStudy) | |
833 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqStudy)) | |
834 self.assertEqual(1, len(e['Exports'])) | |
835 self.assertTrue(e['Done']) | |
836 self.assertEqual(e['Exports'][-1]['Seq'], seqPatient) | |
837 e = DoGet(_REMOTE, '/exports?last') | |
838 self.assertEqual(1, len(e['Exports'])) | |
839 self.assertTrue(e['Done']) | |
840 self.assertEqual(e['Exports'][-1]['Seq'], seqPatient) | |
841 | |
842 | |
843 # Check the content of the logged information | |
844 e = DoGet(_REMOTE, '/exports')['Exports'] | |
845 | |
846 if 'PatientID' in e[0]: | |
847 # Since Orthanc 0.8.6 | |
848 patient = 'PatientID' | |
849 study = 'StudyInstanceUID' | |
850 series = 'SeriesInstanceUID' | |
851 instance = 'SOPInstanceUID' | |
852 else: | |
853 # Up to Orthanc 0.8.5 | |
854 patient = 'PatientId' | |
855 study = 'StudyInstanceUid' | |
856 series = 'SeriesInstanceUid' | |
857 instance = 'SopInstanceUid' | |
858 | |
859 for k in range(4): | |
860 self.assertTrue('Date' in e[k]) | |
861 self.assertTrue('Seq' in e[k]) | |
862 self.assertEqual('orthanctest', e[k]['RemoteModality']) | |
863 | |
864 self.assertEqual(10, len(e[0])) | |
865 self.assertEqual('Instance', e[0]['ResourceType']) | |
866 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', e[0]['ID']) | |
867 self.assertEqual('/instances/66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', e[0]['Path']) | |
868 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', e[0][instance]) | |
869 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', e[0][series]) | |
870 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[0][study]) | |
871 self.assertEqual('ozp00SjY2xG', e[0][patient]) | |
872 | |
873 self.assertEqual(9, len(e[1])) | |
874 self.assertEqual('Series', e[1]['ResourceType']) | |
875 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', e[1]['ID']) | |
876 self.assertEqual('/series/f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', e[1]['Path']) | |
877 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', e[1][series]) | |
878 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[1][study]) | |
879 self.assertEqual('ozp00SjY2xG', e[1][patient]) | |
880 | |
881 self.assertEqual(8, len(e[2])) | |
882 self.assertEqual('Study', e[2]['ResourceType']) | |
883 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', e[2]['ID']) | |
884 self.assertEqual('/studies/b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', e[2]['Path']) | |
885 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[2][study]) | |
886 self.assertEqual('ozp00SjY2xG', e[2][patient]) | |
887 | |
888 self.assertEqual(7, len(e[3])) | |
889 self.assertEqual('Patient', e[3]['ResourceType']) | |
890 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', e[3]['ID']) | |
891 self.assertEqual('/patients/6816cb19-844d5aee-85245eba-28e841e6-2414fae2', e[3]['Path']) | |
892 self.assertEqual('ozp00SjY2xG', e[3][patient]) | |
893 | |
894 DropOrthanc(_REMOTE) | |
895 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
896 | |
897 | |
898 def test_store_peer(self): | |
899 self.assertEqual(0, len(DoGet(_LOCAL, '/exports')['Exports'])) | |
900 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
901 | |
902 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
903 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
904 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
905 | |
906 j = DoPost(_REMOTE, '/peers/peer/store', str(i), 'text/plain') | |
907 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
908 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
909 | |
910 self.assertEqual(1, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
911 | |
912 DropOrthanc(_REMOTE) | |
913 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
914 | |
915 | |
916 def test_bulk_storescu(self): | |
917 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
918 | |
919 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
920 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
921 | |
922 j = DoPost(_REMOTE, '/modalities/orthanctest/store', [ a['ID'], b['ID'] ], 'application/json') | |
923 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
924 | |
925 DropOrthanc(_LOCAL) | |
926 | |
927 # Send using patient's UUID | |
928 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
929 j = DoPost(_REMOTE, '/modalities/orthanctest/store', | |
930 [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ], 'application/json') | |
931 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
932 | |
933 | |
934 def test_color(self): | |
935 i = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] | |
936 im = GetImage(_REMOTE, '/instances/%s/preview' % i) | |
937 self.assertEqual("RGB", im.mode) | |
938 self.assertEqual(41, im.size[0]) | |
939 self.assertEqual(41, im.size[1]) | |
940 | |
941 # http://effbot.org/zone/pil-comparing-images.htm | |
13 | 942 truth = Image.open(GetDatabasePath('ColorTestMalaterre.png')) |
11 | 943 self.assertTrue(ImageChops.difference(im, truth).getbbox() is None) |
944 | |
945 | |
12 | 946 def test_faking_ruby_put(self): |
947 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
948 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
949 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
950 a = DoGet(_REMOTE, '/patients')[0] | |
951 b = DoGet(_REMOTE, '/patients')[1] | |
952 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
953 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '0') | |
954 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
955 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '1') | |
956 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
957 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '0') | |
958 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
959 | |
960 | |
961 def test_faking_ruby_delete(self): | |
962 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
963 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
964 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
965 a = DoGet(_REMOTE, '/patients')[0] | |
966 b = DoGet(_REMOTE, '/patients')[1] | |
967 DoGet(_REMOTE, '/patients/%s' % a, data = { '_method' : 'DELETE' }) | |
968 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
969 DoGet(_REMOTE, '/patients/%s' % b, data = { '_method' : 'DELETE' }) | |
970 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
971 | |
972 | |
973 def test_faking_google_put(self): | |
974 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
975 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
976 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
977 a = DoGet(_REMOTE, '/patients')[0] | |
978 b = DoGet(_REMOTE, '/patients')[1] | |
979 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
980 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '0') | |
981 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
982 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '1') | |
983 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
984 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '0') | |
985 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
986 | |
987 | |
988 def test_faking_google_delete(self): | |
989 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
990 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
991 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
992 a = DoGet(_REMOTE, '/patients')[0] | |
993 b = DoGet(_REMOTE, '/patients')[1] | |
994 DoPost(_REMOTE, '/patients/%s' % a, headers = { 'X-HTTP-Method-Override' : 'DELETE' }) | |
995 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
996 DoPost(_REMOTE, '/patients/%s' % b, headers = { 'X-HTTP-Method-Override' : 'DELETE' }) | |
997 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
998 | |
999 | |
1000 def test_lua(self): | |
1001 self.assertEqual(42, DoPost(_REMOTE, '/tools/execute-script', 'print(42)')) | |
1002 self.assertTrue(IsDefinedInLua(_REMOTE, 'PrintRecursive')) | |
1003 self.assertFalse(IsDefinedInLua(_REMOTE, 'HelloWorld')) | |
1004 | |
1005 | |
1006 def test_metadata(self): | |
1007 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
1008 p = DoGet(_REMOTE, '/patients')[0] | |
1009 i = DoGet(_REMOTE, '/instances')[0] | |
1010 | |
1011 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
1012 self.assertEqual(1, len(m)) | |
1013 self.assertEqual('LastUpdate', m[0]) | |
1014 | |
1015 m = DoGet(_REMOTE, '/instances/%s/metadata' % i) | |
145 | 1016 self.assertEqual(8, len(m)) |
12 | 1017 self.assertTrue('IndexInSeries' in m) |
1018 self.assertTrue('ReceptionDate' in m) | |
1019 self.assertTrue('RemoteAET' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1020 self.assertTrue('Origin' in m) |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1021 self.assertTrue('TransferSyntax' in m) |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1022 self.assertTrue('SopClassUid' in m) |
145 | 1023 self.assertTrue('RemoteIP' in m) |
1024 self.assertTrue('HttpUsername' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1025 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
|
1026 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
|
1027 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
|
1028 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
|
1029 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % i), '1.2.840.10008.5.1.4.1.1.4') |
12 | 1030 |
1031 # Play with custom metadata | |
1032 DoPut(_REMOTE, '/patients/%s/metadata/5555' % p, 'coucou') | |
1033 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
1034 self.assertEqual(2, len(m)) | |
1035 self.assertTrue('LastUpdate' in m) | |
1036 self.assertTrue('5555' in m) | |
1037 self.assertEqual('coucou', DoGet(_REMOTE, '/patients/%s/metadata/5555' % p)) | |
1038 DoPut(_REMOTE, '/patients/%s/metadata/5555' % p, 'hello') | |
1039 self.assertEqual('hello', DoGet(_REMOTE, '/patients/%s/metadata/5555' % p)) | |
1040 DoDelete(_REMOTE, '/patients/%s/metadata/5555' % p) | |
1041 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
1042 self.assertEqual(1, len(m)) | |
1043 self.assertTrue('LastUpdate' in m) | |
13 | 1044 |
1045 | |
1046 def test_statistics(self): | |
1047 # Upload 16 instances | |
1048 for i in range(4): | |
1049 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1050 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1051 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1052 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1053 | |
1054 s = DoGet(_REMOTE, '/statistics') | |
1055 self.assertEqual(16, s['CountInstances']) | |
1056 self.assertEqual(2, s['CountPatients']) | |
1057 self.assertEqual(2, s['CountStudies']) | |
1058 self.assertEqual(4, s['CountSeries']) | |
1059 d = int(s['TotalUncompressedSize']) | |
1060 | |
1061 e = 0 | |
1062 for patient in DoGet(_REMOTE, '/patients'): | |
1063 s = DoGet(_REMOTE, '/patients/%s/statistics' % patient) | |
1064 self.assertEqual(8, s['CountInstances']) | |
1065 self.assertEqual(1, s['CountStudies']) | |
1066 self.assertEqual(2, s['CountSeries']) | |
1067 e += int(s['UncompressedSize']) | |
1068 | |
1069 for study in DoGet(_REMOTE, '/studies'): | |
1070 s = DoGet(_REMOTE, '/studies/%s/statistics' % study) | |
1071 self.assertEqual(8, s['CountInstances']) | |
1072 self.assertEqual(2, s['CountSeries']) | |
1073 e += int(s['UncompressedSize']) | |
1074 | |
1075 for series in DoGet(_REMOTE, '/series'): | |
1076 s = DoGet(_REMOTE, '/series/%s/statistics' % series) | |
1077 self.assertEqual(4, s['CountInstances']) | |
1078 e += int(s['UncompressedSize']) | |
1079 | |
1080 self.assertEqual(3 * d, e) | |
1081 | |
1082 | |
1083 def test_custom_attachment(self): | |
1084 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
1085 patient = DoGet(_REMOTE, '/patients')[0] | |
1086 instance = DoGet(_REMOTE, '/instances')[0] | |
1087 size = int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']) | |
1088 self.assertEqual(size, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1089 | |
1090 self.assertEqual(0, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1091 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) | |
1092 self.assertTrue('dicom' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) | |
1093 self.assertTrue('dicom-as-json' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) | |
1094 | |
1095 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/patients/%s/attachments/22' % patient, 'hello')) | |
1096 hello = 'hellohellohellohellohellohellohellohellohello' | |
1097 DoPut(_REMOTE, '/patients/%s/attachments/1025' % patient, hello) | |
1098 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1099 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1100 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1101 size + int(DoGet(_REMOTE, '/patients/%s/attachments/1025/compressed-size' % patient))) | |
1102 | |
1103 DoPut(_REMOTE, '/patients/%s/attachments/1026' % patient, 'world') | |
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 + | |
1108 int(DoGet(_REMOTE, '/patients/%s/attachments/1025/compressed-size' % patient)) + | |
1109 int(DoGet(_REMOTE, '/patients/%s/attachments/1026/compressed-size' % patient))) | |
1110 | |
1111 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1112 self.assertEqual(hello, DoGet(_REMOTE, '/patients/%s/attachments/1025/data' % patient)) | |
1113 self.assertEqual('world', DoGet(_REMOTE, '/patients/%s/attachments/1026/data' % patient)) | |
1114 DoPost(_REMOTE, '/patients/%s/attachments/1025/verify-md5' % patient) | |
1115 DoPost(_REMOTE, '/patients/%s/attachments/1026/verify-md5' % patient) | |
1116 DoPut(_REMOTE, '/patients/%s/attachments/1026' % patient, 'world2') | |
1117 self.assertEqual('world2', DoGet(_REMOTE, '/patients/%s/attachments/1026/data' % patient)) | |
1118 | |
1119 self.assertRaises(Exception, lambda: DoDelete(_REMOTE, '/instances/%s/attachments/dicom' % instance)) | |
1120 DoDelete(_REMOTE, '/patients/%s/attachments/1025' % patient) | |
1121 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1122 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1123 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1124 size + int(DoGet(_REMOTE, '/patients/%s/attachments/1026/compressed-size' % patient))) | |
1125 | |
1126 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1127 DoDelete(_REMOTE, '/patients/%s/attachments/1026' % patient) | |
1128 self.assertEqual(0, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1129 | |
1130 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), size) | |
1131 self.assertEqual(size, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1132 | |
1133 | |
1134 def test_incoming_storescu(self): | |
1135 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
45 | 1136 subprocess.check_call([ FindExecutable('storescu'), |
44
ffa542cce638
Toolbox.FindExecutable()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
1137 _REMOTE['Server'], str(_REMOTE['DicomPort']), |
13 | 1138 GetDatabasePath('ColorTestImageJ.dcm') ]) |
1139 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1140 | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1141 i = DoGet(_REMOTE, '/instances') |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1142 self.assertEqual(1, len(i)) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1143 m = DoGet(_REMOTE, '/instances/%s/metadata' % i[0]) |
145 | 1144 self.assertEqual(8, len(m)) |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1145 self.assertTrue('IndexInSeries' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1146 self.assertTrue('ReceptionDate' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1147 self.assertTrue('RemoteAET' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1148 self.assertTrue('Origin' in m) |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1149 self.assertTrue('TransferSyntax' in m) |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1150 self.assertTrue('SopClassUid' in m) |
145 | 1151 self.assertTrue('RemoteIP' in m) |
1152 self.assertTrue('CalledAET' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1153 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
|
1154 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
|
1155 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
|
1156 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
|
1157 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
|
1158 |
13 | 1159 |
1160 def test_incoming_findscu(self): | |
1161 UploadInstance(_REMOTE, 'Multiframe.dcm') | |
1162 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') | |
1163 | |
1164 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', '0010,0010' ]) | |
1165 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', i) | |
1166 self.assertEqual(2, len(patientNames)) | |
1167 self.assertTrue('Test Patient BG ' in patientNames) | |
1168 self.assertTrue('Anonymized' in patientNames) | |
1169 | |
1170 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,0021' ]) | |
1171 series = re.findall('\(0008,0021\).*?\[\s*(.*?)\s*\]', i) | |
1172 self.assertEqual(2, len(series)) | |
1173 self.assertTrue('20070208' in series) | |
1174 self.assertTrue('19980312' in series) | |
1175 | |
56
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1176 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
|
1177 series = re.findall('\(0008,0021\).*?\[\s*(.*?)\s*\]', i) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1178 self.assertEqual(1, len(series)) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1179 self.assertTrue('19980312' in series) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1180 |
13 | 1181 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'PatientName=Anonymized' ]) |
1182 series = re.findall('\(0010,0010\).*?\[\s*(.*?)\s*\]', i) | |
1183 self.assertEqual(1, len(series)) | |
1184 | |
1185 # Test the "CaseSentitivePN" flag (false by default) | |
1186 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'PatientName=anonymized' ]) | |
1187 series = re.findall('\(0010,0010\).*?\[\s*(.*?)\s*\]', i) | |
1188 self.assertEqual(1, len(series)) | |
66
821d9eb73c45
Test returning sequence values
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
1189 |
70 | 1190 # Test range search (buggy if Orthanc <= 0.9.6) |
1191 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=19980312-' ]) | |
1192 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1193 self.assertEqual(2, len(studies)) | |
1194 self.assertTrue('20070208' in studies) | |
1195 self.assertTrue('19980312' in studies) | |
1196 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=19980312-19980312' ]) | |
1197 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1198 self.assertEqual(1, len(studies)) | |
1199 self.assertTrue('19980312' in studies) | |
1200 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=-19980312' ]) | |
1201 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1202 self.assertEqual(1, len(studies)) | |
1203 self.assertTrue('19980312' in studies) | |
13 | 1204 |
1205 | |
191
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1206 def test_incoming_findscu_2(self): |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1207 # This test fails if "LookupMode_DatabaseOnly" is used |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1208 # (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
|
1209 # DICOM tags are returned) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1210 UploadInstance(_REMOTE, 'Multiframe.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1211 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1212 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1213 # 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
|
1214 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
|
1215 sequences = re.findall('\(0008,2112\)', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1216 self.assertEqual(1, len(sequences)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1217 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1218 # Test returning a non-main DICOM tag, |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1219 # "SecondaryCaptureDeviceID" (0018,1010), whose value is |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1220 # "MEDPC" in "ColorTestImageJ.dcm" |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1221 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0018,1010' ]) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1222 tags = re.findall('\(0018,1010\).*MEDPC', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1223 self.assertEqual(1, len(tags)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1224 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1225 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1226 def test_incoming_findscu_3(self): |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1227 # This test fails if "LookupMode_DatabaseOnly" or |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1228 # "LookupMode_DiskOnAnswer" is used, as |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1229 # "SecondaryCaptureDeviceID" (0018,1010) is not a main DICOM |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1230 # 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
|
1231 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1232 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1233 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
|
1234 sequences = re.findall('\(0018,1010\)', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1235 self.assertEqual(1, len(sequences)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1236 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1237 |
13 | 1238 def test_incoming_movescu(self): |
1239 UploadInstance(_REMOTE, 'Multiframe.dcm') | |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1240 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1241 # No matching patient, so no job is created |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1242 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1243 CallMoveScu([ '--patient', '-k', '0008,0052=PATIENT', '-k', 'PatientID=none' ]) |
13 | 1244 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1245 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1246 # 1 Matching patient, track the job |
138 | 1247 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
1248 '--patient', | |
1249 '-k', '0008,0052=PATIENT', | |
1250 '-k', 'PatientID=12345678' | |
1251 ]))) | |
13 | 1252 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) |
1253 | |
1254 | |
1255 def test_findscu(self): | |
1256 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1257 j = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] | |
1258 k = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] | |
1259 DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1260 | |
1261 # Test the "find-patient" level | |
1262 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }) | |
1263 self.assertEqual(1, len(p)) | |
1264 self.assertEqual('ozp00SjY2xG', p[0]['PatientID']) | |
1265 | |
1266 # Test wildcards constraints. The "LO" value representation | |
1267 # for PatientID is always case-sensitive, but the "PN" for | |
1268 # PatientName might depend on the implementation: | |
1269 # "GenerateConfigurationForTests.py" will force it to be case | |
1270 # insensitive (which was the default until Orthanc 0.8.6). | |
1271 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'K*' }) | |
1272 self.assertEqual(1, len(p)) | |
1273 | |
1274 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'k*' }) | |
1275 self.assertEqual(1, len(p)) | |
1276 | |
1277 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : 'ozp*' }) | |
1278 self.assertEqual(1, len(p)) | |
1279 | |
1280 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : 'o?p*' }) | |
1281 self.assertEqual(1, len(p)) | |
1282 | |
1283 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : '0?q*' }) | |
1284 self.assertEqual(0, len(p)) | |
1285 | |
1286 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'B*' }) | |
1287 self.assertEqual(0, len(p)) | |
1288 | |
1289 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'b*' }) | |
1290 self.assertEqual(0, len(p)) | |
1291 | |
1292 DoPost(_REMOTE, '/modalities/orthanctest/store', str(j), 'text/plain') | |
1293 DoPost(_REMOTE, '/modalities/orthanctest/store', str(k), 'text/plain') | |
1294 DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }) | |
1295 self.assertEqual(3, len(DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }))) | |
1296 | |
1297 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'A*' }) | |
1298 self.assertEqual(2, len(p)) | |
1299 | |
1300 # Test the "find-study" level. This is the instance "ColorTestImageJ.dcm" | |
1301 s = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ' }) | |
1302 self.assertEqual(1, len(s)) | |
1303 self.assertEqual('20070208', s[0]['StudyDate']) | |
1304 | |
1305 # Test range searches | |
1306 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1307 'StudyDate' : '-20070101' }) | |
1308 self.assertEqual(0, len(t)) | |
1309 | |
1310 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1311 'StudyDate' : '20090101-' }) | |
1312 self.assertEqual(0, len(t)) | |
1313 | |
1314 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1315 'StudyDate' : '20070101-' }) | |
1316 self.assertEqual(1, len(t)) | |
1317 | |
1318 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1319 'StudyDate' : '-20090101' }) | |
1320 self.assertEqual(1, len(t)) | |
1321 | |
1322 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1323 'StudyDate' : '20070207-20070207' }) | |
1324 self.assertEqual(0, len(t)) | |
1325 | |
1326 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1327 'StudyDate' : '20070208-20070208' }) | |
1328 self.assertEqual(1, len(t)) | |
1329 | |
1330 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1331 'StudyDate' : '20070209-20070209' }) | |
1332 self.assertEqual(0, len(t)) | |
1333 | |
1334 # Test the ModalitiesInStudy tag | |
1335 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1336 'PatientID' : 'B9uTHKOZ', | |
1337 'ModalitiesInStudy' : 'US' }) | |
1338 self.assertEqual(0, len(t)) | |
1339 | |
1340 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1341 'PatientID' : 'B9uTHKOZ', | |
1342 'ModalitiesInStudy' : 'CT' }) | |
1343 self.assertEqual(1, len(t)) | |
1344 | |
1345 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1346 'PatientID' : 'B9uTHKOZ', | |
1347 'ModalitiesInStudy' : 'US\\CT' }) | |
1348 self.assertEqual(1, len(t)) | |
1349 | |
1350 # Test the "find-series" level | |
1351 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1352 'PatientID' : 'B9uTHKOZ', | |
1353 'StudyInstanceUID' : s[0]['StudyInstanceUID'] }) | |
1354 self.assertEqual(1, len(t)) | |
1355 | |
1356 # Test "\" separator | |
1357 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1358 'PatientID' : 'B9uTHKOZ', | |
1359 'StudyInstanceUID' : s[0]['StudyInstanceUID'], | |
1360 'Modality' : 'MR\\CT\\US' }) | |
1361 self.assertEqual(1, len(t)) | |
1362 | |
1363 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1364 'PatientID' : 'B9uTHKOZ', | |
1365 'StudyInstanceUID' : s[0]['StudyInstanceUID'], | |
1366 'Modality' : 'MR\\US' }) | |
1367 self.assertEqual(0, len(t)) | |
1368 | |
1369 | |
1370 def test_update_modalities(self): | |
1371 try: | |
1372 DoDelete(_REMOTE, '/modalities/toto') | |
1373 except: | |
1374 pass | |
1375 try: | |
1376 DoDelete(_REMOTE, '/modalities/tata') | |
1377 except: | |
1378 pass | |
1379 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/toto')) | |
1380 DoPut(_REMOTE, '/modalities/toto', [ "STORESCP", "localhost", 2000 ]) | |
116 | 1381 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'MedInria' ]) # check backward compatiblity with obsolete manufacturer |
1382 DoDelete(_REMOTE, '/modalities/tata') | |
124 | 1383 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'GenericNoUniversalWildcard' ]) |
121
1a19f953f53c
also test GenericNoWildcardInDates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
120
diff
changeset
|
1384 DoDelete(_REMOTE, '/modalities/tata') |
1a19f953f53c
also test GenericNoWildcardInDates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
120
diff
changeset
|
1385 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'GenericNoWildcardInDates' ]) |
128 | 1386 modalitiesReadback = DoGet(_REMOTE, '/modalities?expand') |
182
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1387 self.assertEqual('STORESCP', modalitiesReadback['tata']['AET']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1388 self.assertEqual('localhost', modalitiesReadback['tata']['Host']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1389 self.assertEqual(2000, modalitiesReadback['tata']['Port']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1390 self.assertEqual('GenericNoWildcardInDates', modalitiesReadback['tata']['Manufacturer']) |
116 | 1391 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/modalities/toto', [ "STORESCP", "localhost", 2000, 'InvalidManufacturerName' ])) |
13 | 1392 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/toto')) |
1393 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/tata')) | |
1394 DoDelete(_REMOTE, '/modalities/toto') | |
1395 DoDelete(_REMOTE, '/modalities/tata') | |
1396 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/toto')) | |
1397 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/tata')) | |
1398 | |
1399 | |
1400 def test_update_peers(self): | |
1401 # curl -X PUT http://localhost:8042/peers/toto -d '["http://localhost:8042/"]' -v | |
1402 try: | |
1403 DoDelete(_REMOTE, '/peers/toto') | |
1404 except: | |
1405 pass | |
1406 try: | |
1407 DoDelete(_REMOTE, '/peers/tata') | |
1408 except: | |
1409 pass | |
1410 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/toto')) | |
1411 DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/' ]) | |
1412 DoPut(_REMOTE, '/peers/tata', [ 'http://localhost:8042/', 'user', 'pass' ]) | |
128 | 1413 self.assertTrue('tata' in DoGet(_REMOTE, '/peers')) |
1414 peersReadback = DoGet(_REMOTE, '/peers?expand') | |
1415 self.assertEqual('http://localhost:8042/', peersReadback['tata']['Url']) | |
1416 self.assertEqual('user', peersReadback['tata']['Username']) | |
1417 self.assertFalse('Password' in peersReadback['tata']) # make sure no sensitive data is included | |
1418 self.assertFalse('CertificateFile' in peersReadback['tata']) # make sure no sensitive data is included | |
1419 self.assertFalse('CertificateKeyFile' in peersReadback['tata']) # make sure no sensitive data is included | |
1420 self.assertFalse('CertificateKeyPassword' in peersReadback['tata']) # make sure no sensitive data is included | |
1421 self.assertFalse('Pkcs11' in peersReadback['tata']) # make sure no sensitive data is included | |
13 | 1422 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/', 'a' ])) |
1423 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/', 'a', 'b', 'c' ])) | |
1424 self.assertTrue('store' in DoGet(_REMOTE, '/peers/toto')) | |
1425 self.assertTrue('store' in DoGet(_REMOTE, '/peers/tata')) | |
1426 DoDelete(_REMOTE, '/peers/toto') | |
1427 DoDelete(_REMOTE, '/peers/tata') | |
1428 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/toto')) | |
1429 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/tata')) | |
1430 | |
1431 | |
1432 def test_mesterhazy_modification(self): | |
1433 # When I modify a series ( eg. curl | |
1434 # http://localhost:8042/series/uidhere/modify -X POST -d | |
1435 # '{"Replace":{"SeriesDate":"19990101"}}' ) the modified | |
1436 # series is added to a new Study, instead of the existing | |
1437 # Study. Fixed in Orthanc 0.7.5 | |
1438 | |
1439 u = UploadInstance(_REMOTE, 'DummyCT.dcm') | |
1440 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' | |
1441 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
1442 | |
1443 modified = DoPost(_REMOTE, '/series/%s/modify' % series, | |
1444 json.dumps({ "Replace" : { "SeriesDate" : "19990101" }})) | |
1445 | |
1446 self.assertEqual(study, DoGet(_REMOTE, '/series/%s' % modified['ID']) ['ParentStudy']) | |
1447 | |
1448 | |
1449 def test_create(self): | |
1450 i = DoPost(_REMOTE, '/tools/create-dicom', | |
1451 json.dumps({ | |
1452 'PatientName' : 'Jodogne', | |
1453 'Modality' : 'CT', | |
58 | 1454 'SOPClassUID' : '1.2.840.10008.5.1.4.1.1.1', |
13 | 1455 'PixelData' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==' # red dot in RGBA |
1456 })) | |
1457 | |
1458 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
1459 self.assertEqual('CT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i['ID']).strip()) | |
1460 | |
1461 png = GetImage(_REMOTE, '/instances/%s/preview' % i['ID']) | |
1462 self.assertEqual((5, 5), png.size) | |
1463 | |
38 | 1464 j = DoGet(_REMOTE, i['Path']) |
1465 self.assertEqual('Instance', j['Type']) | |
1466 self.assertEqual(j['ID'], i['ID']) | |
1467 | |
13 | 1468 |
1469 def test_pilates(self): | |
1470 # "SCU failed error when accessing orthanc with osirix" by | |
1471 # Pilates Agentur (Mar 10, 2014 at 9:33 PM) | |
1472 i = UploadInstance(_REMOTE, 'PilatesArgenturGEUltrasoundOsiriX.dcm')['ID'] | |
1473 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
1474 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1475 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
1476 | |
1477 | |
1478 def test_shared_tags(self): | |
1479 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1480 b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm')['ID'] | |
1481 p = DoGet(_REMOTE, '/patients')[0] | |
1482 | |
1483 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1484 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
|
1485 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
|
1486 |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1487 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
|
1488 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
|
1489 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
|
1490 |
13 | 1491 self.assertTrue('0008,1030' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) |
1492 self.assertTrue('StudyDescription' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1493 self.assertTrue('0008,103e' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1494 self.assertTrue('SeriesDescription' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1495 self.assertFalse('0008,0018' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1496 self.assertFalse('SOPInstanceUID' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1497 | |
1498 self.assertTrue('0008,0018' in DoGet(_REMOTE, '/instances/%s/tags' % a)) | |
1499 self.assertTrue('SOPInstanceUID' in DoGet(_REMOTE, '/instances/%s/tags?simplify' % a)) | |
1500 | |
1501 | |
1502 def test_modules(self): | |
1503 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1504 p = DoGet(_REMOTE, '/patients')[0] | |
1505 s = DoGet(_REMOTE, '/studies')[0] | |
1506 t = DoGet(_REMOTE, '/series')[0] | |
1507 | |
1508 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/module' % p)) | |
1509 self.assertTrue('PatientName' in DoGet(_REMOTE, '/patients/%s/module?simplify' % p)) | |
1510 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/studies/%s/module-patient' % p)) | |
1511 self.assertTrue('PatientName' in DoGet(_REMOTE, '/studies/%s/module-patient?simplify' % p)) | |
1512 self.assertTrue('0008,1030' in DoGet(_REMOTE, '/studies/%s/module' % s)) | |
1513 self.assertTrue('StudyDescription' in DoGet(_REMOTE, '/studies/%s/module?simplify' % s)) | |
1514 self.assertTrue('0008,103e' in DoGet(_REMOTE, '/series/%s/module' % p)) | |
1515 self.assertTrue('SeriesDescription' in DoGet(_REMOTE, '/series/%s/module?simplify' % p)) | |
1516 self.assertTrue('0008,0018' in DoGet(_REMOTE, '/instances/%s/module' % a)) | |
1517 self.assertTrue('SOPInstanceUID' in DoGet(_REMOTE, '/instances/%s/module?simplify' % a)) | |
1518 | |
1519 | |
1520 def test_auto_directory(self): | |
1521 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1522 self.assertTrue('now' in DoGet(_REMOTE, '/tools')) | |
1523 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
|
1524 self.assertTrue('invalidate-tags' in DoGet(_REMOTE, '/tools')) |
13 | 1525 self.assertTrue(len(DoGet(_REMOTE, '/tools/dicom-conformance')) > 1000) |
1526 self.assertTrue('orthanctest' in DoGet(_REMOTE, '/modalities')) | |
1527 self.assertTrue('echo' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1528 self.assertTrue('find' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1529 self.assertTrue('find-instance' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1530 self.assertTrue('find-patient' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1531 self.assertTrue('find-series' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1532 self.assertTrue('find-study' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1533 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1534 self.assertTrue('store' in DoGet(_REMOTE, '/peers/peer')) | |
1535 self.assertTrue('matlab' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) | |
79 | 1536 self.assertTrue('raw' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) |
13 | 1537 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/tools/nope')) |
28 | 1538 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope')) |
1539 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope/nope.html')) | |
1540 self.assertEqual(404, DoGetRaw(_REMOTE, '/nope')[0].status) | |
1541 self.assertEqual(404, DoGetRaw(_REMOTE, '/nope/nope.html')[0].status) | |
13 | 1542 |
1543 | |
1544 def test_echo(self): | |
1545 DoPost(_REMOTE, '/modalities/orthanctest/echo') | |
1546 | |
1547 | |
1548 def test_xml(self): | |
1549 json = DoGet(_REMOTE, '/tools', headers = { 'accept' : 'application/json' }) | |
1550 xml = minidom.parseString(DoGet(_REMOTE, '/tools', headers = { 'accept' : 'application/xml' })) | |
1551 items = xml.getElementsByTagName('root')[0].getElementsByTagName('item') | |
1552 self.assertEqual(len(items), len(json)) | |
1553 | |
1554 self.assertTrue('dicom-conformance' in json) | |
1555 | |
1556 ok = False | |
1557 for i in items: | |
1558 if i.childNodes[0].data == 'dicom-conformance': | |
1559 ok = True | |
1560 self.assertTrue(ok) | |
1561 | |
1562 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1563 def test_googlecode_issue_16(self): |
13 | 1564 i = UploadInstance(_REMOTE, 'Issue16.dcm')['ID'] |
1565 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i)['FrameIncrementPointer'] | |
1566 self.assertEqual('0018,1063', t) | |
1567 | |
1568 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1569 def test_googlecode_issue_22(self): |
13 | 1570 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] |
1571 a = [ | |
1572 "f804691f62197040438f4627c6b994f1", # Frame 0 | |
1573 "c69eee9a51eea3e8611e82e578897254", | |
1574 "315666be83e2d0111c77bc0996d84901", | |
1575 "3e27aa959d911172c48a1436443c72b1", | |
1576 "958642c9e7e9d232d3869faff546058c", | |
1577 "5e7ea8e3e4230cae707d143481355c59", | |
1578 "eda37f83558d858a596175aed8b2ad47", | |
1579 "486713bd2895c4ecbe0e97715ac7f80a", | |
1580 "091ef729eb169e67da8a0faa9631f9a8", | |
1581 "5aa2b8c7ffe0a483efaa8e12417686ca", | |
1582 "e2f39e85896fe58876654b94cd0b5013", | |
1583 "6fd2129e4950abbe1be053bc814d5da8", | |
1584 "c3331a8ba7a757f3d423735ab7fa81f9", | |
1585 "746f808582156734dd6b6fdfd3a0b72c", | |
1586 "8075ea2b227a70c60ea6b7b75a6bb190", | |
1587 "806b8b3e300c615099c11a5ec23465aa", | |
1588 "7c836aa298ba6eef96434579af631a11", | |
1589 "a0357dc9f4f72d73a885c33d7c287446", | |
1590 "f25ba3be1cc7d7fad95706adc199ea7d", | |
1591 "8b114c526b8cbed6cad8a3248b7b480c", | |
1592 "44e6670f127e612a2b4aa60a0d207698", | |
1593 "b8945f90fe02facf2ace24ca1ecbe0a5", | |
1594 "95c796c2fa8f59018b15cf2987b1f79b", | |
1595 "ce0a51ab30224205b44920221dc27351", # Frame 23 | |
1596 ] | |
1597 | |
1598 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
1599 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/24/preview' % s)) | |
1600 | |
1601 for i in range(len(a)): | |
1602 self.assertEqual(a[i], ComputeMD5(DoGet(_REMOTE, '/instances/%s/frames/%d/preview' % (s, i)))) | |
1603 | |
1604 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1605 def test_googlecode_issue_19(self): |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1606 # This is an image with "YBR_FULL" photometric interpretation, it is not supported by Orthanc |
13 | 1607 # gdcmconv -i /home/jodogne/DICOM/GdcmDatabase/US_DataSet/HDI5000_US/3EAF5E01 -w -o Issue19.dcm |
1608 | |
1609 a = UploadInstance(_REMOTE, 'Issue19.dcm')['ID'] | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1610 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/941ad3c8-05d05b88-560459f9-0eae0e20-6cddd533/preview')) |
13 | 1611 |
1612 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1613 def test_googlecode_issue_37(self): |
13 | 1614 # Same test for issues 35 and 37. Fixed in Orthanc 0.9.1 |
1615 u = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] | |
1616 | |
1617 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
1618 'CaseSensitive' : True, | |
1619 'Query' : { 'StationName' : 'SMR4-MP3' }}) | |
1620 self.assertEqual(1, len(a)) | |
14 | 1621 |
1622 | |
1623 def test_rest_find(self): | |
1624 # Upload 8 instances | |
1625 for i in range(2): | |
1626 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1627 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1628 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1629 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1630 | |
1631 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1632 'CaseSensitive' : False, | |
194
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1633 'Query' : { 'PatientName' : 'BRAINIX' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1634 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1635 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1636 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1637 'CaseSensitive' : False, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1638 'Query' : { 'PatientName' : 'BRAINIX\\KNEE\\NOPE' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1639 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1640 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1641 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1642 'CaseSensitive' : False, |
14 | 1643 'Query' : { 'PatientName' : '*n*' }}) |
1644 self.assertEqual(2, len(a)) | |
1645 | |
1646 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1647 'CaseSensitive' : True, | |
1648 'Query' : { 'PatientName' : '*n*' }}) | |
1649 self.assertEqual(0, len(a)) | |
1650 | |
1651 a = DoPost(_REMOTE, '/tools/find', { 'Expand' : True, | |
1652 'Level' : 'Patient', | |
1653 'CaseSensitive' : False, | |
1654 'Query' : { 'PatientName' : '*ne*' }}) | |
1655 self.assertEqual(1, len(a)) | |
1656 self.assertEqual('20080822', a[0]['MainDicomTags']['PatientBirthDate']) | |
1657 | |
1658 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1659 'CaseSensitive' : True, | |
1660 'Query' : { 'PatientName' : '*ne*' }}) | |
1661 self.assertEqual(0, len(a)) | |
1662 | |
1663 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', | |
1664 'CaseSensitive' : True, | |
1665 'Query' : { 'PatientName' : '*NE*' }}) | |
1666 self.assertEqual(1, len(a)) | |
1667 | |
1668 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
1669 'CaseSensitive' : True, | |
1670 'Query' : { 'PatientName' : '*NE*' }}) | |
1671 self.assertEqual(2, len(a)) | |
1672 | |
1673 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', | |
1674 'CaseSensitive' : True, | |
1675 'Query' : { 'PatientName' : '*NE*' }}) | |
1676 self.assertEqual(4, len(a)) | |
1677 | |
1678 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', 'Query' : { }}) | |
1679 self.assertEqual(2, len(a)) | |
1680 | |
1681 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', 'Query' : { }}) | |
1682 self.assertEqual(2, len(a)) | |
1683 | |
1684 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', 'Query' : { }}) | |
1685 self.assertEqual(4, len(a)) | |
1686 | |
1687 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', 'Query' : { }}) | |
1688 self.assertEqual(8, len(a)) | |
1689 | |
194
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-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' : '20061201-20091201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1699 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1700 for i in range(2): |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1701 self.assertTrue(a[i]['PatientMainDicomTags']['PatientName'] in ['BRAINIX', 'KNEE']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1702 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1703 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1704 'Query' : { 'StudyDate' : '20061202-20061202' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1705 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1706 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1707 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1708 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1709 'Query' : { 'StudyDate' : '-20061201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1710 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1711 self.assertEqual('BRAINIX', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1712 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1713 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1714 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1715 'Query' : { 'StudyDate' : '-20051201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1716 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1717 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1718 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1719 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1720 'Query' : { 'StudyDate' : '20061201-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1721 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1722 for i in range(2): |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1723 self.assertTrue(a[i]['PatientMainDicomTags']['PatientName'] in ['BRAINIX', 'KNEE']) |
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 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1726 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1727 'Query' : { 'StudyDate' : '20061202-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1728 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1729 self.assertEqual('KNEE', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1730 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1731 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1732 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1733 'Query' : { 'StudyDate' : '20080819-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1734 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1735 self.assertEqual('KNEE', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1736 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1737 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1738 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1739 'Query' : { 'StudyDate' : '20080820-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1740 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1741 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1742 |
14 | 1743 |
1744 def test_rest_query_retrieve(self): | |
1745 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1746 | |
1747 # Upload 8 instances | |
1748 for i in range(2): | |
1749 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1750 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1751 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1752 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1753 | |
1754 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
1755 for p in DoGet(_REMOTE, '/patients'): | |
1756 DoPost(_REMOTE, '/modalities/orthanctest/store', p) | |
1757 DoDelete(_REMOTE, '/patients/%s' % p) | |
1758 | |
1759 for q in DoGet(_REMOTE, '/queries'): | |
1760 DoDelete(_REMOTE, '/queries/%s' % q) | |
1761 | |
1762 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1763 self.assertEqual(0, len(DoGet(_REMOTE, '/queries'))) | |
1764 a = DoPost(_REMOTE, '/modalities/orthanctest/query', { 'Level' : 'Series', | |
27 | 1765 'Query' : { |
1766 'PatientName' : '*NE*', | |
1767 'StudyDate' : '*', | |
1768 }})['ID'] | |
14 | 1769 self.assertEqual(1, len(DoGet(_REMOTE, '/queries'))) |
1770 | |
1771 b = DoGet(_REMOTE, '/queries/%s' % a) | |
1772 self.assertTrue('answers' in b) | |
1773 self.assertTrue('level' in b) | |
1774 self.assertTrue('modality' in b) | |
1775 self.assertTrue('query' in b) | |
1776 self.assertTrue('retrieve' in b) | |
1777 self.assertEqual('Series', DoGet(_REMOTE, '/queries/%s/level' % a)) | |
1778 self.assertEqual('orthanctest', DoGet(_REMOTE, '/queries/%s/modality' % a)) | |
1779 | |
1780 q = DoGet(_REMOTE, '/queries/%s/query?simplify' % a) | |
27 | 1781 self.assertEqual(2, len(q)) |
14 | 1782 self.assertTrue('PatientName' in q) |
27 | 1783 self.assertTrue('StudyDate' in q) |
14 | 1784 self.assertEqual('*NE*', q['PatientName']) |
27 | 1785 self.assertEqual('*', q['StudyDate']) |
14 | 1786 |
1787 self.assertEqual(2, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) | |
1788 | |
1789 s = DoGet(_REMOTE, '/queries/%s/answers/0' % a) | |
1790 self.assertTrue('content' in s) | |
1791 self.assertTrue('retrieve' in s) | |
1792 | |
1793 s = DoGet(_REMOTE, '/queries/%s/answers/0/content?simplify' % a) | |
1794 self.assertEqual('887', s['PatientID']) | |
1795 self.assertEqual('2.16.840.1.113669.632.20.121711.10000160881', s['StudyInstanceUID']) | |
1796 | |
1797 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1798 DoPost(_REMOTE, '/queries/%s/answers/0/retrieve' % a, 'ORTHANC') | |
1799 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1800 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
1801 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
1802 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) | |
1803 | |
112 | 1804 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 | 1805 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) |
1806 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
1807 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
1808 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
1809 | |
186
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1810 # 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
|
1811 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
|
1812 self.assertEqual(2, len(s)) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1813 for i in range(2): |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1814 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
|
1815 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
|
1816 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
|
1817 |
14 | 1818 DoDelete(_REMOTE, '/queries/%s' % a) |
1819 self.assertEqual(0, len(DoGet(_REMOTE, '/queries'))) | |
1820 | |
1821 | |
1822 def test_parent(self): | |
1823 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1824 patient = '6816cb19-844d5aee-85245eba-28e841e6-2414fae2' | |
1825 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' | |
1826 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
1827 instance = '66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d' | |
107
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
1828 self.assertEqual(instance, u) |
14 | 1829 |
1830 a = DoGet(_REMOTE, '/studies/%s/patient' % study) | |
1831 self.assertEqual('Patient', a['Type']) | |
1832 self.assertEqual(patient, a['ID']) | |
1833 | |
1834 a = DoGet(_REMOTE, '/series/%s/patient' % series) | |
1835 self.assertEqual('Patient', a['Type']) | |
1836 self.assertEqual(patient, a['ID']) | |
1837 | |
1838 a = DoGet(_REMOTE, '/series/%s/study' % series) | |
1839 self.assertEqual('Study', a['Type']) | |
1840 self.assertEqual(study, a['ID']) | |
1841 | |
1842 a = DoGet(_REMOTE, '/instances/%s/patient' % instance) | |
1843 self.assertEqual('Patient', a['Type']) | |
1844 self.assertEqual(patient, a['ID']) | |
1845 | |
1846 a = DoGet(_REMOTE, '/instances/%s/study' % instance) | |
1847 self.assertEqual('Study', a['Type']) | |
1848 self.assertEqual(study, a['ID']) | |
1849 | |
1850 a = DoGet(_REMOTE, '/instances/%s/series' % instance) | |
1851 self.assertEqual('Series', a['Type']) | |
1852 self.assertEqual(series, a['ID']) | |
1853 | |
1854 | |
1855 def test_shanon(self): | |
1856 def Anonymize(instance, replacements = {}): | |
119 | 1857 return DoPost(_REMOTE, '/instances/%s/anonymize' % instance, { |
1858 'Replace' : replacements, | |
1859 'Force' : True, | |
1860 }, 'application/json') | |
14 | 1861 |
1862 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
1863 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1864 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1865 | |
1866 tags = [ 'PatientID', 'StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID', 'DeidentificationMethod' ] | |
1867 ids = [ 'ozp00SjY2xG', | |
1868 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
1869 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
1870 '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' ] | |
1871 | |
1872 a = ExtractDicomTags(Anonymize(u), tags) | |
1873 for i in range(4): | |
1874 self.assertNotEqual(ids[i], a[i]) | |
1875 self.assertTrue(a[4].startswith('Orthanc')) | |
1876 | |
1877 a = ExtractDicomTags(Anonymize(u, { 'PatientName' : 'toto' }), tags) | |
1878 for i in range(4): | |
1879 self.assertNotEqual(ids[i], a[i]) | |
1880 self.assertFalse(a[4].startswith('Orthanc')) | |
1881 | |
1882 a = ExtractDicomTags(Anonymize(u, { 'SOPInstanceUID' : 'instance' }), tags) | |
1883 self.assertEqual('instance', a[3]) | |
1884 self.assertFalse(a[4].startswith('Orthanc')) | |
1885 | |
1886 a = ExtractDicomTags(Anonymize(u, { 'SeriesInstanceUID' : 'series' }), tags) | |
1887 self.assertEqual('series', a[2]) | |
1888 self.assertFalse(a[4].startswith('Orthanc')) | |
1889 | |
1890 a = ExtractDicomTags(Anonymize(u, { 'StudyInstanceUID' : 'study' }), tags) | |
1891 self.assertEqual('study', a[1]) | |
1892 self.assertFalse(a[4].startswith('Orthanc')) | |
1893 | |
1894 a = ExtractDicomTags(Anonymize(u, { 'PatientID' : 'patient' }), tags) | |
1895 self.assertEqual('patient', a[0]) | |
1896 self.assertFalse(a[4].startswith('Orthanc')) | |
1897 | |
1898 a = ExtractDicomTags(Anonymize(u, { 'PatientID' : 'patient', | |
1899 'StudyInstanceUID' : 'study', | |
1900 'SeriesInstanceUID' : 'series', | |
1901 'SOPInstanceUID' : 'instance' }), tags) | |
1902 self.assertEqual('patient', a[0]) | |
1903 self.assertFalse(a[4].startswith('Orthanc')) | |
1904 | |
1905 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1906 | |
1907 | |
1908 def test_shanon_2(self): | |
1909 def Modify(instance, replacements = {}): | |
119 | 1910 return DoPost(_REMOTE, '/instances/%s/modify' % instance, { |
1911 'Replace' : replacements, | |
1912 'Force': True, | |
1913 }, 'application/json') | |
14 | 1914 |
1915 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
1916 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1917 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1918 | |
1919 tags = [ 'PatientID', 'StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID', 'DeidentificationMethod' ] | |
1920 ids = [ 'ozp00SjY2xG', | |
1921 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
1922 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
1923 '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' ] | |
1924 | |
1925 a = ExtractDicomTags(Modify(u), tags) | |
1926 self.assertEqual(ids[0], a[0]) | |
1927 self.assertEqual(ids[1], a[1]) | |
1928 self.assertEqual(ids[2], a[2]) | |
1929 self.assertNotEqual(ids[3], a[3]) | |
1930 self.assertEqual(0, len(a[4])) | |
1931 | |
1932 a = ExtractDicomTags(Modify(u, { 'SOPInstanceUID' : 'instance' }), tags) | |
1933 self.assertEqual(ids[0], a[0]) | |
1934 self.assertEqual(ids[1], a[1]) | |
1935 self.assertEqual(ids[2], a[2]) | |
1936 self.assertEqual('instance', a[3]) | |
1937 | |
1938 a = ExtractDicomTags(Modify(u, { 'SeriesInstanceUID' : 'series' }), tags) | |
1939 self.assertEqual(ids[0], a[0]) | |
1940 self.assertEqual(ids[1], a[1]) | |
1941 self.assertEqual('series', a[2]) | |
1942 self.assertNotEqual(ids[3], a[3]) | |
1943 | |
1944 a = ExtractDicomTags(Modify(u, { 'StudyInstanceUID' : 'study' }), tags) | |
1945 self.assertEqual(ids[0], a[0]) | |
1946 self.assertEqual('study', a[1]) | |
1947 self.assertNotEqual(ids[2], a[2]) | |
1948 self.assertNotEqual(ids[3], a[3]) | |
1949 | |
1950 a = ExtractDicomTags(Modify(u, { 'PatientID' : 'patient' }), tags) | |
1951 self.assertEqual('patient', a[0]) | |
1952 self.assertNotEqual(ids[1], a[1]) | |
1953 self.assertNotEqual(ids[2], a[2]) | |
1954 self.assertNotEqual(ids[3], a[3]) | |
1955 | |
1956 a = ExtractDicomTags(Modify(u, { 'PatientID' : 'patient', | |
1957 'StudyInstanceUID' : 'study', | |
1958 'SeriesInstanceUID' : 'series', | |
1959 'SOPInstanceUID' : 'instance' }), tags) | |
1960 self.assertEqual('patient', a[0]) | |
1961 self.assertEqual('study', a[1]) | |
1962 self.assertEqual('series', a[2]) | |
1963 self.assertEqual('instance', a[3]) | |
1964 | |
1965 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
1966 | |
1967 | |
1968 def test_instances_tags(self): | |
1969 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1970 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm')['ID'] | |
1971 #a = UploadInstance(_REMOTE, 'Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386937.676343')['ID'] | |
1972 #b = UploadInstance(_REMOTE, 'Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386925.676329')['ID'] | |
1973 | |
1974 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/patients')[0]) | |
1975 self.assertEqual(2, len(i)) | |
1976 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1977 self.assertEqual('887', i[i.keys()[1]]['PatientID']) | |
1978 | |
1979 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/studies')[0]) | |
1980 self.assertEqual(2, len(i)) | |
1981 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1982 self.assertEqual('887', i[i.keys()[1]]['PatientID']) | |
1983 | |
1984 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
1985 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/series')[0]) | |
1986 self.assertEqual(1, len(i)) | |
1987 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1988 | |
1989 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/series')[1]) | |
1990 self.assertEqual(1, len(i)) | |
1991 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
1992 | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1993 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
|
1994 self.assertEqual(1, len(i)) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1995 self.assertEqual('887', i[i.keys()[0]]['0010,0020']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1996 |
14 | 1997 |
1998 def test_lookup(self): | |
1999 a = DoPost(_REMOTE, '/tools/lookup', 'ozp00SjY2xG') | |
2000 self.assertEqual(0, len(a)) | |
2001 | |
2002 UploadInstance(_REMOTE, 'DummyCT.dcm') | |
2003 | |
2004 a = DoPost(_REMOTE, '/tools/lookup', 'ozp00SjY2xG') | |
2005 self.assertEqual(1, len(a)) | |
2006 self.assertEqual('Patient', a[0]['Type']) | |
2007 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', a[0]['ID']) | |
2008 self.assertEqual('/patients/%s' % a[0]['ID'], a[0]['Path']) | |
2009 | |
2010 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390') | |
2011 self.assertEqual(1, len(a)) | |
2012 self.assertEqual('Study', a[0]['Type']) | |
2013 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', a[0]['ID']) | |
2014 self.assertEqual('/studies/%s' % a[0]['ID'], a[0]['Path']) | |
2015 | |
2016 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394') | |
2017 self.assertEqual(1, len(a)) | |
2018 self.assertEqual('Series', a[0]['Type']) | |
2019 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', a[0]['ID']) | |
2020 self.assertEqual('/series/%s' % a[0]['ID'], a[0]['Path']) | |
2021 | |
2022 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109') | |
2023 self.assertEqual(1, len(a)) | |
2024 self.assertEqual('Instance', a[0]['Type']) | |
2025 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', a[0]['ID']) | |
2026 self.assertEqual('/instances/%s' % a[0]['ID'], a[0]['Path']) | |
2027 | |
2028 DropOrthanc(_REMOTE) | |
2029 a = DoPost(_REMOTE, '/tools/lookup', '3113719P') | |
2030 self.assertEqual(0, len(a)) | |
2031 | |
15 | 2032 |
2033 def test_autorouting(self): | |
2034 knee1 = 'Knee/T1/IM-0001-0001.dcm' | |
2035 knee2 = 'Knee/T2/IM-0001-0002.dcm' | |
2036 other = 'Brainix/Flair/IM-0001-0001.dcm' | |
2037 | |
2038 # Check that this version is >= 0.8.0 | |
2039 self.assertTrue(IsDefinedInLua(_REMOTE, '_InitializeJob')) | |
2040 self.assertTrue('orthanctest' in DoGet(_REMOTE, '/modalities')) | |
2041 | |
2042 UploadInstance(_REMOTE, knee1) | |
2043 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
2044 | |
2045 DropOrthanc(_REMOTE) | |
2046 DropOrthanc(_LOCAL) | |
174 | 2047 InstallLuaScriptFromPath(_REMOTE, 'Lua/Autorouting.lua') |
15 | 2048 UploadInstance(_REMOTE, knee1) |
2049 UploadInstance(_REMOTE, knee2) | |
2050 UploadInstance(_REMOTE, other) | |
2051 WaitEmpty(_REMOTE) | |
174 | 2052 UninstallLuaCallbacks(_REMOTE) |
15 | 2053 self.assertEqual(3, len(DoGet(_LOCAL, '/instances'))) |
2054 | |
2055 DropOrthanc(_REMOTE) | |
2056 DropOrthanc(_LOCAL) | |
174 | 2057 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingConditional.lua') |
15 | 2058 UploadInstance(_REMOTE, knee1) |
2059 UploadInstance(_REMOTE, knee2) | |
2060 UploadInstance(_REMOTE, other) | |
2061 WaitEmpty(_REMOTE) | |
174 | 2062 UninstallLuaCallbacks(_REMOTE) |
15 | 2063 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
2064 | |
2065 DropOrthanc(_REMOTE) | |
2066 DropOrthanc(_LOCAL) | |
174 | 2067 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingModification.lua') |
15 | 2068 UploadInstance(_REMOTE, knee1) |
2069 WaitEmpty(_REMOTE) | |
174 | 2070 UninstallLuaCallbacks(_REMOTE) |
15 | 2071 i = DoGet(_LOCAL, '/instances') |
2072 self.assertEqual(1, len(i)) | |
2073 | |
2074 with tempfile.NamedTemporaryFile(delete = True) as f: | |
2075 f.write(DoGet(_LOCAL, '/instances/%s/file' % i[0])) | |
2076 f.flush() | |
45 | 2077 routed = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) |
15 | 2078 self.assertEqual('My Medical Device', re.search('"StationName">(.*?)<', routed).group(1).strip()) |
2079 self.assertEqual(None, re.search('"MilitaryRank"', routed)) | |
2080 self.assertEqual(None, re.search('"0051,0010"', routed)) # A private tag | |
17 | 2081 |
2082 | |
2083 def test_storescu_rf(self): | |
2084 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] | |
2085 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
2086 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
2087 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
18 | 2088 |
2089 | |
2090 def test_anonymize_instance(self): | |
2091 def AnonymizeAndUpload(instanceId, parameters): | |
2092 return DoPost(_REMOTE, '/instances', DoPost(_REMOTE, '/instances/%s/anonymize' % instanceId, parameters, | |
2093 'application/json'), 'application/dicom')['ID'] | |
2094 | |
2095 def ModifyAndUpload(instanceId, parameters): | |
2096 return DoPost(_REMOTE, '/instances', DoPost(_REMOTE, '/instances/%s/modify' % instanceId, parameters, | |
2097 'application/json'), 'application/dicom')['ID'] | |
2098 | |
2099 a = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
2100 s1 = DoGet(_REMOTE, '/instances/%s/content/PatientName' % a) | |
2101 s2 = DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % a) # Some private tag | |
2102 s3 = DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % a) | |
2103 s4 = DoGet(_REMOTE, '/instances/%s/content/SeriesDescription' % a) | |
2104 s5 = DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % a) | |
2105 | |
2106 b = AnonymizeAndUpload(a, '{}') | |
2107 self.assertNotEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2108 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2109 | |
2110 # Keep private tag (only OK since Orthanc 0.8.0) | |
2111 b = AnonymizeAndUpload(a, '{"Keep":["00e1-10c2"]}') | |
2112 self.assertNotEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2113 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2114 | |
2115 b = AnonymizeAndUpload(a, '{"Keep":["00e1,10c2","PatientName"]}') | |
2116 self.assertEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2117 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2118 | |
2119 b = AnonymizeAndUpload(a, '{"Keep":["PatientName"],"Replace":{"00e1,10c2":"Hello"}}') | |
2120 self.assertEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2121 self.assertTrue(DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b).startswith('Hello')) | |
2122 | |
2123 # Examples from the Wiki | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2124 b = AnonymizeAndUpload(a, '{"Replace":{"PatientName":"hello","0010-0020":"world"},"Keep":["StudyDescription", "SeriesDescription"],"KeepPrivateTags": true,"Force":true}') |
18 | 2125 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2126 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2127 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2128 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008,103e' % b)) | |
2129 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008-103E' % b)) | |
2130 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2131 DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % a) | |
2132 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2133 | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2134 b = ModifyAndUpload(a, '{"Replace":{"PatientName":"hello","PatientID":"world"},"Remove":["InstitutionName"],"RemovePrivateTags": true,"Force":true}') |
18 | 2135 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2136 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2137 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2138 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008,103e' % b)) | |
2139 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2140 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2141 | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2142 b = ModifyAndUpload(a, '{"Replace":{"PatientName":"hello","PatientID":"world"},"Force":true}') |
18 | 2143 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2144 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2145 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1,10c2' % b)) | |
2146 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2147 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008-103E' % b)) | |
2148 self.assertEqual(s5, DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2149 | |
2150 | |
2151 # Test modify non-existing | |
2152 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2153 json.dumps({ | |
2154 'PatientName' : 'Jodogne', | |
2155 'Modality' : 'CT', | |
2156 }))['ID'] | |
2157 | |
2158 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i).strip()) | |
2159 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % i)) | |
2160 self.assertEqual('CT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i).strip()) | |
2161 | |
2162 b = ModifyAndUpload(i, '{"Replace":{"StudyDescription":"hello","Modality":"world"}}') | |
2163 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % b).strip()) | |
2164 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % b).strip()) | |
2165 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/Modality' % b).strip()) | |
2166 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2167 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2168 def test_incoming_jpeg(self): |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2169 def storescu(image, acceptUnknownSopClassUid): |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2170 if acceptUnknownSopClassUid: |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2171 tmp = [ '-xf', GetDatabasePath('UnknownSopClassUid.cfg'), 'Default' ] |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2172 else: |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2173 tmp = [ '-xs' ] |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2174 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2175 with open(os.devnull, 'w') as FNULL: |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2176 subprocess.check_call([ FindExecutable('storescu') ] + tmp + |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2177 [ _REMOTE['Server'], str(_REMOTE['DicomPort']), |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2178 GetDatabasePath(image) ], |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2179 stderr = FNULL) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2180 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2181 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
174 | 2182 InstallLuaScriptFromPath(_REMOTE, 'Lua/TransferSyntaxDisable.lua') |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2183 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
|
2184 self.assertRaises(Exception, lambda: storescu('UnknownSopClassUid.dcm', True)) |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2185 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
174 | 2186 InstallLuaScriptFromPath(_REMOTE, 'Lua/TransferSyntaxEnable.lua') |
62
f9c4ce95756f
removal of useless information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
61
diff
changeset
|
2187 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
|
2188 storescu('Knix/Loc/IM-0001-0001.dcm', False) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2189 storescu('UnknownSopClassUid.dcm', True) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2190 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2191 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2192 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2193 def test_storescu_jpeg(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2194 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
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 knixStudy = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' |
64 | 2197 i = UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm')['ID'] |
2198 | |
2199 # This is JPEG lossless | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2200 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header' % i)['0002,0010']['Value']) |
64 | 2201 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
|
2202 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header?short' % i)['0002,0010']) |
64 | 2203 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2204 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0002.dcm') |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2205 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0003.dcm') |
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 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
|
2208 b = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2209 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2210 DoPost(_REMOTE, '/modalities/orthanctest/store', [ knixStudy, a, b ]) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2211 self.assertEqual(5, len(DoGet(_LOCAL, '/instances'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2212 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2213 self.assertEqual(3, len(DoGet(_REMOTE, '/exports')['Exports'])) |
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 DropOrthanc(_REMOTE) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2216 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
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 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2219 def test_pixel_data(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2220 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
|
2221 color = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2222 phenix = UploadInstance(_REMOTE, 'Phenix/IM-0001-0001.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2223 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2224 phenixSize = 358 * 512 * 2 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2225 colorSize = 1000 * 1000 * 3 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2226 jpegSize = 51918 |
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 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
|
2229 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
|
2230 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
|
2231 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2232 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
|
2233 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
|
2234 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2235 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
|
2236 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
|
2237 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2238 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2239 def test_decode_brainix(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2240 brainix = [ |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2241 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'], # (*) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2242 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
|
2243 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
|
2244 ] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2245 h = '6fb11b932d535c2be04beabd99793ff8' |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2246 maxValue = 426.0 |
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 truth = Image.open(GetDatabasePath('Formats/Brainix.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2249 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2250 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2251 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2252 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2253 truth2 = map(lambda x: min(255, x), truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2254 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2255 self.AssertSameImages(truth2, '/instances/%s/image-uint8' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2256 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2257 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
|
2258 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2259 self.AssertSameImages(truth2, '/instances/%s/preview' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2260 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2261 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2262 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
|
2263 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2264 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2265 def test_decode_color(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2266 imagej = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2267 color = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2268 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2269 for i in [ imagej, color ]: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2270 for j in [ 'image-uint8', 'image-uint16', 'image-int16' ]: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2271 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
|
2272 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2273 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
|
2274 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
|
2275 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2276 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
|
2277 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
|
2278 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2279 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2280 def test_decode_rf(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2281 rf = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2282 truth = Image.open(GetDatabasePath('Formats/KarstenHilbertRF.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2283 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2284 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint8' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2285 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2286 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2287 self.AssertSameImages(truth.getdata(), '/instances/%s/preview' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2288 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2289 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
|
2290 |
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 def test_decode_multiframe(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2293 mf = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2294 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2295 # Test the first frame |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2296 truth = Image.open(GetDatabasePath('Formats/Multiframe0.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2297 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint8' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2298 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2299 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2300 self.AssertSameImages(truth.getdata(), '/instances/%s/preview' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2301 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
|
2302 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2303 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
|
2304 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2305 # Test the last frame |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2306 truth = Image.open(GetDatabasePath('Formats/Multiframe75.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2307 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
|
2308 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2309 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2310 def test_decode_signed(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2311 signed = UploadInstance(_REMOTE, 'SignedCT.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2312 minValue = -2000 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2313 maxValue = 4042 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2314 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2315 truth = Image.open(GetDatabasePath('Formats/SignedCT.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2316 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2317 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2318 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
|
2319 self.AssertSameImages(truth2, '/instances/%s/image-uint16' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2320 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2321 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
|
2322 self.AssertSameImages(truth3, '/instances/%s/image-uint8' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2323 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2324 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
|
2325 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
|
2326 self.AssertSameImages(tmp, '/instances/%s/preview' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2327 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2328 self.assertEqual('b57e6c872a3da50877c7da689b03a444', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % signed))) |
22 | 2329 |
2330 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
2331 def test_googlecode_issue_32(self): |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2332 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/tools/default-encoding', 'nope')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2333 self.assertEqual('Windows1251', DoPut(_REMOTE, '/tools/default-encoding', 'Windows1251')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2334 self.assertEqual('Windows1251', DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2335 |
22 | 2336 f = UploadInstance(_REMOTE, 'Issue32.dcm')['ID'] |
2337 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % f) | |
2338 self.assertEqual(u'Рентгенография', tags['SeriesDescription']) | |
2339 self.assertEqual(u'Таз', tags['BodyPartExamined']) | |
2340 self.assertEqual(u'Прямая', tags['ViewPosition']) | |
2341 | |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2342 # 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
|
2343 self.assertEqual('Latin1', DoPut(_REMOTE, '/tools/default-encoding', 'Latin1')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2344 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2345 DoDelete(_REMOTE, '/instances/%s' % f) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2346 f = UploadInstance(_REMOTE, 'Issue32.dcm')['ID'] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2347 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % f) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2348 self.assertNotEqual(u'Рентгенография', tags['SeriesDescription']) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2349 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2350 |
22 | 2351 def test_encodings(self): |
23 | 2352 # Latin-1 (ISO_IR 100) |
22 | 2353 brainix = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
2354 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % brainix) | |
2355 self.assertEqual(u'IRM cérébrale, neuro-crâne', tags['StudyDescription']) | |
23 | 2356 |
2357 # Latin-2 (ISO_IR 101) | |
2358 a = UploadInstance(_REMOTE, 'MarekLatin2.dcm')['ID'] | |
2359 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % a) | |
2360 # dcm2xml MarekLatin2.dcm | iconv -f latin2 -t utf-8 | xmllint --format - | |
2361 self.assertEqual('Imię i Nazwisko osoby opisującej', | |
2362 i['ContentSequence'][4]['ConceptNameCodeSequence'][0]['CodeMeaning'].encode('utf-8')) | |
2363 | |
26
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 def test_storescu_custom_aet(self): |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2366 # 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
|
2367 # 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
|
2368 # in the REST API)." |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2369 # 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
|
2370 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2371 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2372 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2373 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2374 b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2375 c = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0003.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2376 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2377 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2378 'LocalAet' : 'YOP', |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2379 'Resources' : [ a['ID'], b['ID'] ] |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2380 }) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2381 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2382 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2383 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
|
2384 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2385 DropOrthanc(_LOCAL) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2386 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2387 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2388 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2389 'Resources' : [ c['ID'] ] |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2390 }) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2391 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2392 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2393 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
|
2394 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2395 DropOrthanc(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2396 DropOrthanc(_LOCAL) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2397 |
174 | 2398 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingChangeAet.lua') |
26
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2399 DoPost(_REMOTE, '/tools/execute-script', 'aet = "HELLO"', 'application/lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2400 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2401 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2402 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2403 WaitEmpty(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2404 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2405 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
|
2406 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2407 DoPost(_REMOTE, '/tools/execute-script', 'aet = nill', 'application/lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2408 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2409 WaitEmpty(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2410 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2411 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
|
2412 |
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 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
|
2414 # 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
|
2415 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
|
2416 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
|
2417 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
|
2418 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
|
2419 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
|
2420 |
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(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
|
2422 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
|
2423 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
|
2424 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
|
2425 |
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.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
|
2427 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
|
2428 |
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 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
|
2430 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
|
2431 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
|
2432 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
|
2433 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
|
2434 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
|
2435 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
|
2436 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
|
2437 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
|
2438 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
|
2439 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
|
2440 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
|
2441 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
|
2442 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
|
2443 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
|
2444 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2445 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
|
2446 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
|
2447 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
|
2448 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
|
2449 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
|
2450 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
|
2451 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
|
2452 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2453 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
|
2454 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
|
2455 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
|
2456 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2457 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
|
2458 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
|
2459 self.assertTrue(instance in s) |
36 | 2460 |
2461 | |
2462 def test_create_pdf(self): | |
2463 # Upload 4 instances | |
2464 brainixInstance = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] | |
2465 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
2466 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
2467 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
2468 | |
2469 brainixPatient = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' | |
2470 brainixStudy = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' | |
2471 brainixEpi = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
2472 | |
2473 with open(GetDatabasePath('HelloWorld.pdf'), 'rb') as f: | |
2474 pdf = f.read() | |
2475 | |
2476 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2477 json.dumps({ | |
2478 'Tags' : { | |
2479 'PatientName' : 'Jodogne', | |
2480 'Modality' : 'CT', | |
2481 }, | |
2482 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2483 })) | |
2484 | |
2485 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2486 self.assertEqual('OT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i['ID']).strip()) | |
2487 | |
2488 b = DoGet(_REMOTE, '/instances/%s/content/0042-0011' % i['ID']) | |
2489 self.assertEqual(len(b), len(pdf) + 1) | |
2490 self.assertEqual(ComputeMD5(b), ComputeMD5(pdf + '\0')) | |
2491 | |
2492 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/tools/create-dicom', | |
2493 json.dumps({ | |
2494 'Parent' : brainixPatient, | |
2495 'Tags' : { | |
2496 'PatientName' : 'Jodogne', | |
2497 } | |
2498 }))) | |
2499 | |
2500 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2501 json.dumps({ | |
2502 'Parent' : brainixPatient, | |
2503 'Tags' : { 'StudyDescription' : 'PDF^Patient' }, | |
2504 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2505 })) | |
2506 | |
2507 self.assertEqual(brainixPatient, DoGet(_REMOTE, '/instances/%s/patient' % i['ID'])['ID']) | |
2508 | |
2509 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2510 json.dumps({ | |
2511 'Parent' : brainixStudy, | |
2512 'Tags' : { 'SeriesDescription' : 'PDF^Study' }, | |
2513 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2514 })) | |
2515 | |
2516 self.assertEqual(brainixStudy, DoGet(_REMOTE, '/instances/%s/study' % i['ID'])['ID']) | |
2517 | |
2518 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2519 json.dumps({ | |
2520 'Parent' : brainixEpi, | |
37 | 2521 'Tags' : { 'SpecificCharacterSet' : 'ISO_IR 13' }, |
36 | 2522 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) |
2523 })) | |
2524 | |
2525 self.assertEqual(brainixEpi, DoGet(_REMOTE, '/instances/%s/series' % i['ID'])['ID']) | |
2526 | |
2527 b = DoGet(_REMOTE, '/instances/%s/pdf' % i['ID']) | |
2528 self.assertEqual(len(b), len(pdf)) | |
2529 self.assertEqual(ComputeMD5(b), ComputeMD5(pdf)) | |
2530 | |
2531 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/pdf' % brainixInstance)) | |
38 | 2532 |
2533 | |
2534 def test_create_series(self): | |
2535 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2536 json.dumps({ | |
2537 'Tags' : { | |
40 | 2538 'SpecificCharacterSet' : 'ISO_IR 100', |
2539 'PatientName' : 'Sébastien Jodogne', | |
38 | 2540 'Modality' : 'CT', |
2541 }, | |
2542 'Content' : [ | |
40 | 2543 { |
2544 'Content': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', # red dot in RGBA | |
2545 'Tags' : { 'ImageComments' : 'Tutu' } | |
2546 }, | |
38 | 2547 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAoUlEQVQ4jZ2SWw3EIBREjwUsYAELa2EtoAULFUCyXAtroRZqoRbox254BdLC/DZnZjoXWJFgCDg8egW2CBEhEnDzyRk+Ecxz2KP/0AL8S99T+jQccAVs22qKwAuPuq0uyNg9cPLh3am+pe/dkHLZtqJHj6vXJrZ7nvzvxxgemXgUwnGfXqpee09mUwp8m022OYP6bLF7mVuVe0y/umxinsAXRd9z0k1ubWsAAAAASUVORK5CYII=', |
2548 ] | |
2549 })) | |
2550 | |
2551 s = DoGet(_REMOTE, i['Path']) | |
2552 self.assertEqual('Series', s['Type']) | |
2553 self.assertEqual(s['ID'], i['ID']) | |
2554 self.assertEqual(2, len(s['Instances'])) | |
39 | 2555 self.assertEqual(2, s['ExpectedNumberOfInstances']) |
2556 self.assertEqual('Complete', s['Status']) | |
40 | 2557 |
2558 a = DoGet(_REMOTE, '/instances/%s/tags?simplify' % s['Instances'][0]) | |
2559 b = DoGet(_REMOTE, '/instances/%s/tags?simplify' % s['Instances'][1]) | |
2560 self.assertTrue('ImageComments' in a or 'ImageComments' in b) | |
2561 if 'ImageComments' in a: | |
2562 self.assertEqual('Tutu', a['ImageComments']) | |
2563 else: | |
2564 self.assertEqual('Tutu', b['ImageComments']) | |
2565 | |
2566 patient = DoGet(_REMOTE, '/instances/%s/patient' % s['Instances'][0]) | |
2567 self.assertEqual(patient['MainDicomTags']['PatientName'].encode('utf-8'), | |
2568 'Sébastien Jodogne') | |
47 | 2569 |
2570 | |
2571 def test_create_binary(self): | |
2572 binary = ''.join(map(chr, range(256))) | |
2573 encoded = 'data:application/octet-stream;base64,' + base64.b64encode(binary) | |
2574 tags = { | |
2575 'PatientName' : 'Jodogne', | |
2576 '8899-8899' : encoded | |
2577 } | |
2578 | |
2579 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2580 json.dumps({ | |
2581 'Tags' : tags | |
2582 })) | |
2583 | |
2584 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2585 self.assertEqual(binary, DoGet(_REMOTE, '/instances/%s/content/8899-8899' % i['ID']).strip()) | |
2586 | |
2587 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2588 json.dumps({ | |
2589 'InterpretBinaryTags' : False, | |
2590 'Tags' : tags | |
2591 })) | |
2592 | |
2593 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2594 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
|
2595 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2596 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2597 def test_patient_ids_collision(self): |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2598 # 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
|
2599 # same PatientID |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2600 for i in range(3): |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2601 UploadInstance(_REMOTE, 'PatientIdsCollision/Image%d.dcm' % (i + 1)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2602 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2603 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2604 'Query' : { 'PatientName' : '*' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2605 self.assertEqual(1, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2606 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
|
2607 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2608 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2609 'CaseSensitive' : True, |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2610 'Query' : { 'PatientName' : 'FOO\\HELLO' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2611 self.assertEqual(2, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2612 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2613 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2614 'CaseSensitive' : False, |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2615 'Query' : { 'PatientName' : 'Foo' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2616 self.assertEqual(1, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2617 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
|
2618 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
|
2619 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
|
2620 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2621 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2622 'Query' : { 'PatientName' : '*' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2623 self.assertEqual(3, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2624 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
|
2625 self.assertTrue('FOO^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2626 self.assertTrue('HELLO^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2627 self.assertTrue('WORLD^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2628 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2629 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
|
2630 self.assertEqual(1, len(set(d))) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2631 self.assertEqual('COMMON', d[0]) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2632 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2633 for i in a: |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2634 d = DoGet(_REMOTE, '/studies/%s' % i) ['MainDicomTags']['StudyDescription'] |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2635 p = DoGet(_REMOTE, '/studies/%s' % i) ['PatientMainDicomTags']['PatientName'] |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2636 self.assertEqual('%s^SERIES' % p, d) |
49
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2637 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2638 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2639 def test_bitbucket_issue_4(self): |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2640 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2641 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2642 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0003.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2643 UploadInstance(_REMOTE, 'Formats/Jpeg.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2644 UploadInstance(_REMOTE, 'Formats/JpegLossless.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2645 UploadInstance(_REMOTE, 'Formats/Rle.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2646 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2647 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2648 self.assertEqual(6, len(DoGet(_REMOTE, '/instances'))) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2649 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2650 p = DoGet(_REMOTE, '/patients') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2651 self.assertEqual(2, len(p)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2652 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
|
2653 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
|
2654 self.assertEqual(3, len(i1)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2655 self.assertEqual(3, len(i2)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2656 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2657 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
|
2658 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2659 self.assertEqual(6, len(DoGet(_LOCAL, '/instances'))) |
50
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2660 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2661 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2662 def test_create_sequence(self): |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2663 i = DoPost(_REMOTE, '/tools/create-dicom', |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2664 json.dumps({ |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2665 'Tags' : { |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2666 'SpecificCharacterSet': 'ISO_IR 100', # Encode using Latin1 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2667 'PatientName': 'Jodogne^', |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2668 'ReferencedStudySequence': GenerateTestSequence(), |
50
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2669 } |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2670 }))['ID'] |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2671 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2672 self.assertEqual('Jodogne^', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2673 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
|
2674 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
|
2675 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
|
2676 self.assertEqual(u'Sébastien^'.encode('latin-1'), |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2677 DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/1/StudyDescription' % i)) |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2678 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2679 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2680 def test_modify_sequence(self): |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2681 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2682 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
|
2683 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2684 j = DoPost(_REMOTE, '/instances/%s/modify' % i, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2685 json.dumps({ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2686 "Replace" : { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2687 "PatientName" : "hello", |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2688 'ReferencedStudySequence': GenerateTestSequence(), |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2689 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2690 }), |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2691 'application/json') |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2692 j = DoPost(_REMOTE, '/instances', j, 'application/dicom')['ID'] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2693 DoDelete(_REMOTE, '/instances/%s' % i) |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2694 |
52 | 2695 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence' % j))) |
2696 | |
2697 | |
2698 def test_compression(self): | |
2699 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
2700 | |
2701 data = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % i)[1] | |
2702 | |
2703 # "StorageCompression" is enabled in the Orthanc to be tested, | |
2704 # uncompress the data before running the test | |
2705 if DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i) != 0: | |
2706 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/uncompress' % i) | |
2707 | |
2708 cs = DoGet(_REMOTE, '/statistics')['TotalDiskSize'] | |
2709 us = DoGet(_REMOTE, '/statistics')['TotalUncompressedSize'] | |
2710 size = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i) | |
2711 md5 = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i) | |
2712 self.assertEqual(data, DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1]) | |
2713 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2714 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2715 | |
2716 ops = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json' % i) | |
2717 self.assertTrue('compress' in ops) | |
2718 self.assertTrue('uncompress' in ops) | |
2719 self.assertTrue('is-compressed' in ops) | |
2720 self.assertEqual(0, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2721 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2722 | |
2723 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/compress' % i) | |
2724 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2725 self.assertEqual(1, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2726 self.assertLess(cs, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
2727 self.assertEqual(us, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
2728 self.assertGreater(len(data), len(DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1])) | |
2729 self.assertGreater(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2730 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i)) | |
2731 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i)) | |
2732 self.assertNotEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2733 | |
2734 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/uncompress' % i) | |
2735 DoPost(_REMOTE, '/instances/%s/attachments/dicom-as-json/verify-md5' % i) | |
2736 self.assertEqual(0, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/is-compressed' % i)) | |
2737 self.assertEqual(data, DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-data' % i)[1]) | |
2738 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-size' % i)) | |
2739 self.assertEqual(size, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % i)) | |
2740 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/md5' % i)) | |
2741 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/compressed-md5' % i)) | |
2742 self.assertEqual(cs, DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
2743 self.assertEqual(us, DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
53 | 2744 |
2745 | |
2746 def test_ordered_slices(self): | |
2747 i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] | |
2748 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2749 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2750 self.assertEqual('Sequence', o['Type']) | |
2751 self.assertEqual(1, len(o['Dicom'])) | |
2752 self.assertEqual('/instances/9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02/file', o['Dicom'][0]) | |
2753 self.assertEqual(76, len(o['Slices'])) | |
2754 for j in range(76): | |
2755 self.assertEqual('/instances/9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02/frames/%d' % j, o['Slices'][j]) | |
2756 | |
68 | 2757 self.assertEqual(1, len(o['SlicesShort'])) |
2758 self.assertEqual('9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02', o['SlicesShort'][0][0]) | |
2759 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2760 self.assertEqual(76, o['SlicesShort'][0][2]) | |
2761 | |
53 | 2762 i = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
2763 j = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm')['ID'] | |
2764 k = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0003.dcm')['ID'] | |
2765 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2766 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2767 | |
2768 self.assertEqual('Volume', o['Type']) | |
2769 self.assertEqual(3, len(o['Dicom'])) | |
2770 self.assertEqual(3, len(o['Slices'])) | |
2771 self.assertEqual('/instances/%s/file' % i, o['Dicom'][2]) | |
2772 self.assertEqual('/instances/%s/file' % j, o['Dicom'][1]) | |
2773 self.assertEqual('/instances/%s/file' % k, o['Dicom'][0]) | |
2774 self.assertEqual('/instances/%s/frames/0' % i, o['Slices'][2]) | |
2775 self.assertEqual('/instances/%s/frames/0' % j, o['Slices'][1]) | |
2776 self.assertEqual('/instances/%s/frames/0' % k, o['Slices'][0]) | |
2777 | |
68 | 2778 self.assertEqual(3, len(o['SlicesShort'])) |
2779 self.assertEqual(k, o['SlicesShort'][0][0]) | |
2780 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2781 self.assertEqual(1, o['SlicesShort'][0][2]) | |
2782 self.assertEqual(j, o['SlicesShort'][1][0]) | |
2783 self.assertEqual(0, o['SlicesShort'][1][1]) | |
2784 self.assertEqual(1, o['SlicesShort'][1][2]) | |
2785 self.assertEqual(i, o['SlicesShort'][2][0]) | |
2786 self.assertEqual(0, o['SlicesShort'][2][1]) | |
2787 self.assertEqual(1, o['SlicesShort'][2][2]) | |
2788 | |
53 | 2789 i = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] |
2790 j = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0002.dcm')['ID'] | |
2791 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2792 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2793 | |
2794 self.assertEqual('Sequence', o['Type']) | |
2795 self.assertEqual(2, len(o['Dicom'])) | |
2796 self.assertEqual(2, len(o['Slices'])) | |
2797 self.assertEqual('/instances/%s/file' % i, o['Dicom'][0]) | |
2798 self.assertEqual('/instances/%s/file' % j, o['Dicom'][1]) | |
2799 self.assertEqual('/instances/%s/frames/0' % i, o['Slices'][0]) | |
2800 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
|
2801 |
68 | 2802 self.assertEqual(2, len(o['SlicesShort'])) |
2803 self.assertEqual(i, o['SlicesShort'][0][0]) | |
2804 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2805 self.assertEqual(1, o['SlicesShort'][0][2]) | |
2806 self.assertEqual(j, o['SlicesShort'][1][0]) | |
2807 self.assertEqual(0, o['SlicesShort'][1][1]) | |
2808 self.assertEqual(1, o['SlicesShort'][1][2]) | |
2809 | |
2810 | |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2811 |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2812 def test_incoming_movescu_accession(self): |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2813 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2814 |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2815 # No matching patient, so no job is created |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2816 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2817 CallMoveScu([ '--study', '-k', '0008,0052=STUDY', '-k', 'AccessionNumber=nope' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2818 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2819 CallMoveScu([ '--study', '-k', '0008,0052=PATIENT', '-k', 'AccessionNumber=A10003245599' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2820 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2821 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2822 # 1 Matching patient, track the job |
138 | 2823 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
2824 '--study', | |
2825 '-k', '0008,0052=STUDY', | |
2826 '-k', 'AccessionNumber=A10003245599' | |
2827 ]))) | |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
2828 |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2829 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
2830 |
55 | 2831 |
2832 def test_dicom_to_json(self): | |
2833 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
|
2834 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
|
2835 |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2836 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
|
2837 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
|
2838 self.assertTrue(CompareTags(t, json.loads(f.read()), [ |
123 | 2839 # Tags for compatibility with DCMTK 3.6.0 |
2840 'RETIRED_OtherPatientIDs', | |
2841 'OtherPatientIDs', | |
2842 'ACR_NEMA_2C_VariablePixelDataGroupLength', | |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
2843 ])) |
55 | 2844 |
2845 t = DoGet(_REMOTE, '/instances/%s/tags' % i) | |
2846 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
|
2847 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
|
2848 ])) |
55 | 2849 |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2850 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
|
2851 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
|
2852 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
|
2853 ])) |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2854 |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
2855 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
|
2856 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
|
2857 a = json.loads(f.read()) |
65
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
2858 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
|
2859 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
|
2860 self.assertEqual(aa, tt) |
57 | 2861 |
2862 | |
2863 def test_batch_archive(self): | |
2864 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
2865 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') | |
2866 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
2867 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0002.dcm') | |
2868 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
2869 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm') | |
2870 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
2871 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0002.dcm') | |
2872 | |
2873 s = DoPost(_REMOTE, '/tools/create-archive', [ ]) | |
2874 z = zipfile.ZipFile(StringIO(s), "r") | |
2875 self.assertEqual(0, len(z.namelist())) | |
2876 | |
2877 # One patient | |
2878 s = DoPost(_REMOTE, '/tools/create-archive', [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ]) | |
2879 z = zipfile.ZipFile(StringIO(s), "r") | |
2880 self.assertEqual(4, len(z.namelist())) | |
2881 | |
2882 # One patient + twice its study + one series from other patient | |
2883 s = DoPost(_REMOTE, '/tools/create-archive', [ | |
2884 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
2885 '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918', | |
2886 '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
2887 ]) | |
2888 z = zipfile.ZipFile(StringIO(s), "r") | |
2889 self.assertEqual(6, len(z.namelist())) | |
2890 | |
2891 # One patient + one series + one instance | |
2892 s = DoPost(_REMOTE, '/tools/create-archive', [ | |
2893 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
2894 '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0', | |
2895 '1d429ccb-bdcc78a1-7d129d6a-ba4966ed-fe4dbd87' | |
2896 ]) | |
2897 z = zipfile.ZipFile(StringIO(s), "r") | |
2898 self.assertEqual(7, len(z.namelist())) | |
59
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2899 |
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 def test_decode_brainix_as_jpeg(self): |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2902 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
|
2903 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2904 j = GetImage(_REMOTE, '/instances/%s/preview' % i) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2905 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2906 self.assertEqual(j.size[0], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2907 self.assertEqual(j.size[1], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2908 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2909 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
|
2910 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2911 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2912 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
|
2913 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2914 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2915 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
|
2916 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2917 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2918 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
|
2919 self.assertEqual('JPEG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2920 self.assertEqual(j.size[0], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2921 self.assertEqual(j.size[1], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2922 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2923 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
|
2924 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
|
2925 self.assertLess(a, b) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2926 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2927 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
|
2928 self.assertEqual('JPEG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2929 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2930 # 16bit encoding is not supported with JPEG |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2931 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
|
2932 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
|
2933 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2934 # No matching content type |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
2935 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
|
2936 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2937 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2938 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2939 def test_media_encodings(self): |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2940 ascii = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2941 latin1 = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2942 latin2 = UploadInstance(_REMOTE, 'MarekLatin2.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2943 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2944 tmp = DoPost(_REMOTE, '/tools/create-media', [ascii,latin1,latin2]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2945 z = zipfile.ZipFile(StringIO(tmp), "r") |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2946 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2947 self.assertEqual(4, len(z.namelist())) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2948 self.assertTrue('IMAGES/IM0' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2949 self.assertTrue('IMAGES/IM1' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2950 self.assertTrue('IMAGES/IM2' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2951 self.assertTrue('DICOMDIR' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2952 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2953 try: |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2954 os.remove('/tmp/DICOMDIR') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2955 except: |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2956 # The file does not exist |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2957 pass |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2958 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2959 z.extract('DICOMDIR', '/tmp') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2960 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2961 stderr = subprocess.STDOUT).split('\n') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2962 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2963 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2964 stderr = subprocess.STDOUT).split('\n') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2965 self.assertEqual(1, len(a)) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2966 self.assertEqual('', a[0]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2967 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2968 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2969 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
|
2970 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
|
2971 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
|
2972 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
2973 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
|
2974 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2975 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2976 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
|
2977 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
|
2978 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
|
2979 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
|
2980 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2981 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
|
2982 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
|
2983 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
|
2984 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
|
2985 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2986 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
|
2987 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
|
2988 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
|
2989 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
|
2990 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2991 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
|
2992 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
|
2993 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
|
2994 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
|
2995 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
2996 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
|
2997 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
|
2998 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
|
2999 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
|
3000 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3001 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
|
3002 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
|
3003 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
|
3004 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
|
3005 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3006 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
|
3007 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
|
3008 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
|
3009 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
|
3010 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
|
3011 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3012 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
|
3013 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
|
3014 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
|
3015 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
|
3016 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
|
3017 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
|
3018 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3019 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
|
3020 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
|
3021 self.assertEqual(1, len(s)) |
176
48cc188ffb09
strip trailing 0 char that appears with some findscu versions
am@osimis.io
parents:
175
diff
changeset
|
3022 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
|
3023 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
|
3024 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
|
3025 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3026 |
78
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3027 def test_decode_transfer_syntax(self): |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3028 def Check(t, md5): |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3029 i = UploadInstance(_REMOTE, 'TransferSyntaxes/%s.dcm' % t)['ID'] |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3030 |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3031 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
|
3032 transferSyntax = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % i) |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3033 self.assertEqual(t, transferSyntax) |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3034 |
78
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3035 if md5 == None: |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3036 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
|
3037 else: |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3038 m = ComputeMD5(DoGet(_REMOTE, '/instances/%s/preview' % i)) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3039 self.assertEqual(m, md5) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3040 |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3041 Check('1.2.840.10008.1.2.1', 'fae08d5415c4c0cd2cdbae4522408631') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3042 Check('1.2.840.10008.1.2.2', 'f3d9784768b8feb54d6a50b6d5c37682') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3043 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
|
3044 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
|
3045 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
|
3046 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
|
3047 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
|
3048 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
|
3049 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
|
3050 Check('1.2.840.10008.1.2', 'd54aed9f67a100984b42942cc2e9939b') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3051 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
|
3052 Check('1.2.840.10008.1.2.4.91', None) # JPEG-2000 image, not supported |
79 | 3053 |
3054 | |
3055 def test_raw_frame(self): | |
3056 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] | |
3057 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3058 a = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3059 self.assertEqual(512 * 512 * 2, len(a)) | |
3060 self.assertEqual(512 * 512 * 2, len(DoGet(_REMOTE, '/instances/%s/frames/23/raw' % s))) | |
3061 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/24/raw' % s)) | |
3062 self.assertEqual('1914287dc4d958eca21fdaacfb3482fa', ComputeMD5(a)) | |
3063 | |
3064 s = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] | |
3065 self.assertEqual(76, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3066 self.assertEqual(186274, len(DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s))) | |
3067 self.assertEqual(189424, len(DoGet(_REMOTE, '/instances/%s/frames/75/raw' % s))) | |
3068 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/76/raw' % s)) | |
3069 im = GetImage(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3070 self.assertEqual("L", im.mode) | |
3071 self.assertEqual(512, im.size[0]) | |
3072 self.assertEqual(512, im.size[1]) | |
3073 | |
3074 # Test an image with 2 JPEG frames spread over multiple fragments | |
3075 s = UploadInstance(_REMOTE, 'LenaTwiceWithFragments.dcm')['ID'] | |
3076 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3077 a = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3078 b = DoGet(_REMOTE, '/instances/%s/frames/1/raw' % s) | |
3079 self.assertEqual(69214, len(a)) | |
3080 self.assertEqual(ComputeMD5(a), ComputeMD5(b)) | |
3081 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/2/raw' % s)) | |
3082 im = GetImage(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3083 self.assertEqual("RGB", im.mode) | |
3084 self.assertEqual(512, im.size[0]) | |
3085 self.assertEqual(512, im.size[1]) | |
3086 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % s) | |
3087 self.assertEqual("RGB", im.mode) | |
3088 self.assertEqual(512, im.size[0]) | |
3089 self.assertEqual(512, im.size[1]) | |
81 | 3090 |
3091 | |
3092 | |
3093 def test_rest_movescu(self): | |
3094 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3095 | |
3096 # Upload 4 instances | |
3097 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
3098 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0002.dcm') | |
3099 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
3100 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
3101 | |
3102 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3103 for p in DoGet(_REMOTE, '/patients'): | |
3104 DoPost(_REMOTE, '/modalities/orthanctest/store', p) | |
3105 DoDelete(_REMOTE, '/patients/%s' % p) | |
3106 | |
3107 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3108 | |
3109 # Upload instance Brainix/Flair/IM-0001-0001.dcm | |
3110 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Instance', | |
3111 'Resources' : [ | |
3112 { | |
3113 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3114 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497', | |
3115 'SOPInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549', | |
3116 } | |
3117 ]}) | |
3118 | |
3119 # Upload series Brainix/Flair/* | |
3120 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3121 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3122 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
3123 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
3124 | |
3125 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Series', | |
3126 'Resources' : [ | |
3127 { | |
3128 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3129 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497', | |
3130 } | |
3131 ]}) | |
3132 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3133 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3134 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
3135 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) | |
3136 | |
3137 # Upload series Brainix/Epi/* | |
3138 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Series', | |
3139 'Resources' : [ | |
3140 { | |
3141 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3142 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314125550', | |
3143 } | |
3144 ]}) | |
3145 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3146 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3147 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
3148 self.assertEqual(3, len(DoGet(_REMOTE, '/instances'))) | |
3149 | |
3150 # Upload study Knee/* | |
3151 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Study', | |
3152 'Resources' : [ | |
3153 { | |
3154 'StudyInstanceUID' : '2.16.840.1.113669.632.20.121711.10000160881', | |
3155 } | |
3156 ]}) | |
3157 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3158 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) | |
3159 self.assertEqual(3, len(DoGet(_REMOTE, '/series'))) | |
3160 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
3161 | |
3162 # Reset | |
3163 for p in DoGet(_REMOTE, '/patients'): | |
3164 DoDelete(_REMOTE, '/patients/%s' % p) | |
3165 | |
3166 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3167 | |
3168 | |
3169 # Upload all at once | |
3170 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Study', | |
3171 'Resources' : [ | |
3172 { | |
3173 'StudyInstanceUID' : '2.16.840.1.113669.632.20.121711.10000160881', | |
3174 }, | |
3175 { | |
3176 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3177 } | |
3178 ]}) | |
3179 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3180 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) | |
3181 self.assertEqual(3, len(DoGet(_REMOTE, '/series'))) | |
3182 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
3183 | |
86
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 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3186 def test_reconstruct_json(self): |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3187 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3188 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3189 instance = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3190 first = DoGet(_REMOTE, '/instances/%s/tags' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3191 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3192 self.assertEqual('TWINOW', first['0008,1010']['Value']) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3193 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3194 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3195 # Cannot delete the "DICOM" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3196 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
|
3197 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3198 # Can delete the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3199 r = DoDelete(_REMOTE, '/instances/%s/attachments/dicom-as-json' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3200 self.assertTrue(type(r) is dict and len(r) == 0) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3201 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3202 # Only the "DICOM" attachment subsists |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3203 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3204 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3205 # Cannot manually reconstruct the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3206 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
|
3207 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3208 # Transparently reconstruct the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3209 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
|
3210 second = DoGet(_REMOTE, '/instances/%s/tags' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3211 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3212 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3213 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
|
3214 self.assertEqual(str(first), str(second)) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3215 self.assertEqual(str(first), str(third)) |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3216 |
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 def test_reconstruct_json2(self): |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3219 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
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 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
|
3222 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
|
3223 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3224 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
|
3225 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
|
3226 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3227 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
|
3228 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
|
3229 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3230 DoPost(_REMOTE, '/tools/invalidate-tags', '', 'text/plain') |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3231 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3232 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
|
3233 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
|
3234 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3235 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
|
3236 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
|
3237 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3238 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
|
3239 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
|
3240 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3241 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3242 def test_private_tags(self): |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3243 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3244 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
|
3245 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
|
3246 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
|
3247 |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3248 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3249 def test_findscu_encoding(self): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3250 # Check out ../Database/Encodings/Generate.sh |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3251 TEST = u'Test-éüäöòДΘĝדصķћ๛ネİ' |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3252 ENCODINGS = { |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3253 'Arabic' : [ 'ISO_IR 127' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3254 'Ascii' : [ 'ISO_IR 6' ], # More accurately, ISO 646 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3255 'Cyrillic' : [ 'ISO_IR 144' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3256 'Greek' : [ 'ISO_IR 126' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3257 'Hebrew' : [ 'ISO_IR 138' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3258 'Japanese' : [ 'ISO_IR 13', 'shift-jis' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3259 'Latin1' : [ 'ISO_IR 100' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3260 'Latin2' : [ 'ISO_IR 101' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3261 'Latin3' : [ 'ISO_IR 109' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3262 'Latin4' : [ 'ISO_IR 110' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3263 'Latin5' : [ 'ISO_IR 148' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3264 'Thai' : [ 'ISO_IR 166', 'tis-620' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3265 'Utf8' : [ 'ISO_IR 192' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3266 } |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3267 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3268 for name in ENCODINGS.iterkeys(): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3269 if len(ENCODINGS[name]) == 1: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3270 ENCODINGS[name].append(name.lower()) |
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 UploadInstance(_REMOTE, 'Encodings/Lena-utf8.dcm') |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3273 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3274 for name in ENCODINGS.iterkeys(): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3275 self.assertEqual(name, DoPut(_REMOTE, '/tools/default-encoding', name)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3276 self.assertEqual(name, DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3277 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3278 i = CallFindScu([ '-k', '0008,0052=STUDY', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3279 '-k', 'SpecificCharacterSet', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3280 '-k', 'PatientName' ]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3281 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3282 characterSet = re.findall('\(0008,0005\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3283 self.assertEqual(1, len(characterSet)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3284 self.assertEqual(ENCODINGS[name][0], characterSet[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3285 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3286 patientName = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3287 self.assertEqual(1, len(patientName)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3288 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3289 expected = TEST.encode(ENCODINGS[name][1], 'ignore') |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3290 self.assertEqual(expected, patientName[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3291 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3292 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3293 #for master in ENCODINGS: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3294 for master in [ 'Latin1', 'Utf8', 'Cyrillic' ]: # Shortcut to speedup tests |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3295 self.assertEqual(master, DoPut(_REMOTE, '/tools/default-encoding', master)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3296 self.assertEqual(master, DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3297 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3298 for name in ENCODINGS: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3299 DropOrthanc(_REMOTE) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3300 UploadInstance(_REMOTE, 'Encodings/Lena-%s.dcm' % ENCODINGS[name][1]) |
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 i = CallFindScu([ '-k', '0008,0052=STUDY', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3303 '-k', 'PatientID', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3304 '-k', 'SpecificCharacterSet', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3305 '-k', 'PatientName' ]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3306 i = i.decode(ENCODINGS[master][1]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3307 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3308 characterSet = re.findall('\(0008,0005\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3309 self.assertEqual(1, len(characterSet)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3310 self.assertEqual(ENCODINGS[master][0], characterSet[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3311 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3312 patientId = re.findall('\(0010,0020\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3313 self.assertEqual(1, len(patientId)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3314 self.assertEqual(ENCODINGS[name][1], patientId[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3315 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3316 patientName = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3317 self.assertEqual(1, len(patientName)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3318 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3319 tmp = ENCODINGS[name][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3320 expected = TEST.encode(tmp, 'ignore').decode(tmp) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3321 tmp = ENCODINGS[master][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3322 expected = expected.encode(tmp, 'ignore').decode(tmp) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3323 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3324 self.assertEqual(expected, patientName[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3325 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3326 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3327 a = DoPost(_REMOTE, '/tools/find', { 'Expand' : True, |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3328 'Level' : 'Study', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3329 'Query' : { }}) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3330 self.assertEqual(1, len(a)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3331 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3332 tmp = ENCODINGS[name][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3333 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
|
3334 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3335 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3336 def test_reconstruct(self): |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3337 def CompareMainDicomTag(expected, instance, level, tag): |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3338 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
|
3339 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3340 a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
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 studies = DoGet(_REMOTE, '/studies/') |
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(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(1, len(DoGet(_REMOTE, '/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 modified = DoPost(_REMOTE, '/studies/%s/modify' % studies[0], { |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3349 "Replace" : { |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3350 "StudyDescription" : "hello", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3351 "SeriesDescription" : "world", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3352 "SOPClassUID" : "test", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3353 "SOPInstanceUID" : "myid", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3354 }, |
119 | 3355 "Keep" : [ "StudyInstanceUID", "SeriesInstanceUID" ], |
3356 "Force" : True | |
96
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3357 }) |
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 instances = DoGet(_REMOTE, '/instances/') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3360 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3361 self.assertEqual(1, len(DoGet(_REMOTE, '/studies/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3362 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3363 self.assertEqual(2, len(instances)) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3364 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3365 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
|
3366 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3367 CompareMainDicomTag('Knee (R)', a, 'study', 'StudyDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3368 CompareMainDicomTag('AX. FSE PD', a, 'series', 'SeriesDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3369 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
|
3370 CompareMainDicomTag('myid', b, '', 'SOPInstanceUID') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3371 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
|
3372 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
|
3373 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3374 DoPost(_REMOTE, '/instances/%s/reconstruct' % b, {}) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3375 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3376 CompareMainDicomTag('hello', a, 'study', 'StudyDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3377 CompareMainDicomTag('world', a, 'series', 'SeriesDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3378 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', a, '', 'SOPInstanceUID') |
102 | 3379 |
104 | 3380 def test_httpClient_lua(self): |
3381 with open(GetDatabasePath('Lua/HttpClient.lua'), 'r') as f: | |
102 | 3382 result = DoPost(_REMOTE, '/tools/execute-script', f.read(), 'application/lua') |
3383 | |
3384 self.assertIn('OK', result) | |
107
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 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3387 def test_bitbucket_issue_44(self): |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3388 # 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
|
3389 UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3390 UploadInstance(_REMOTE, 'Issue44/Monochrome2.dcm') |
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 # dcmcjpeg +ua +eb Monochrome1.dcm Monochrome1-Jpeg.dcm |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3393 UploadInstance(_REMOTE, 'Issue44/Monochrome1-Jpeg.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3394 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3395 # dcmcjpeg +ua Monochrome1.dcm Monochrome1-JpegLS.dcm |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3396 UploadInstance(_REMOTE, 'Issue44/Monochrome1-JpegLS.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3397 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3398 monochrome1 = 'bcdd600a-a6a9c522-5f0a6e84-8657c9f3-b76e59b7' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3399 monochrome1_jpeg = '9df82121-208a2da8-0038674a-3d7a773b-b7008cd2' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3400 monochrome1_jpegls = '0486d1a2-9165573f-b1976b20-e927b016-6b8d67ab' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3401 monochrome2 = 'f00947b7-f61f7164-c93414d1-c6fbda6a-9e92ed20' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3402 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3403 for i in [ monochrome1, monochrome1_jpeg, monochrome1_jpegls ]: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3404 im = GetImage(_REMOTE, '/instances/%s/preview' % i) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3405 self.assertEqual("L", im.mode) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3406 self.assertEqual(2010, im.size[0]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3407 self.assertEqual(2446, im.size[1]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3408 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3409 # 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
|
3410 # white (255), should be rendered as black (0) => invert |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3411 if i == monochrome1_jpeg: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3412 # Add some tolerance because of JPEG destructive compression |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3413 self.assertGreater(10, im.getpixel((0,0))) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3414 else: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3415 self.assertEqual(0, im.getpixel((0,0))) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3416 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3417 im = GetImage(_REMOTE, '/instances/%s/preview' % monochrome2) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3418 self.assertEqual("L", im.mode) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3419 self.assertEqual(1572, im.size[0]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3420 self.assertEqual(2010, im.size[1]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3421 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3422 # 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
|
3423 # white (255), should be rendered as white (255) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3424 self.assertEqual(255, im.getpixel((0,0))) |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3425 |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3426 |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3427 def test_bitbucket_issue_42(self): |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3428 # https://bitbucket.org/sjodogne/orthanc/issues/42/fails-to-modify-a-dicom-video-file |
123 | 3429 # 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
|
3430 UploadInstance(_REMOTE, 'Issue42.dcm')['ID'] |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3431 modified = DoPost(_REMOTE, |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3432 '/patients/da128605-e040d0c4-310615d2-3475da63-df2d1ef4/modify', |
119 | 3433 '{"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
|
3434 'application/json') |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3435 self.assertTrue('PatientID' in modified) |
113
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3436 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3437 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3438 def test_rest_find_limit(self): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3439 # 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
|
3440 # 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
|
3441 |
113
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3442 # Upload 6 instances |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3443 brainix = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3444 knee = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3445 for i in range(2): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3446 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
|
3447 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
|
3448 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
|
3449 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3450 # Check using BRAINIX |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3451 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3452 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3453 'Limit' : 10 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3454 self.assertEqual(4, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3455 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3456 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3457 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3458 'Limit' : 4 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3459 self.assertEqual(4, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3460 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3461 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3462 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3463 'Since' : 2, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3464 'Limit' : 4 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3465 self.assertEqual(2, len(a)) |
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 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3468 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3469 'Limit' : 3 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3470 self.assertEqual(3, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3471 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3472 b = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3473 for i in range(4): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3474 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3475 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3476 'Limit' : 1, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3477 'Since' : i }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3478 self.assertEqual(1, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3479 b.append(a[0]) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3480 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3481 # 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
|
3482 self.assertEqual(0, len(set(b) ^ set(brainix))) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3483 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3484 # Check using KNEE |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3485 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3486 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3487 'Limit' : 10 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3488 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3489 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3490 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3491 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3492 'Limit' : 2 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3493 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3494 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3495 b = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3496 for i in range(2): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3497 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3498 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3499 'Limit' : 1, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3500 'Since' : i }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3501 self.assertEqual(1, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3502 b.append(a[0]) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3503 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3504 self.assertEqual(0, len(set(b) ^ set(knee))) |
115
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3505 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3506 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3507 def test_bitbucket_issue_46(self): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3508 # "PHI remaining after anonymization" |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3509 # https://bitbucket.org/sjodogne/orthanc/issues/46 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3510 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3511 def GetAnonymizedTags(study, version): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3512 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3513 { 'DicomVersion' : version }, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3514 'application/json') ['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3515 a = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3516 self.assertEqual(1, len(a)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3517 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3518 instance = a[0]['ID'] |
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 return (instance, DoGet(_REMOTE, '/instances/%s/tags' % instance)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3521 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3522 UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm') |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3523 origStudy = '6068a14b-d4df27af-9ec22145-538772d8-74f228ff' |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3524 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3525 # 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
|
3526 # (Patient's Mother's Birth Name) tags |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3527 newStudy = DoPost(_REMOTE, '/studies/%s/modify' % origStudy, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3528 '{"Replace":{"0010,1060":"OSIMIS","0032,1033":"MOTHER"}}', |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3529 'application/json')['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3530 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3531 # 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
|
3532 # 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
|
3533 (instance, tags) = GetAnonymizedTags(newStudy, "2008") |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3534 self.assertTrue('0032,1033' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3535 self.assertTrue('0010,1060' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3536 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3537 # 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
|
3538 # 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
|
3539 (instance, tags) = GetAnonymizedTags(newStudy, "2017c") |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3540 self.assertFalse('0032,1033' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3541 self.assertFalse('0010,1060' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3542 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3543 t = {} |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3544 for (key, value) in tags.iteritems(): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3545 t[value['Name']] = value['Value'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3546 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3547 self.assertEqual('', t['StudyDate']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3548 self.assertEqual('', t['StudyTime']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3549 self.assertEqual('', t['PatientSex']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3550 self.assertFalse('SeriesDate' in t) # Type 3 tag => null |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3551 self.assertFalse('SeriesTime' in t) # Type 3 tag => null |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3552 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3553 with tempfile.NamedTemporaryFile(delete = True) as f: |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3554 # 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
|
3555 f.write(DoGet(_REMOTE, '/instances/%s/file' % instance)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3556 f.flush() |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3557 subprocess.check_output([ FindExecutable('dciodvfy'), f.name ], |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3558 stderr = subprocess.STDOUT).split('\n') |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3559 |
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 def test_bitbucket_issue_55(self): |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3562 def Run(modify, query): |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3563 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3564 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3565 operation = 'modify' if modify else 'anonymize' |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3566 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3567 self.assertRaises(Exception, lambda: DoPost( |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3568 _REMOTE, '/studies/%s/%s' % (study, operation), query)) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3569 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3570 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3571 query["Force"] = True |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3572 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
|
3573 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3574 DoDelete(_REMOTE, a) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3575 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3576 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3577 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3578 UploadInstance(_REMOTE, 'DummyCT.dcm') |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3579 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3580 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3581 Run(True, { "Replace" : { "StudyInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3582 Run(True, { "Replace" : { "SeriesInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3583 Run(True, { "Replace" : { "SOPInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3584 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3585 Run(False, { "Keep" : [ "StudyInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3586 Run(False, { "Keep" : [ "SeriesInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3587 Run(False, { "Keep" : [ "SOPInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3588 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3589 Run(False, { "Replace" : { "StudyInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3590 Run(False, { "Replace" : { "SeriesInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3591 Run(False, { "Replace" : { "SOPInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3592 |
120
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3593 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3594 def test_bitbucket_issue_56(self): |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3595 # Case-insensitive matching over accents. This test assumes |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3596 # that the "CaseSensitivePN" configuration option of Orthanc |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3597 # is set to "false" (default value). |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3598 # https://bitbucket.org/sjodogne/orthanc/issues/56 |
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 def Check(name, expected, expectedSensitive): |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3601 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
|
3602 '-k', '0008,0052=PATIENT', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3603 '-k', 'PatientName=%s' % name ]) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3604 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', a) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3605 self.assertEqual(expected, len(patientNames)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3606 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3607 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3608 'CaseSensitive' : False, |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3609 'Query' : { 'PatientName' : name }}) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3610 self.assertEqual(expected, len(a)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3611 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3612 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3613 'CaseSensitive' : True, |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3614 'Query' : { 'PatientName' : name }}) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3615 self.assertEqual(expectedSensitive, len(a)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3616 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3617 UploadInstance(_REMOTE, 'Encodings/Lena-latin1.dcm') |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3618 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3619 # WildcardConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3620 Check('TeSt*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3621 Check('TeSt-a*', 0, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3622 Check('TeSt-É*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3623 Check('TeSt-é*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3624 Check('Test-é*', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3625 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3626 # ListConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3627 Check('Test-éüäöò\\nope', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3628 Check('Test-ÉÜÄÖÒ\\nope', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3629 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3630 # ValueConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3631 Check('Test-éüäöò', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3632 Check('Test-ÉÜÄÖÒ', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3633 |
125 | 3634 |
3635 def test_gbk_alias(self): | |
3636 # https://groups.google.com/d/msg/orthanc-users/WMM8LMbjpUc/02-1f_yFCgAJ | |
3637 # This test fails on Orthanc <= 1.3.0 | |
3638 i = UploadInstance(_REMOTE, '2017-09-19-GBK-Tumashu.dcm')['ID'] | |
3639 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
3640 self.assertEqual(tags['PatientName'], u'徐浩凯') | |
3641 self.assertEqual(tags['InstitutionName'], u'灌云县疾病预防控制中心') | |
126 | 3642 |
3643 | |
3644 def test_long_tag(self): | |
3645 i = UploadInstance(_REMOTE, 'DummyCTWithLongTag.dcm')['ID'] | |
3646 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
3647 | |
3648 tags = DoGet(_REMOTE, '/instances/%s/tags' % i) | |
3649 self.assertTrue('0018,1020' in tags) | |
3650 self.assertEqual('SoftwareVersions', tags['0018,1020']['Name']) | |
3651 self.assertEqual('TooLong', tags['0018,1020']['Type']) | |
3652 self.assertEqual(None, tags['0018,1020']['Value']) | |
3653 | |
3654 tags = DoGet(_REMOTE, '/instances/%s/tags?ignore-length=0018-1020' % i) | |
3655 self.assertTrue('0018,1020' in tags) | |
3656 self.assertEqual('SoftwareVersions', tags['0018,1020']['Name']) | |
3657 self.assertEqual('String', tags['0018,1020']['Type']) | |
3658 self.assertTrue(tags['0018,1020']['Value'].startswith('Lorem ipsum dolor sit amet')) | |
3659 | |
3660 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
3661 self.assertTrue('SoftwareVersions' in tags) | |
3662 self.assertEqual(None, tags['SoftwareVersions']) | |
3663 self.assertTrue('HeartRate' in tags) | |
3664 self.assertEqual(474, int(tags['HeartRate'])) | |
3665 | |
3666 tags = DoGet(_REMOTE, '/instances/%s/simplified-tags' % i) | |
3667 self.assertTrue('SoftwareVersions' in tags) | |
3668 self.assertEqual(None, tags['SoftwareVersions']) | |
3669 | |
3670 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify&ignore-length=0018-1020' % i) | |
3671 self.assertTrue('SoftwareVersions' in tags) | |
3672 self.assertTrue(tags['SoftwareVersions'].startswith('Lorem ipsum dolor sit amet')) | |
3673 | |
3674 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify&ignore-length=SoftwareVersions' % i) | |
3675 self.assertTrue('SoftwareVersions' in tags) | |
3676 self.assertTrue(tags['SoftwareVersions'].startswith('Lorem ipsum dolor sit amet')) | |
3677 | |
3678 tags = DoGet(_REMOTE, '/series/%s/instances-tags' % series) | |
3679 self.assertEqual(1, len(tags)) | |
3680 self.assertTrue(i in tags.keys()) | |
3681 self.assertTrue('0018,1020' in tags[i]) | |
3682 self.assertEqual('TooLong', tags[i]['0018,1020']['Type']) | |
3683 | |
3684 tags = DoGet(_REMOTE, '/series/%s/instances-tags?ignore-length=SoftwareVersions' % series) | |
3685 self.assertEqual(1, len(tags)) | |
3686 self.assertTrue(i in tags.keys()) | |
3687 self.assertTrue('0018,1020' in tags[i]) | |
3688 self.assertEqual('String', tags[i]['0018,1020']['Type']) | |
3689 self.assertTrue(tags[i]['0018,1020']['Value'].startswith('Lorem ipsum dolor sit amet')) | |
3690 | |
127
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3691 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3692 def test_extended_media(self): |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3693 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3694 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3695 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
|
3696 self.assertEqual(2, len(z.namelist())) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3697 self.assertTrue('IMAGES/IM0' in z.namelist()) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3698 self.assertTrue('DICOMDIR' in z.namelist()) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3699 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3700 try: |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3701 os.remove('/tmp/DICOMDIR') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3702 except: |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3703 # The file does not exist |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3704 pass |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3705 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3706 z.extract('DICOMDIR', '/tmp') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3707 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3708 stderr = subprocess.STDOUT).split('\n') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3709 self.assertEqual(5, len(a)) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3710 self.assertTrue(a[0].startswith('Warning')) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3711 self.assertEqual('BasicDirectory', a[1]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3712 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
|
3713 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
|
3714 self.assertEqual('', a[4]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3715 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3716 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3717 stderr = subprocess.STDOUT).split('\n') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3718 self.assertEqual(1, len(a)) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3719 self.assertEqual('', a[0]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3720 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3721 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3722 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
|
3723 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3724 # Check the presence of the series description (extended tag) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3725 self.assertTrue(re.search('T1W_aTSE', a) != None) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3726 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3727 os.remove('/tmp/DICOMDIR') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3728 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3729 |
132
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3730 def test_anonymize_relationships_1(self): |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3731 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3732 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
|
3733 study = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3734 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3735 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
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 'application/json')['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3738 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3739 a = DoGet(_REMOTE, '/studies/%s/instances' % study) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3740 self.assertEqual(2, len(a)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3741 a1 = a[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3742 a2 = a[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3743 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3744 b = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3745 self.assertEqual(2, len(b)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3746 b1 = b[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3747 b2 = b[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3748 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3749 SEQUENCE = '/instances/%s/content/ReferencedImageSequence' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3750 SOP = '/instances/%s/content/ReferencedImageSequence/%d/ReferencedSOPInstanceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3751 CLASS = '/instances/%s/content/ReferencedImageSequence/%d/ReferencedSOPClassUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3752 FRAME = '/instances/%s/content/FrameOfReferenceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3753 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3754 self.assertEqual(DoGet(_REMOTE, FRAME % a1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3755 DoGet(_REMOTE, FRAME % a2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3756 self.assertEqual(DoGet(_REMOTE, FRAME % b1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3757 DoGet(_REMOTE, FRAME % b2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3758 self.assertNotEqual(DoGet(_REMOTE, FRAME % a1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3759 DoGet(_REMOTE, FRAME % b1)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3760 self.assertNotEqual(DoGet(_REMOTE, FRAME % a2), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3761 DoGet(_REMOTE, FRAME % b2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3762 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3763 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
|
3764 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
|
3765 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
|
3766 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
|
3767 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3768 for i in range(3): |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3769 self.assertEqual(DoGet(_REMOTE, SOP % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3770 DoGet(_REMOTE, SOP % (a2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3771 self.assertEqual(DoGet(_REMOTE, SOP % (b1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3772 DoGet(_REMOTE, SOP % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3773 self.assertNotEqual(DoGet(_REMOTE, SOP % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3774 DoGet(_REMOTE, SOP % (b1, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3775 self.assertNotEqual(DoGet(_REMOTE, SOP % (a2, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3776 DoGet(_REMOTE, SOP % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3777 self.assertEqual(DoGet(_REMOTE, CLASS % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3778 DoGet(_REMOTE, CLASS % (b1, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3779 self.assertEqual(DoGet(_REMOTE, CLASS % (a2, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3780 DoGet(_REMOTE, CLASS % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3781 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3782 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3783 def test_anonymize_relationships_2(self): |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3784 UploadInstance(_REMOTE, 'Comunix/Ct/IM-0001-0001.dcm') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3785 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
|
3786 study = '6c65289b-db2fcb71-7eaf73f4-8e12470c-a4d6d7cf' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3787 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3788 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3789 '{}', |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3790 'application/json')['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3791 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3792 a = DoGet(_REMOTE, '/studies/%s/instances' % study) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3793 self.assertEqual(2, len(a)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3794 a1 = a[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3795 a2 = a[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3796 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3797 b = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3798 self.assertEqual(2, len(b)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3799 b1 = b[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3800 b2 = b[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3801 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3802 SEQUENCE = '/instances/%s/content/SourceImageSequence' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3803 SOP = '/instances/%s/content/SourceImageSequence/%d/ReferencedSOPInstanceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3804 CLASS = '/instances/%s/content/SourceImageSequence/%d/ReferencedSOPClassUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3805 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3806 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
|
3807 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
|
3808 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
|
3809 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
|
3810 self.assertEqual(DoGet(_REMOTE, SOP % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3811 DoGet(_REMOTE, SOP % (a2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3812 self.assertEqual(DoGet(_REMOTE, SOP % (b1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3813 DoGet(_REMOTE, SOP % (b2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3814 self.assertNotEqual(DoGet(_REMOTE, SOP % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3815 DoGet(_REMOTE, SOP % (b1, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3816 self.assertNotEqual(DoGet(_REMOTE, SOP % (a2, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3817 DoGet(_REMOTE, SOP % (b2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3818 self.assertEqual(DoGet(_REMOTE, CLASS % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3819 DoGet(_REMOTE, CLASS % (b1, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3820 self.assertEqual(DoGet(_REMOTE, CLASS % (a2, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3821 DoGet(_REMOTE, CLASS % (b2, 0))) |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3822 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3823 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3824 def test_anonymize_relationships_3(self): |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3825 sr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/StructuredReports/IM0')['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3826 mr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/StructuredReports/IM631')['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3827 study = 'ef351eb2-c1147229-062736b8-35a151e3-e32d526b' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3828 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3829 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3830 { "Keep" : [ "ContentSequence" ] }) ['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3831 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3832 a = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3833 self.assertEqual(2, len(a)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3834 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3835 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
|
3836 sr2 = a[0]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3837 mr2 = a[1]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3838 else: |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3839 sr2 = a[1]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3840 mr2 = a[0]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3841 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3842 self.assertEqual(DoGet(_REMOTE, '/instances/%s/content/Modality' % sr1), |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3843 DoGet(_REMOTE, '/instances/%s/content/Modality' % sr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3844 self.assertEqual(DoGet(_REMOTE, '/instances/%s/content/Modality' % mr1), |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3845 DoGet(_REMOTE, '/instances/%s/content/Modality' % mr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3846 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3847 mrUid1 = DoGet(_REMOTE, '/instances/%s' % mr1)['MainDicomTags']['SOPInstanceUID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3848 mrUid2 = DoGet(_REMOTE, '/instances/%s' % mr2)['MainDicomTags']['SOPInstanceUID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3849 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
|
3850 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
|
3851 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
|
3852 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
|
3853 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3854 PATH1 = '/instances/%s/content/CurrentRequestedProcedureEvidenceSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3855 PATH2 = PATH1 + '/0/ReferencedSeriesSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3856 PATH3 = PATH2 + '/0/ReferencedSOPSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3857 PATH4 = PATH3 + '/0/ReferencedSOPInstanceUID' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3858 PATH5 = PATH3 + '/0/ReferencedSOPClassUID' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3859 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3860 self.assertEqual(1, len(DoGet(_REMOTE, PATH1 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3861 self.assertEqual(1, len(DoGet(_REMOTE, PATH2 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3862 self.assertEqual(1, len(DoGet(_REMOTE, PATH3 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3863 self.assertEqual(DoGet(_REMOTE, PATH4 % sr1), mrUid1) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3864 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
|
3865 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
|
3866 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3867 self.assertEqual(1, len(DoGet(_REMOTE, PATH1 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3868 self.assertEqual(1, len(DoGet(_REMOTE, PATH2 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3869 self.assertEqual(1, len(DoGet(_REMOTE, PATH3 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3870 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
|
3871 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3872 self.assertEqual(mrUid2, DoGet(_REMOTE, PATH4 % sr2).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3873 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
|
3874 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
|
3875 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3876 content1 = DoGet(_REMOTE, '/instances/%s/tags?simplify' % sr1) ['ContentSequence'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3877 content2 = DoGet(_REMOTE, '/instances/%s/tags?simplify' % sr2) ['ContentSequence'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3878 self.assertEqual(str(content1), str(content2)) |
141
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3879 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3880 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3881 def test_bitbucket_issue_94(self): |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3882 # "a simple instance modification should not modify FrameOfReferenceUID + ..." |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3883 # https://bitbucket.org/sjodogne/orthanc/issues/94 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3884 i = UploadInstance(_REMOTE, 'Issue94.dcm')['ID'] |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3885 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3886 source = DoGet(_REMOTE, '/instances/%s/attachments/dicom/data' % i) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3887 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3888 modified = DoPost(_REMOTE, '/instances/%s/modify' % i, |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3889 { "Replace" : {"PatientID" : "toto"}, "Force": True}) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3890 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3891 anonymized = DoPost(_REMOTE, '/instances/%s/anonymize' % i) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3892 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3893 a = ExtractDicomTags(source, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3894 self.assertEqual(1, len(a)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3895 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3896 b = ExtractDicomTags(modified, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3897 self.assertEqual(1, len(b)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3898 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3899 c = ExtractDicomTags(anonymized, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3900 self.assertEqual(1, len(c)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3901 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3902 self.assertEqual(a, b) # Modified DICOM |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
3903 self.assertNotEqual(a, c) # Anonymized DICOM |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3904 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3905 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3906 def test_metadata_origin(self): |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3907 # Upload using the REST API |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3908 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
|
3909 self.assertEqual('RestApi', DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3910 self.assertEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3911 self.assertNotEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteIP' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3912 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
|
3913 self.assertEqual('alice', DoGet(_REMOTE, '/instances/%s/metadata/HttpUsername' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3914 |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3915 m = DoGet(_REMOTE, '/instances/%s/metadata?expand' % i) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3916 self.assertEqual('RestApi', m['Origin']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3917 self.assertEqual('', m['RemoteAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3918 self.assertNotEqual('', m['RemoteIP']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3919 self.assertFalse('CalledAET' in m) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3920 self.assertEqual('alice', m['HttpUsername']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3921 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3922 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
|
3923 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
|
3924 self.assertEqual('1', m['IndexInSeries']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3925 self.assertTrue('ReceptionDate' in m) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3926 |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3927 DoDelete(_REMOTE, '/instances/%s' % i) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3928 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3929 # Upload using the DICOM protocol |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3930 subprocess.check_call([ FindExecutable('storescu'), |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3931 _REMOTE['Server'], str(_REMOTE['DicomPort']), |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3932 GetDatabasePath('Knee/T1/IM-0001-0001.dcm'), |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3933 '-xw' ]) # Propose JPEG2000 |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3934 self.assertEqual('DicomProtocol', DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3935 self.assertEqual('STORESCU', DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3936 self.assertNotEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteIP' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
3937 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
|
3938 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
|
3939 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3940 m = DoGet(_REMOTE, '/instances/%s/metadata?expand' % i) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3941 self.assertEqual('DicomProtocol', m['Origin']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3942 self.assertEqual('STORESCU', m['RemoteAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3943 self.assertNotEqual('', m['RemoteIP']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3944 self.assertEqual('ANY-SCP', m['CalledAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3945 self.assertFalse('HttpUsername' in m) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3946 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3947 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
|
3948 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
|
3949 self.assertEqual('1', m['IndexInSeries']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
3950 self.assertTrue('ReceptionDate' in m) |
147 | 3951 |
3952 | |
3953 def test_lua_deadlock(self): | |
3954 # Rana Asim Wajid (2018-07-14): "It does seem that the issue | |
3955 # is with the lua script I'm using for conversion of images to | |
3956 # JPEG2000. When the script is used with 1.4.0 the first | |
3957 # instance appears to be stored and then everything just | |
3958 # halts, ie Orthanc wont respond to anything after that." | |
3959 # https://groups.google.com/d/msg/orthanc-users/Rc-Beb42xc8/JUgdzrmCAgAJ | |
174 | 3960 InstallLuaScriptFromPath(_REMOTE, 'Lua/Jpeg2000Conversion.lua') |
147 | 3961 |
3962 subprocess.check_call([ FindExecutable('storescu'), | |
3963 _REMOTE['Server'], str(_REMOTE['DicomPort']), | |
3964 GetDatabasePath('Brainix/Flair/IM-0001-0001.dcm'), | |
3965 GetDatabasePath('Brainix/Flair/IM-0001-0002.dcm'), | |
3966 ]) | |
3967 | |
3968 instances = DoGet(_REMOTE, '/instances') | |
3969 self.assertEqual(2, len(instances)) | |
3970 | |
3971 t1 = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % instances[0]) | |
3972 t2 = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % instances[1]) | |
175 | 3973 self.assertEqual('1.2.840.10008.1.2.4.90', t1) # this will fail if libgdcm-tools is not installed |
147 | 3974 self.assertEqual(t1, t2); |
154
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3975 |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3976 |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3977 def test_find_group_length(self): |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3978 # 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
|
3979 # one of the Generic Group Length tags (*, 0x0000) |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3980 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
|
3981 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
|
3982 self.assertFalse('UnableToProcess' in result) |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
3983 self.assertFalse('E:' in result) |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3984 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3985 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3986 def test_split(self): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3987 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3988 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3989 study = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3990 t1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3991 t2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' |
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 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3994 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) |
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 info = DoGet(_REMOTE, '/studies/%s' % study) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3997 self.assertTrue('ReferringPhysicianName' in info['MainDicomTags']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3998 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
3999 job = MonitorJob2(_REMOTE, lambda: DoPost |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4000 (_REMOTE, '/studies/%s/split' % study, { |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4001 'Series' : [ t2 ], |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4002 'Replace' : { 'PatientName' : 'Hello' }, |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4003 'Remove' : [ 'ReferringPhysicianName' ], |
181 | 4004 'KeepSource' : False, |
4005 'Asynchronous' : True | |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4006 })) |
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 self.assertNotEqual(None, job) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4009 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4010 studies = set(DoGet(_REMOTE, '/studies')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4011 self.assertEqual(2, len(studies)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4012 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4013 series = set(DoGet(_REMOTE, '/series')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4014 self.assertEqual(2, len(series)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4015 self.assertTrue(t1 in series) |
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 study2 = DoGet(_REMOTE, '/jobs/%s' % job)['Content']['TargetStudy'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4018 self.assertTrue(study in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4019 self.assertTrue(study2 in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4020 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4021 info = DoGet(_REMOTE, '/studies/%s' % study2) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4022 self.assertTrue('Hello', info['PatientMainDicomTags']['PatientName']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4023 self.assertFalse('ReferringPhysicianName' in info['MainDicomTags']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4024 |
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 def test_merge(self): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4027 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4028 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4029 knee = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4030 t1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4031 brainix = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4032 flair = '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' |
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 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4035 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4036 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4037 job = MonitorJob2(_REMOTE, lambda: DoPost |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4038 (_REMOTE, '/studies/%s/merge' % knee, { |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4039 'Resources' : [ brainix ], |
181 | 4040 'KeepSource' : True, |
4041 'Synchronous' : False | |
179
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 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4044 self.assertNotEqual(None, job) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4045 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4046 studies = set(DoGet(_REMOTE, '/studies')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4047 self.assertEqual(2, len(studies)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4048 self.assertTrue(knee in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4049 self.assertTrue(brainix in studies) |
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 series = set(DoGet(_REMOTE, '/studies/%s' % knee)['Series']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4052 self.assertTrue(t1 in series) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4053 series.remove(t1) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4054 self.assertEqual(1, len(series)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4055 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4056 instances = DoGet(_REMOTE, '/series/%s' % list(series)[0])['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4057 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4058 merged = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4059 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4060 instances = DoGet(_REMOTE, '/series/%s' % t1)['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4061 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4062 a = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4063 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4064 instances = DoGet(_REMOTE, '/series/%s' % flair)['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4065 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4066 b = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4067 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4068 tags = DoGet(_REMOTE, '/studies/%s' % knee) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4069 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4070 for key in tags['PatientMainDicomTags']: |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4071 self.assertEqual(a[key], merged[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4072 if (key in b and key != 'PatientSex'): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4073 self.assertNotEqual(a[key], b[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4074 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4075 for key in tags['MainDicomTags']: |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4076 # Not in the patient/study module |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4077 if (not key in [ 'InstitutionName', |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4078 'RequestingPhysician', |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4079 'RequestedProcedureDescription', ]): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4080 self.assertEqual(a[key], merged[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4081 if (key in b): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4082 self.assertNotEqual(a[key], b[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4083 |
187 | 4084 |
4085 def test_async_archive(self): | |
4086 # Testing the asynchronous generation of archives/medias (new | |
4087 # in Orthanc 1.4.3) | |
4088 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
4089 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
4090 | |
4091 kneeT1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
4092 kneeT2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
4093 | |
4094 job = MonitorJob2(_REMOTE, lambda: DoPost | |
4095 (_REMOTE, '/studies/%s/archive' % kneeT1, { | |
4096 'Synchronous' : False | |
4097 })) | |
4098 | |
4099 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4100 self.assertEqual(1, len(z.namelist())) | |
4101 self.assertFalse('DICOMDIR' in z.namelist()) | |
4102 | |
4103 job2 = MonitorJob2(_REMOTE, lambda: DoPost | |
4104 (_REMOTE, '/studies/%s/media' % kneeT1, { | |
4105 'Synchronous' : False | |
4106 })) | |
4107 | |
4108 # The archive from the first job has been replaced by the | |
4109 # archive from second job (as MediaArchiveSize == 1) | |
4110 self.assertRaises(Exception, lambda: GetArchive(_REMOTE, '/jobs/%s/archive' % job)) | |
4111 | |
4112 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job2) | |
4113 self.assertEqual(2, len(z.namelist())) | |
4114 self.assertTrue('DICOMDIR' in z.namelist()) | |
4115 | |
4116 job = MonitorJob2(_REMOTE, lambda: DoPost | |
4117 (_REMOTE, '/tools/create-archive', { | |
4118 'Synchronous' : False, | |
4119 'Resources' : [ kneeT1, kneeT2 ], | |
4120 })) | |
4121 | |
4122 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4123 self.assertEqual(2, len(z.namelist())) | |
4124 self.assertFalse('DICOMDIR' in z.namelist()) | |
4125 | |
4126 job = MonitorJob2(_REMOTE, lambda: DoPost | |
4127 (_REMOTE, '/tools/create-media', { | |
4128 'Synchronous' : False, | |
4129 'Resources' : [ kneeT1, kneeT2 ], | |
4130 })) | |
4131 | |
4132 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4133 self.assertEqual(3, len(z.namelist())) | |
4134 self.assertTrue('DICOMDIR' in z.namelist()) | |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4135 |
187 | 4136 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4137 def test_queries_hierarchy(self): |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4138 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4139 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
|
4140 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4141 tags = { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4142 'NumberOfPatientRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4143 'NumberOfPatientRelatedSeries' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4144 'NumberOfPatientRelatedStudies' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4145 'NumberOfStudyRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4146 'NumberOfStudyRelatedSeries' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4147 'NumberOfSeriesRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4148 } |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4149 |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4150 tags2 = copy.copy(tags) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4151 tags2['PatientID'] = '887' # Only consider the "Knee" patient |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4152 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4153 patient = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4154 'Level' : 'Patient', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4155 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4156 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4157 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4158 study = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4159 'Level' : 'Study', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4160 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4161 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4162 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4163 series = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4164 'Level' : 'Series', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4165 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4166 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4167 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4168 instance = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4169 'Level' : 'Instance', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4170 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4171 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4172 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4173 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
|
4174 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4175 self.assertEqual('887', p[0]['PatientID']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4176 self.assertEqual('1', p[0]['NumberOfPatientRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4177 self.assertEqual('1', p[0]['NumberOfPatientRelatedSeries']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4178 self.assertEqual('1', p[0]['NumberOfPatientRelatedStudies']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4179 self.assertFalse('NumberOfStudyRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4180 self.assertFalse('NumberOfStudyRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4181 self.assertFalse('NumberOfSeriesRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4182 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4183 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
|
4184 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4185 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
|
4186 self.assertEqual('1', p[0]['NumberOfStudyRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4187 self.assertEqual('1', p[0]['NumberOfStudyRelatedSeries']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4188 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4189 self.assertFalse('NumberOfPatientRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4190 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4191 self.assertFalse('NumberOfSeriesRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4192 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4193 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
|
4194 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4195 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
|
4196 self.assertEqual('1', p[0]['NumberOfSeriesRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4197 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4198 self.assertFalse('NumberOfPatientRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4199 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4200 self.assertFalse('NumberOfStudyRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4201 self.assertFalse('NumberOfStudyRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4202 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4203 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
|
4204 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4205 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
|
4206 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4207 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
|
4208 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4209 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
|
4210 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % study)) |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4211 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4212 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
|
4213 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4214 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
|
4215 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % series)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4216 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4217 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
|
4218 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4219 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
|
4220 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4221 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4222 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
|
4223 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4224 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
|
4225 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % series)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4226 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4227 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
|
4228 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4229 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
|
4230 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4231 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4232 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
|
4233 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4234 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
|
4235 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4236 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4237 |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4238 def test_dicom_disk_size(self): |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4239 dicomSize = 0 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4240 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4241 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4242 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4243 for i in range(2): |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4244 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
|
4245 UploadInstance(_REMOTE, p) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4246 dicomSize += os.path.getsize(GetDatabasePath(p)) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4247 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4248 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
|
4249 self.assertEqual(2, s['CountInstances']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4250 self.assertEqual(2, s['CountSeries']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4251 self.assertEqual(1, s['CountStudies']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4252 self.assertEqual(dicomSize, int(s['DicomDiskSize'])) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4253 self.assertEqual(dicomSize, int(s['DicomUncompressedSize'])) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4254 self.assertLess(dicomSize, int(s['UncompressedSize'])) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4255 self.assertEqual(s['UncompressedSize'], s['DiskSize']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4256 |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4257 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4258 def test_changes_2(self): |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4259 # 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
|
4260 # 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
|
4261 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4262 # 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
|
4263 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
|
4264 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
|
4265 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
|
4266 DoDelete(_REMOTE, '/instances/%s' % a) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4267 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4268 # 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
|
4269 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
|
4270 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4271 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4272 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
|
4273 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4274 seq = c['Last'] |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4275 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4276 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4277 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
|
4278 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4279 self.assertEqual(seq, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4280 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4281 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
|
4282 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
|
4283 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4284 self.assertEqual(seq, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4285 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4286 # Add one instance |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4287 UploadInstance(_REMOTE, 'DummyCT.dcm') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4288 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
|
4289 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4290 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4291 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
|
4292 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4293 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
|
4294 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4295 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4296 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
|
4297 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4298 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
|
4299 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4300 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
|
4301 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
|
4302 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4303 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
|
4304 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4305 # Remove the uploaded instance |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4306 DoDelete(_REMOTE, '/instances/%s' % a) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4307 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
|
4308 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4309 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4310 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
|
4311 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4312 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
|
4313 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4314 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4315 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
|
4316 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4317 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
|
4318 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4319 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
|
4320 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
|
4321 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4322 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
|
4323 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4324 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4325 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
|
4326 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
|
4327 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4328 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
|
4329 self.assertEqual(2, len(z.namelist())) |
207
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4330 |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4331 |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4332 def test_invalid_findscp(self): |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4333 UploadInstance(_REMOTE, 'DummyCT.dcm') |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4334 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
|
4335 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
|
4336 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4337 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4338 def test_bitbucket_issue_90(self): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4339 def CountDicomResults(sex): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4340 a = CallFindScu([ '-S', '-k', '8,52=STUDY', '-k', sex ]) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4341 return len(re.findall('\(0010,0040\)', a)) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4342 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4343 def CountRestResults(sex): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4344 a = DoPost(_REMOTE, '/tools/find', |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4345 { 'Level' : 'Study', 'Query' : { 'PatientSex' : sex } }) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4346 return len(a) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4347 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4348 # 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
|
4349 # "DummyCT.dcm" has the tag PatientSex (0010,0040) unset |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4350 UploadInstance(_REMOTE, 'DummyCT.dcm') |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4351 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4352 # 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
|
4353 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4354 # 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
|
4355 self.assertEqual(0, CountDicomResults('PatientSex=*')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4356 self.assertEqual(0, CountRestResults('*')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4357 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4358 # 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
|
4359 self.assertEqual(0, CountDicomResults('PatientSex=F')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4360 self.assertEqual(0, CountDicomResults('PatientSex=M')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4361 self.assertEqual(0, CountRestResults('F')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4362 self.assertEqual(0, CountRestResults('M')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4363 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4364 # 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
|
4365 # 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
|
4366 # as a filter in such a situation. |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4367 self.assertEqual(1, CountDicomResults('PatientSex')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4368 self.assertEqual(1, CountDicomResults('PatientSex=')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4369 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
|
4370 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4371 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4372 def test_rest_modalities_in_study(self): |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4373 # 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
|
4374 # 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
|
4375 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4376 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4377 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4378 'Query' : { 'ModalitiesInStudy' : 'US' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4379 self.assertEqual(0, len(a)) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4380 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4381 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4382 'Query' : { 'ModalitiesInStudy' : 'US\\CT' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4383 self.assertEqual(1, len(a)) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4384 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4385 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4386 'Query' : { 'ModalitiesInStudy' : 'CT' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4387 self.assertEqual(1, len(a)) |
211 | 4388 |
4389 | |
4390 def test_series_status(self): | |
4391 def HasCompletedInChanges(): | |
4392 for c in DoGet(_REMOTE, '/changes?limit=1000&since=0')['Changes']: | |
4393 if c['ChangeType'] == 'CompletedSeries': | |
4394 return True; | |
4395 | |
4396 return False | |
4397 | |
4398 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm') | |
4399 series = '8ea120d7-5057d919-837dfbcc-ccd04e0f-7f3a94aa' | |
4400 self.assertEqual('Unknown', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4401 self.assertFalse(HasCompletedInChanges()) | |
4402 | |
4403 series = 'ce25ecb6-ed79d004-5ae43ca7-3fc89bc5-67511614' | |
4404 | |
4405 for i in range(3): | |
4406 UploadInstance(_REMOTE, 'Series/Lena-%d.dcm' % (i + 1)) | |
4407 self.assertEqual('Missing', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4408 self.assertFalse(HasCompletedInChanges()) | |
4409 | |
4410 UploadInstance(_REMOTE, 'Series/Lena-4.dcm') | |
4411 self.assertEqual('Complete', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4412 self.assertTrue(HasCompletedInChanges()) | |
4413 | |
4414 DoDelete(_REMOTE, '/changes') | |
4415 self.assertFalse(HasCompletedInChanges()) | |
4416 | |
4417 UploadInstance(_REMOTE, 'Series/Lena-5.dcm') | |
4418 self.assertEqual('Inconsistent', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4419 self.assertFalse(HasCompletedInChanges()) | |
4420 |