Mercurial > hg > orthanc-tests
annotate Tests/Tests.py @ 384:9a41306c1fe5
notes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 24 Feb 2021 21:21:25 +0100 |
parents | 05d0d0c2623c |
children | 27e0a2fcdc85 |
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 |
363
79ce0f7a9714
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
361
diff
changeset
|
8 # Copyright (C) 2017-2021 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 |
290
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
25 import bz2 |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
26 import copy |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
27 import pprint |
14 | 28 import tempfile |
3 | 29 import unittest |
295 | 30 import shutil |
3 | 31 |
11 | 32 from PIL import ImageChops |
3 | 33 from Toolbox import * |
13 | 34 from xml.dom import minidom |
312 | 35 from datetime import datetime |
3 | 36 |
37 _LOCAL = None | |
38 _REMOTE = None | |
306
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
39 _DOCKER = False |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
40 |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
41 |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
42 def SetOrthancParameters(local, remote, withinDocker): |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
43 global _LOCAL, _REMOTE, _DOCKER |
3 | 44 _LOCAL = local |
45 _REMOTE = remote | |
306
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
46 _DOCKER = withinDocker |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
47 |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
48 |
14 | 49 def ExtractDicomTags(rawDicom, tags): |
50 with tempfile.NamedTemporaryFile(delete = True) as f: | |
51 f.write(rawDicom) | |
52 f.flush() | |
45 | 53 data = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) |
14 | 54 |
55 result = [] | |
56 for tag in tags: | |
57 match = re.search('<element[^>]+name="%s">([^>]*)</element>' % tag, data) | |
58 if match == None: | |
59 result.append('') | |
60 else: | |
61 result.append(match.group(1)) | |
62 | |
63 return result | |
64 | |
65 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
66 def CompareLists(a, b): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
67 if len(a) != len(b): |
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 for i in range(len(a)): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
71 d = a[i] - b[i] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
72 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
|
73 return False |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
74 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
75 return True |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
76 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
77 |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
78 def CompareTags(a, b, tagsToIgnore): |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
79 for i in tagsToIgnore: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
80 if i in a: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
81 del a[i] |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
82 if i in b: |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
83 del b[i] |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
84 |
123 | 85 if a.keys() == b.keys(): |
86 return True | |
87 else: | |
88 print('Mismatch in tags: %s' % str(set(a.keys()) ^ set(b.keys()))) | |
89 return False | |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
90 |
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
91 |
71
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
92 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
|
93 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
|
94 '-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
|
95 _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
|
96 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
|
97 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
|
98 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
99 |
142 | 100 def GetMoveScuCommand(): |
101 return [ | |
102 FindExecutable('movescu'), | |
103 '--move', _LOCAL['DicomAet'], # Target AET (i.e. storescp) | |
104 '--call', _REMOTE['DicomAet'], # Called AET (i.e. Orthanc) | |
105 '--aetitle', _LOCAL['DicomAet'], # Calling AET (i.e. storescp) | |
106 _REMOTE['Server'], | |
107 str(_REMOTE['DicomPort']) | |
108 ] | |
109 | |
231
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
110 |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
111 def IsDicomUntilPixelDataStored(orthanc): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
112 # This function detects whether the "StorageCompression" option is |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
113 # "true", OR the storage area does not support read-range |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
114 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
115 if IsOrthancVersionAbove(orthanc, 1, 9, 1): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
116 i = UploadInstance(orthanc, 'ColorTestMalaterre.dcm') ['ID'] |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
117 a = DoGet(orthanc, '/instances/%s/metadata/PixelDataOffset' % i) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
118 if a != 0x03a0: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
119 raise Exception('Internal error') |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
120 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
121 a = DoGet(orthanc, '/instances/%s/attachments' % i) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
122 if len(a) != 1 and len(a) != 2 or not 'dicom' in a: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
123 raise Exception('Internal error') |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
124 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
125 DoDelete(orthanc, '/instances/%s' % i) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
126 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
127 if len(a) == 1: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
128 return False |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
129 elif 'dicom-until-pixel-data' in a: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
130 return True |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
131 else: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
132 raise Exception('Internal error') |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
133 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
134 else: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
135 return False |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
136 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
137 |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
138 def CallMoveScu(args): |
231
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
139 try: |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
140 subprocess.check_call(GetMoveScuCommand() + args, |
318
bac7cc80f240
dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
141 stderr = subprocess.PIPE) |
231
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
142 except subprocess.CalledProcessError as e: |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
143 # The error code "69" corresponds to "EXITCODE_CMOVE_ERROR", |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
144 # that has been introduced in DCMTK 3.6.2. This error code is |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
145 # expected by some tests that try and C-MOVE non-existing |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
146 # DICOM instances. |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
147 # https://groups.google.com/d/msg/orthanc-users/DCRc5NeSCbM/DG-pSWj-BwAJ |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
148 if e.returncode != 69: |
4087505ddfe3
catching error codes of movescu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
149 raise e |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
150 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
151 |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
152 def GenerateTestSequence(): |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
153 return [ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
154 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
155 'StudyDescription': 'Hello^', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
156 'ReferencedStudySequence' : [ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
157 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
158 'StudyDescription': 'Toto', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
159 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
160 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
161 'StudyDescription': 'Tata', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
162 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
163 ] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
164 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
165 { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
166 'StudyDescription': 'Sébastien^', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
167 'StudyDate' : '19700202', |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
168 } |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
169 ] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
170 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
171 |
3 | 172 class Orthanc(unittest.TestCase): |
173 def setUp(self): | |
83 | 174 if (sys.version_info >= (3, 0)): |
175 # Remove annoying warnings about unclosed socket in Python 3 | |
176 import warnings | |
177 warnings.simplefilter("ignore", ResourceWarning) | |
178 | |
3 | 179 DropOrthanc(_LOCAL) |
180 DropOrthanc(_REMOTE) | |
174 | 181 UninstallLuaCallbacks(_REMOTE) |
312 | 182 #print("%s: In test %s" % (datetime.now(), self._testMethodName)) |
44
ffa542cce638
Toolbox.FindExecutable()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
183 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
184 def AssertSameImages(self, truth, url): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
185 im = GetImage(_REMOTE, url) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
186 self.assertTrue(CompareLists(truth, im.getdata())) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
187 |
3 | 188 |
189 def test_system(self): | |
177 | 190 self.assertTrue('Version' in DoGet(_REMOTE, '/system')) |
191 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
192 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
193 | |
194 systemInfo = DoGet(_REMOTE, '/system') | |
195 if systemInfo["Version"] == "mainline": | |
196 print "Skipping version checks since you're currently in mainline" | |
197 return | |
198 | |
173 | 199 self.assertTrue(IsOrthancVersionAbove(_LOCAL, 0, 8, 6)) |
200 self.assertFalse(IsOrthancVersionAbove(_LOCAL, 0, 8, 7)) | |
201 self.assertTrue(IsOrthancVersionAbove(_LOCAL, 0, 7, 6)) | |
202 self.assertFalse(IsOrthancVersionAbove(_LOCAL, 0, 9, 6)) | |
203 self.assertFalse(IsOrthancVersionAbove(_LOCAL, 1, 8, 6)) | |
3 | 204 |
205 def test_upload(self): | |
173 | 206 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) |
207 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
208 | |
209 sizeDummyCT = 2472 | |
210 sizeOverwrite = 2476 | |
211 instance = '66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d' | |
212 | |
379
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
213 # This file has *no* pixel data => "dicom-until-pixel-data" is not created |
3 | 214 u = UploadInstance(_REMOTE, 'DummyCT.dcm') |
379
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
215 isCompressed = (DoGet(_REMOTE, '/instances/%s/attachments/dicom/is-compressed' % u['ID']) != 0) |
183 | 216 self.assertEqual(instance, u['ID']) |
3 | 217 self.assertEqual('Success', u['Status']) |
173 | 218 |
183 | 219 if True: |
220 # New test for Orthanc 1.4.3 | |
221 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', u['ParentSeries']) | |
222 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', u['ParentStudy']) | |
223 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', u['ParentPatient']) | |
224 | |
379
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
225 if IsOrthancVersionAbove(_REMOTE, 1, 9, 1): |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
226 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json' % instance)) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
227 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/attachments/dicom-until-pixel-data' % instance)) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
228 j = 0 |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
229 else: |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
230 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/attachments/dicom-until-pixel-data' % instance)) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
231 j = int(DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % instance)) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
232 |
173 | 233 s = sizeDummyCT + j |
379
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
234 |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
235 if isCompressed: |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
236 self.assertGreater(s, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
237 else: |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
238 self.assertEqual(s, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
239 |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
240 self.assertEqual(s, int(DoGet(_REMOTE, '/statistics')['TotalUncompressedSize'])) |
173 | 241 |
3 | 242 u = UploadInstance(_REMOTE, 'DummyCT.dcm') |
243 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
244 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
245 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
246 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
379
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
247 |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
248 if isCompressed: |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
249 self.assertGreater(s, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
250 else: |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
251 self.assertEqual(s, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
252 |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
253 self.assertEqual(s, int(DoGet(_REMOTE, '/statistics')['TotalUncompressedSize'])) |
173 | 254 |
255 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % instance) | |
3 | 256 self.assertEqual('20070101', i['StudyDate']) |
173 | 257 self.assertEqual('KNIX', i['PatientName']) |
258 | |
259 if IsOrthancVersionAbove(_REMOTE, 1, 4, 2): | |
260 # Overwriting | |
261 self.assertEqual('Success', u['Status']) | |
262 else: | |
263 self.assertEqual('AlreadyStored', u['Status']) | |
264 | |
265 u = UploadInstance(_REMOTE, 'DummyCT-overwrite.dcm') | |
266 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
267 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
268 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
269 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
270 | |
271 if IsOrthancVersionAbove(_REMOTE, 1, 4, 2): | |
272 # Overwriting | |
273 self.assertEqual('Success', u['Status']) | |
379
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
274 if IsOrthancVersionAbove(_REMOTE, 1, 9, 1): |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
275 j2 = 0 |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
276 else: |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
277 j2 = int(DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/size' % instance)) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
278 self.assertNotEqual(j, j2) |
173 | 279 s2 = sizeOverwrite + j2 |
280 self.assertNotEqual(s, s2) | |
379
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
281 if isCompressed: |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
282 self.assertGreater(s2, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
283 else: |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
284 self.assertEqual(s2, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
285 |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
286 self.assertEqual(s2, int(DoGet(_REMOTE, '/statistics')['TotalUncompressedSize'])) |
173 | 287 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % instance) |
288 self.assertEqual('ANOTHER', i['PatientName']) | |
289 else: | |
290 self.assertEqual('AlreadyStored', u['Status']) | |
379
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
291 self.assertEqual(s, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
292 self.assertEqual(s, int(DoGet(_REMOTE, '/statistics')['TotalUncompressedSize'])) |
3 | 293 |
5 | 294 def test_upload_2(self): |
3 | 295 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
296 instance = DoGet(_REMOTE, '/instances/%s' % i) | |
297 self.assertEqual(i, instance['ID']) | |
298 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', | |
299 instance['MainDicomTags']['SOPInstanceUID']) | |
300 | |
301 series = DoGet(_REMOTE, '/series/%s' % instance['ParentSeries']) | |
302 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
303 series['MainDicomTags']['SeriesInstanceUID']) | |
304 | |
305 study = DoGet(_REMOTE, '/studies/%s' % series['ParentStudy']) | |
306 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
307 study['MainDicomTags']['StudyInstanceUID']) | |
308 | |
309 patient = DoGet(_REMOTE, '/patients/%s' % study['ParentPatient']) | |
310 self.assertEqual('ozp00SjY2xG', | |
311 patient['MainDicomTags']['PatientID']) | |
312 | |
313 dicom = DoGet(_REMOTE, '/instances/%s/file' % instance['ID']) | |
314 self.assertEqual(2472, len(dicom)) | |
315 self.assertEqual('3e29b869978b6db4886355a2b1132124', ComputeMD5(dicom)) | |
316 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
317 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/simplified-tags' % i)['StationName']) | |
318 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
|
319 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
|
320 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/tags?short' % i)['0008,1010']) |
3 | 321 |
322 | |
5 | 323 def test_images(self): |
324 i = UploadInstance(_REMOTE, 'Phenix/IM-0001-0001.dcm')['ID'] | |
325 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
3 | 326 |
5 | 327 im = GetImage(_REMOTE, '/instances/%s/preview' % i) |
328 self.assertEqual("L", im.mode) | |
329 self.assertEqual(512, im.size[0]) | |
330 self.assertEqual(358, im.size[1]) | |
331 | |
332 im = GetImage(_REMOTE, '/instances/%s/image-uint8' % i) | |
333 self.assertEqual("L", im.mode) | |
334 self.assertEqual(512, im.size[0]) | |
335 self.assertEqual(358, im.size[1]) | |
336 | |
337 im = GetImage(_REMOTE, '/instances/%s/image-uint16' % i) | |
338 self.assertEqual(512, im.size[0]) | |
339 self.assertEqual(358, im.size[1]) | |
340 | |
341 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % i) | |
342 self.assertEqual("L", im.mode) | |
343 self.assertEqual(512, im.size[0]) | |
344 self.assertEqual(358, im.size[1]) | |
345 | |
346 im = GetImage(_REMOTE, '/instances/%s/frames/0/image-uint8' % i) | |
347 self.assertEqual("L", im.mode) | |
348 self.assertEqual(512, im.size[0]) | |
349 self.assertEqual(358, im.size[1]) | |
350 | |
351 im = GetImage(_REMOTE, '/instances/%s/frames/0/image-uint16' % i) | |
352 self.assertEqual(512, im.size[0]) | |
353 self.assertEqual(358, im.size[1]) | |
64 | 354 |
355 # This is Little Endian Explicit | |
356 self.assertEqual('1.2.840.10008.1.2.1', DoGet(_REMOTE, '/instances/%s/header?simplify' % i)['TransferSyntaxUID']) | |
357 | |
6 | 358 |
359 def test_hierarchy(self): | |
360 UploadFolder(_REMOTE, 'Brainix/Epi') | |
361 UploadFolder(_REMOTE, 'Brainix/Flair') | |
362 UploadFolder(_REMOTE, 'Knee/T1') | |
363 UploadFolder(_REMOTE, 'Knee/T2') | |
364 | |
365 p = DoGet(_REMOTE, '/patients') | |
366 s = DoGet(_REMOTE, '/studies') | |
367 t = DoGet(_REMOTE, '/series') | |
368 self.assertEqual(2, len(p)) | |
369 self.assertEqual(2, len(s)) | |
370 self.assertEqual(4, len(t)) | |
371 self.assertEqual(94, len(DoGet(_REMOTE, '/instances'))) | |
372 | |
373 brainixPatient = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' | |
374 brainixStudy = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' | |
375 brainixEpi = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
376 brainixFlair = '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
377 | |
378 kneePatient = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' | |
379 kneeStudy = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' | |
380 kneeT1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
381 kneeT2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
382 | |
383 self.assertTrue(brainixPatient in p) | |
384 self.assertTrue(kneePatient in p) | |
385 self.assertTrue(brainixStudy in s) | |
386 self.assertTrue(kneeStudy in s) | |
387 self.assertTrue(brainixEpi in t) | |
388 self.assertTrue(brainixFlair in t) | |
389 self.assertTrue(kneeT1 in t) | |
390 self.assertTrue(kneeT2 in t) | |
391 | |
392 self.assertEqual(44, len(DoGet(_REMOTE, '/patients/%s/instances' % brainixPatient))) | |
393 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/series' % brainixPatient))) | |
394 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/studies' % brainixPatient))) | |
395 | |
396 self.assertEqual(50, len(DoGet(_REMOTE, '/patients/%s/instances' % kneePatient))) | |
397 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/series' % kneePatient))) | |
398 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/studies' % kneePatient))) | |
399 | |
400 self.assertEqual(2, len(DoGet(_REMOTE, '/studies/%s/series' % brainixStudy))) | |
401 self.assertEqual(44, len(DoGet(_REMOTE, '/studies/%s/instances' % brainixStudy))) | |
402 | |
403 self.assertEqual(2, len(DoGet(_REMOTE, '/studies/%s/series' % kneeStudy))) | |
404 self.assertEqual(50, len(DoGet(_REMOTE, '/studies/%s/instances' % kneeStudy))) | |
405 | |
406 self.assertEqual(22, len(DoGet(_REMOTE, '/series/%s/instances' % brainixEpi))) | |
407 self.assertEqual(22, len(DoGet(_REMOTE, '/series/%s/instances' % brainixFlair))) | |
408 self.assertEqual(24, len(DoGet(_REMOTE, '/series/%s/instances' % kneeT1))) | |
409 self.assertEqual(26, len(DoGet(_REMOTE, '/series/%s/instances' % kneeT2))) | |
410 | |
411 for patient in p: | |
412 for study in DoGet(_REMOTE, '/patients/%s/studies' % patient): | |
413 self.assertEqual(patient, study['ParentPatient']) | |
414 for series in DoGet(_REMOTE, '/studies/%s/series' % study['ID']): | |
415 self.assertEqual(study['ID'], series['ParentStudy']) | |
211 | 416 self.assertEqual('Unknown', series['Status']) |
6 | 417 for instance in DoGet(_REMOTE, '/series/%s/instances' % series['ID']): |
418 self.assertEqual(series['ID'], instance['ParentSeries']) | |
419 | |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
420 if not IsOrthancVersionAbove(_REMOTE, 1, 9, 1): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
421 # The "dicom-as-json" attachment was removed in Orthanc 1.9.1 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
422 self.assertEqual(json.dumps(DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % instance['ID'])), |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
423 json.dumps(DoGet(_REMOTE, '/instances/%s/tags' % instance['ID']))) |
6 | 424 |
425 | |
426 r = DoDelete(_REMOTE, "/studies/%s" % brainixStudy)['RemainingAncestor'] | |
427 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
428 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
429 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
430 self.assertEqual(50, len(DoGet(_REMOTE, '/instances'))) | |
431 self.assertEqual(None, r) | |
432 | |
433 r = DoDelete(_REMOTE, "/series/%s" % kneeT2)['RemainingAncestor'] | |
434 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
435 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
436 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
437 self.assertEqual(24, len(DoGet(_REMOTE, '/instances'))) | |
438 self.assertEqual('Study', r['Type']) | |
439 self.assertEqual(kneeStudy, r['ID']) | |
440 | |
441 r = DoDelete(_REMOTE, "/instances/%s" % DoGet(_REMOTE, '/instances')[0])['RemainingAncestor'] | |
442 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
443 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
444 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
445 self.assertEqual(23, len(DoGet(_REMOTE, '/instances'))) | |
446 self.assertEqual('Series', r['Type']) | |
447 self.assertEqual(kneeT1, r['ID']) | |
448 | |
449 r = DoDelete(_REMOTE, "/patients/%s" % kneePatient)['RemainingAncestor'] | |
450 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
451 self.assertEqual(0, len(DoGet(_REMOTE, '/studies'))) | |
452 self.assertEqual(0, len(DoGet(_REMOTE, '/series'))) | |
453 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
454 self.assertEqual(None, r) | |
455 | |
456 DropOrthanc(_REMOTE) | |
457 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize']) | |
458 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) | |
7 | 459 |
213
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
460 def test_delete_cascade(self): |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
461 # 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
|
462 |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
463 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
|
464 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
|
465 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
|
466 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
|
467 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
|
468 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
|
469 |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
470 DoDelete(_REMOTE, '/instances/%s' % a) |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
471 |
eba6b8c38eee
added a delete_cascade test to reproduce an issue in our MSSQL plugin
amazy
parents:
211
diff
changeset
|
472 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
|
473 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
|
474 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
|
475 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
|
476 |
7 | 477 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
478 def test_multiframe(self): |
7 | 479 i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] |
480 self.assertEqual(76, len(DoGet(_REMOTE, '/instances/%s/frames' % i))) | |
481 | |
482 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % i) | |
483 self.assertEqual("L", im.mode) | |
484 self.assertEqual(512, im.size[0]) | |
485 self.assertEqual(512, im.size[1]) | |
486 | |
487 DoGet(_REMOTE, '/instances/%s/frames/0/image-uint8' % i) | |
488 DoGet(_REMOTE, '/instances/%s/frames/0/image-uint16' % i) | |
489 DoGet(_REMOTE, '/instances/%s/frames/75/preview' % i) | |
490 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/aaa/preview' % i)) | |
491 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/76/preview' % i)) | |
492 | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
493 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
494 def test_changes(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
495 # Check emptiness |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
496 c = DoGet(_REMOTE, '/changes') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
497 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
|
498 #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
|
499 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
500 c = DoGet(_REMOTE, '/changes?last') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
501 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
|
502 #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
|
503 self.assertTrue(c['Done']) |
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 # Add 1 instance |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
506 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
|
507 c = DoGet(_REMOTE, '/changes') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
508 begin = c['Last'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
509 self.assertEqual(4, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
510 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
511 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
|
512 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
513 c = DoGet(_REMOTE, '/changes?last') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
514 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
515 self.assertEqual(begin, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
516 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
517 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
|
518 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
519 self.assertEqual(begin, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
520 self.assertTrue(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
521 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
|
522 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
523 self.assertEqual(begin - 1, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
524 self.assertFalse(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
525 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
|
526 self.assertEqual(1, len(c['Changes'])) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
527 self.assertEqual(begin - 2, c['Last']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
528 self.assertFalse(c['Done']) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
529 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
530 UploadFolder(_REMOTE, 'Knee/T1') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
531 UploadFolder(_REMOTE, 'Knee/T2') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
532 since = begin |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
533 countPatients = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
534 countStudies = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
535 countSeries = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
536 countInstances = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
537 completed = 0 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
538 while True: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
539 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
|
540 since = c['Last'] |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
541 for i in c['Changes']: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
542 if i['ResourceType'] == 'Instance': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
543 countInstances += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
544 if i['ResourceType'] == 'Patient': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
545 countPatients += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
546 if i['ResourceType'] == 'Study': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
547 countStudies += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
548 if i['ResourceType'] == 'Series': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
549 countSeries += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
550 if i['ChangeType'] == 'NewInstance': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
551 countInstances += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
552 if i['ChangeType'] == 'NewPatient': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
553 countPatients += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
554 if i['ChangeType'] == 'NewStudy': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
555 countStudies += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
556 if i['ChangeType'] == 'NewSeries': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
557 countSeries += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
558 if i['ChangeType'] == 'CompletedSeries': |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
559 completed += 1 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
560 self.assertTrue('ID' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
561 self.assertTrue('Path' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
562 self.assertTrue('Seq' in i) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
563 if c['Done']: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
564 break |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
565 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
566 self.assertEqual(2 * 50, countInstances) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
567 self.assertEqual(2 * 1, countPatients) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
568 self.assertEqual(2 * 1, countStudies) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
569 self.assertEqual(2 * 2, countSeries) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
570 self.assertEqual(0, completed) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
571 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
572 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
573 def test_archive(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
574 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
|
575 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') |
192 | 576 knee = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' |
577 | |
578 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
|
579 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
580 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
581 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
|
582 self.assertEqual(2, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
583 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
584 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
|
585 self.assertEqual(1, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
586 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
587 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
192 | 588 brainix = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' |
589 | |
590 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
|
591 self.assertEqual(2, len(z.namelist())) |
192 | 592 |
593 z = PostArchive(_REMOTE, '/tools/create-archive', { | |
594 'Resources' : [ brainix, knee ] | |
595 }) | |
596 self.assertEqual(3, len(z.namelist())) | |
597 | |
8
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
598 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
599 def test_media_archive(self): |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
600 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
|
601 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
|
602 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
603 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
|
604 self.assertEqual(3, len(z.namelist())) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
605 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
|
606 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
|
607 self.assertTrue('DICOMDIR' in z.namelist()) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
608 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
609 try: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
610 os.remove('/tmp/DICOMDIR') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
611 except: |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
612 # The file does not exist |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
613 pass |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
614 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
615 z.extract('DICOMDIR', '/tmp') |
45 | 616 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
|
617 stderr = subprocess.STDOUT).split('\n') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
618 self.assertEqual(3, len(a)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
619 self.assertTrue(a[0].startswith('Warning')) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
620 self.assertEqual('BasicDirectory', a[1]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
621 self.assertEqual('', a[2]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
622 |
45 | 623 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
|
624 stderr = subprocess.STDOUT).split('\n') |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
625 self.assertEqual(1, len(a)) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
626 self.assertEqual('', a[0]) |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
627 |
45 | 628 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
|
629 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
|
630 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
|
631 |
f8d781d1d267
test_changes, test_archive, test_media_archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
7
diff
changeset
|
632 os.remove('/tmp/DICOMDIR') |
10 | 633 |
634 | |
635 def test_protection(self): | |
636 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
637 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
638 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
639 a = DoGet(_REMOTE, '/patients')[0] | |
640 b = DoGet(_REMOTE, '/patients')[1] | |
641 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
642 DoPut(_REMOTE, '/patients/%s/protected' % a, '0', 'text/plain') | |
643 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
644 DoPut(_REMOTE, '/patients/%s/protected' % a, '1', 'text/plain') | |
645 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
646 DoPut(_REMOTE, '/patients/%s/protected' % a, '0', 'text/plain') | |
647 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
648 | |
649 | |
12 | 650 def test_raw_tags(self): |
10 | 651 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
652 | |
653 dicom = DoGet(_REMOTE, '/instances/%s/file' % i) | |
654 self.assertEqual('1a7c56cb02d6e742cc9c856a8ac182e3', ComputeMD5(dicom)) | |
655 | |
656 s = '/instances/%s/content/' % i | |
657 | |
658 self.assertEqual('LOGIQBOOK', DoGet(_REMOTE, s + '0008-1010').strip()) | |
659 self.assertRaises(Exception, lambda: DoGet(_REMOTE, s + '0008-1011')) | |
660 | |
661 self.assertEqual('Abdomen', DoGet(_REMOTE, s + '7fe1-1001/0/7fe1-1008/0/7fe1-1057').strip()) | |
662 self.assertEqual('cla_3c', DoGet(_REMOTE, s + '7fe1-1001/0/7fe1-1008/8/7fe1-1057').strip()) | |
663 | |
664 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
665 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
666 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
667 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
668 | |
669 for i in DoGet(_REMOTE, '/instances'): | |
670 aid = DoGet(_REMOTE, '/instances/%s' % i)['MainDicomTags']['SOPInstanceUID'] | |
671 self.assertEqual(aid, DoGet(_REMOTE, '/instances/%s/content/0008-0018' % i).replace(chr(0), '')) | |
672 | |
673 | |
674 def test_raw_tags_mdn(self): | |
675 # Bug reported by Cyril Paulus | |
676 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
677 self.assertAlmostEqual(0.000027, DoGet(_REMOTE, '/instances/%s/content/7053-1000' % i)) | |
678 | |
679 | |
680 def test_modify_instance(self): | |
681 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] | |
682 modified = DoPost(_REMOTE, '/instances/%s/modify' % i, | |
683 json.dumps({ | |
684 "Replace" : { | |
685 "PatientName" : "hello", | |
686 #"PatientID" : "world" | |
687 }, | |
688 "Remove" : [ "StationName" ], | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
689 "RemovePrivateTags" : True |
10 | 690 }), |
691 'application/json') | |
692 j = DoPost(_REMOTE, '/instances', modified, 'application/dicom')['ID'] | |
693 | |
694 self.assertNotEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
695 #self.assertNotEqual('world', DoGet(_REMOTE, '/instances/%s/content/0010-0020' % i).strip()) | |
83 | 696 self.assertEqual('LOGIQBOOK', DoGet(_REMOTE, '/instances/%s/content/0008-1010' % i).strip()) |
10 | 697 DoGet(_REMOTE, '/instances/%s/content/6003-1010' % i) # Some private tag |
698 | |
699 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
700 #self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/0010-0020' % j).strip()) | |
701 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/0008-1010' % j)) | |
702 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/6003-1010' % j)) | |
703 | |
704 | |
705 def test_modify_series(self): | |
706 # Upload 4 images from the same series | |
707 for i in range(4): | |
708 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
709 | |
710 origSeries = DoGet(_REMOTE, '/series')[0] | |
711 newSeries = DoPost(_REMOTE, '/series/%s/modify' % origSeries, | |
712 '{"Replace":{"PatientName":"Jodogne"}}', | |
713 'application/json')['ID'] | |
714 | |
715 self.assertEqual(origSeries, DoGet(_REMOTE, '/series/%s' % newSeries)['ModifiedFrom']) | |
716 instances = DoGet(_REMOTE, '/series/%s' % newSeries)['Instances'] | |
717 self.assertEqual(4, len(instances)) | |
718 for i in instances: | |
719 j = DoGet(_REMOTE, '/instances/%s' % i)['ModifiedFrom'] | |
720 self.assertEqual(newSeries, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
721 self.assertEqual(origSeries, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
722 | |
723 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
724 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
725 | |
726 | |
727 def test_modify_study(self): | |
728 # Upload 4 images from the 2 series of the same study | |
729 for i in range(4): | |
730 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
731 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
732 | |
733 origStudy = DoGet(_REMOTE, '/studies')[0] | |
734 newStudy = DoPost(_REMOTE, '/studies/%s/modify' % origStudy, | |
735 '{"Replace":{"PatientName":"Jodogne"}}', | |
736 'application/json')['ID'] | |
737 | |
738 self.assertEqual(origStudy, DoGet(_REMOTE, '/studies/%s' % newStudy)['ModifiedFrom']) | |
739 series = DoGet(_REMOTE, '/studies/%s' % newStudy)['Series'] | |
740 self.assertEqual(2, len(series)) | |
741 for s in series: | |
742 ss = DoGet(_REMOTE, '/series/%s' % s)['ModifiedFrom'] | |
743 self.assertEqual(newStudy, DoGet(_REMOTE, '/series/%s' % s)['ParentStudy']) | |
744 self.assertEqual(origStudy, DoGet(_REMOTE, '/series/%s' % ss)['ParentStudy']) | |
745 | |
746 instances = DoGet(_REMOTE, '/series/%s' % s)['Instances'] | |
747 for i in instances: | |
748 j = DoGet(_REMOTE, '/instances/%s' % i)['ModifiedFrom'] | |
749 self.assertEqual(s, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
750 self.assertEqual(ss, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
751 | |
752 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
753 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
754 | |
755 | |
756 def test_anonymize_series(self): | |
757 # Upload 4 images from the same series | |
758 for i in range(4): | |
759 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
760 | |
761 origSeries = DoGet(_REMOTE, '/series')[0] | |
762 newSeries = DoPost(_REMOTE, '/series/%s/anonymize' % origSeries, | |
763 '{}', | |
764 'application/json')['ID'] | |
765 | |
766 self.assertEqual(origSeries, DoGet(_REMOTE, '/series/%s' % newSeries)['AnonymizedFrom']) | |
767 instances = DoGet(_REMOTE, '/series/%s' % newSeries)['Instances'] | |
768 self.assertEqual(4, len(instances)) | |
769 for i in instances: | |
770 j = DoGet(_REMOTE, '/instances/%s' % i)['AnonymizedFrom'] | |
771 self.assertEqual(newSeries, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
772 self.assertEqual(origSeries, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
773 | |
774 DoGet(_REMOTE, '/instances/%s/content/0008-1010' % j) | |
775 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/0008-1010' % i)) | |
776 | |
777 | |
778 def test_anonymize_study(self): | |
779 # Upload 4 images from the 2 series of the same study | |
780 for i in range(4): | |
781 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
782 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
783 | |
784 origStudy = DoGet(_REMOTE, '/studies')[0] | |
785 newStudy = DoPost(_REMOTE,'/studies/%s/anonymize' % origStudy, | |
786 '{"Replace":{"PatientName":"Jodogne"}}', | |
787 'application/json')['ID'] | |
788 | |
789 self.assertEqual(origStudy, DoGet(_REMOTE, '/studies/%s' % newStudy)['AnonymizedFrom']) | |
790 series = DoGet(_REMOTE, '/studies/%s' % newStudy)['Series'] | |
791 self.assertEqual(2, len(series)) | |
792 for s in series: | |
793 ss = DoGet(_REMOTE, '/series/%s' % s)['AnonymizedFrom'] | |
794 self.assertEqual(newStudy, DoGet(_REMOTE, '/series/%s' % s)['ParentStudy']) | |
795 self.assertEqual(origStudy, DoGet(_REMOTE, '/series/%s' % ss)['ParentStudy']) | |
796 | |
797 instances = DoGet(_REMOTE, '/series/%s' % s)['Instances'] | |
798 for i in instances: | |
799 j = DoGet(_REMOTE, '/instances/%s' % i)['AnonymizedFrom'] | |
800 self.assertEqual(s, DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries']) | |
801 self.assertEqual(ss, DoGet(_REMOTE, '/instances/%s' % j)['ParentSeries']) | |
802 | |
803 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % i).strip()) | |
804 self.assertNotEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % j).strip()) | |
11 | 805 |
806 | |
807 | |
808 def test_storescu(self): | |
809 # Check emptiness | |
810 e = DoGet(_REMOTE, '/exports') | |
811 self.assertEqual(0, len(e['Exports'])) | |
812 self.assertEqual(0, e['Last']) | |
813 self.assertTrue(e['Done']) | |
814 e = DoGet(_REMOTE, '/exports?last') | |
815 self.assertEqual(0, len(e['Exports'])) | |
816 self.assertEqual(0, e['Last']) | |
817 self.assertTrue(e['Done']) | |
818 | |
819 # Add 1 instance | |
820 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
821 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
822 | |
823 # Export the instance | |
824 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') # instance | |
825 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
826 self.assertEqual(1, len(DoGet(_LOCAL, '/studies'))) | |
827 self.assertEqual(1, len(DoGet(_LOCAL, '/series'))) | |
828 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
829 | |
830 e = DoGet(_REMOTE, '/exports') | |
831 self.assertEqual(1, len(e['Exports'])) | |
832 self.assertTrue(e['Done']) | |
833 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
834 e = DoGet(_REMOTE, '/exports?limit=1') | |
835 self.assertEqual(1, len(e['Exports'])) | |
836 self.assertTrue(e['Done']) | |
837 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
838 e = DoGet(_REMOTE, '/exports?last') | |
839 self.assertEqual(1, len(e['Exports'])) | |
840 self.assertTrue(e['Done']) | |
841 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
842 seqInstance = e['Last'] | |
843 | |
844 # Export the series | |
845 j = DoPost(_REMOTE, '/modalities/orthanctest/store', 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', 'text/plain') | |
846 | |
847 e = DoGet(_REMOTE, '/exports') | |
848 self.assertEqual(2, len(e['Exports'])) | |
849 self.assertTrue(e['Done']) | |
850 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
851 seqSeries = e['Last'] | |
852 self.assertNotEqual(seqInstance, seqSeries) | |
853 e = DoGet(_REMOTE, '/exports?limit=1&since=0') | |
854 self.assertEqual(1, len(e['Exports'])) | |
855 self.assertFalse(e['Done']) | |
856 self.assertEqual(e['Exports'][-1]['Seq'], seqInstance) | |
857 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqInstance)) | |
858 self.assertEqual(1, len(e['Exports'])) | |
859 self.assertTrue(e['Done']) | |
860 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
861 e = DoGet(_REMOTE, '/exports?last') | |
862 self.assertEqual(1, len(e['Exports'])) | |
863 self.assertTrue(e['Done']) | |
864 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
865 | |
866 # Export the study | |
867 j = DoPost(_REMOTE, '/modalities/orthanctest/store', 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', 'text/plain') | |
868 seqStudy = DoGet(_REMOTE, '/exports')['Last'] | |
869 | |
870 # Export the patient | |
871 j = DoPost(_REMOTE, '/modalities/orthanctest/store', '6816cb19-844d5aee-85245eba-28e841e6-2414fae2', 'text/plain') | |
872 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
873 self.assertEqual(1, len(DoGet(_LOCAL, '/studies'))) | |
874 self.assertEqual(1, len(DoGet(_LOCAL, '/series'))) | |
875 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
876 | |
877 e = DoGet(_REMOTE, '/exports') | |
878 self.assertEqual(4, len(e['Exports'])) | |
879 self.assertTrue(e['Done']) | |
880 self.assertEqual(e['Exports'][-1]['Seq'], e['Last']) | |
881 seqPatient = e['Last'] | |
882 self.assertNotEqual(seqInstance, seqSeries) | |
883 self.assertNotEqual(seqSeries, seqStudy) | |
884 self.assertNotEqual(seqStudy, seqPatient) | |
885 self.assertTrue(seqInstance < seqSeries) | |
886 self.assertTrue(seqSeries < seqStudy) | |
887 self.assertTrue(seqStudy < seqPatient) | |
888 e = DoGet(_REMOTE, '/exports?limit=1&since=0') | |
889 self.assertEqual(1, len(e['Exports'])) | |
890 self.assertFalse(e['Done']) | |
891 self.assertEqual(e['Exports'][-1]['Seq'], seqInstance) | |
892 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqInstance)) | |
893 self.assertEqual(1, len(e['Exports'])) | |
894 self.assertFalse(e['Done']) | |
895 self.assertEqual(e['Exports'][-1]['Seq'], seqSeries) | |
896 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqSeries)) | |
897 self.assertEqual(1, len(e['Exports'])) | |
898 self.assertFalse(e['Done']) | |
899 self.assertEqual(e['Exports'][-1]['Seq'], seqStudy) | |
900 e = DoGet(_REMOTE, '/exports?limit=1&since=' + str(seqStudy)) | |
901 self.assertEqual(1, len(e['Exports'])) | |
902 self.assertTrue(e['Done']) | |
903 self.assertEqual(e['Exports'][-1]['Seq'], seqPatient) | |
904 e = DoGet(_REMOTE, '/exports?last') | |
905 self.assertEqual(1, len(e['Exports'])) | |
906 self.assertTrue(e['Done']) | |
907 self.assertEqual(e['Exports'][-1]['Seq'], seqPatient) | |
908 | |
909 | |
910 # Check the content of the logged information | |
911 e = DoGet(_REMOTE, '/exports')['Exports'] | |
912 | |
913 if 'PatientID' in e[0]: | |
914 # Since Orthanc 0.8.6 | |
915 patient = 'PatientID' | |
916 study = 'StudyInstanceUID' | |
917 series = 'SeriesInstanceUID' | |
918 instance = 'SOPInstanceUID' | |
919 else: | |
920 # Up to Orthanc 0.8.5 | |
921 patient = 'PatientId' | |
922 study = 'StudyInstanceUid' | |
923 series = 'SeriesInstanceUid' | |
924 instance = 'SopInstanceUid' | |
925 | |
926 for k in range(4): | |
927 self.assertTrue('Date' in e[k]) | |
928 self.assertTrue('Seq' in e[k]) | |
929 self.assertEqual('orthanctest', e[k]['RemoteModality']) | |
930 | |
931 self.assertEqual(10, len(e[0])) | |
932 self.assertEqual('Instance', e[0]['ResourceType']) | |
933 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', e[0]['ID']) | |
934 self.assertEqual('/instances/66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', e[0]['Path']) | |
935 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', e[0][instance]) | |
936 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', e[0][series]) | |
937 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[0][study]) | |
938 self.assertEqual('ozp00SjY2xG', e[0][patient]) | |
939 | |
940 self.assertEqual(9, len(e[1])) | |
941 self.assertEqual('Series', e[1]['ResourceType']) | |
942 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', e[1]['ID']) | |
943 self.assertEqual('/series/f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', e[1]['Path']) | |
944 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', e[1][series]) | |
945 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[1][study]) | |
946 self.assertEqual('ozp00SjY2xG', e[1][patient]) | |
947 | |
948 self.assertEqual(8, len(e[2])) | |
949 self.assertEqual('Study', e[2]['ResourceType']) | |
950 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', e[2]['ID']) | |
951 self.assertEqual('/studies/b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', e[2]['Path']) | |
952 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', e[2][study]) | |
953 self.assertEqual('ozp00SjY2xG', e[2][patient]) | |
954 | |
955 self.assertEqual(7, len(e[3])) | |
956 self.assertEqual('Patient', e[3]['ResourceType']) | |
957 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', e[3]['ID']) | |
958 self.assertEqual('/patients/6816cb19-844d5aee-85245eba-28e841e6-2414fae2', e[3]['Path']) | |
959 self.assertEqual('ozp00SjY2xG', e[3][patient]) | |
960 | |
961 DropOrthanc(_REMOTE) | |
962 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
963 | |
964 | |
965 def test_store_peer(self): | |
966 self.assertEqual(0, len(DoGet(_LOCAL, '/exports')['Exports'])) | |
967 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
968 | |
969 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
970 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
971 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
972 | |
973 j = DoPost(_REMOTE, '/peers/peer/store', str(i), 'text/plain') | |
974 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
975 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
976 | |
977 self.assertEqual(1, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
978 | |
979 DropOrthanc(_REMOTE) | |
980 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) | |
981 | |
982 | |
983 def test_bulk_storescu(self): | |
984 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
985 | |
986 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
987 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
988 | |
989 j = DoPost(_REMOTE, '/modalities/orthanctest/store', [ a['ID'], b['ID'] ], 'application/json') | |
990 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
991 | |
992 DropOrthanc(_LOCAL) | |
993 | |
994 # Send using patient's UUID | |
995 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
996 j = DoPost(_REMOTE, '/modalities/orthanctest/store', | |
997 [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ], 'application/json') | |
998 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | |
999 | |
1000 | |
1001 def test_color(self): | |
1002 i = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] | |
1003 im = GetImage(_REMOTE, '/instances/%s/preview' % i) | |
1004 self.assertEqual("RGB", im.mode) | |
1005 self.assertEqual(41, im.size[0]) | |
1006 self.assertEqual(41, im.size[1]) | |
1007 | |
1008 # http://effbot.org/zone/pil-comparing-images.htm | |
13 | 1009 truth = Image.open(GetDatabasePath('ColorTestMalaterre.png')) |
11 | 1010 self.assertTrue(ImageChops.difference(im, truth).getbbox() is None) |
1011 | |
1012 | |
12 | 1013 def test_faking_ruby_put(self): |
1014 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
1015 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
1016 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
1017 a = DoGet(_REMOTE, '/patients')[0] | |
1018 b = DoGet(_REMOTE, '/patients')[1] | |
1019 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
1020 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '0') | |
1021 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
1022 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '1') | |
1023 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
1024 DoGet(_REMOTE, '/patients/%s/protected' % a, data = { '_method' : 'PUT' }, body = '0') | |
1025 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
1026 | |
1027 | |
1028 def test_faking_ruby_delete(self): | |
1029 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
1030 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
1031 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
1032 a = DoGet(_REMOTE, '/patients')[0] | |
1033 b = DoGet(_REMOTE, '/patients')[1] | |
1034 DoGet(_REMOTE, '/patients/%s' % a, data = { '_method' : 'DELETE' }) | |
1035 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1036 DoGet(_REMOTE, '/patients/%s' % b, data = { '_method' : 'DELETE' }) | |
1037 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1038 | |
1039 | |
1040 def test_faking_google_put(self): | |
1041 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
1042 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
1043 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
1044 a = DoGet(_REMOTE, '/patients')[0] | |
1045 b = DoGet(_REMOTE, '/patients')[1] | |
1046 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
1047 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '0') | |
1048 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
1049 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '1') | |
1050 self.assertEqual(1, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
1051 DoPost(_REMOTE, '/patients/%s/protected' % a, headers = { 'X-HTTP-Method-Override' : 'PUT' }, data = '0') | |
1052 self.assertEqual(0, DoGet(_REMOTE, '/patients/%s/protected' % a)) | |
1053 | |
1054 | |
1055 def test_faking_google_delete(self): | |
1056 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
1057 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
1058 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
1059 a = DoGet(_REMOTE, '/patients')[0] | |
1060 b = DoGet(_REMOTE, '/patients')[1] | |
1061 DoPost(_REMOTE, '/patients/%s' % a, headers = { 'X-HTTP-Method-Override' : 'DELETE' }) | |
1062 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1063 DoPost(_REMOTE, '/patients/%s' % b, headers = { 'X-HTTP-Method-Override' : 'DELETE' }) | |
1064 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1065 | |
1066 | |
1067 def test_lua(self): | |
1068 self.assertEqual(42, DoPost(_REMOTE, '/tools/execute-script', 'print(42)')) | |
1069 self.assertTrue(IsDefinedInLua(_REMOTE, 'PrintRecursive')) | |
1070 self.assertFalse(IsDefinedInLua(_REMOTE, 'HelloWorld')) | |
1071 | |
1072 | |
1073 def test_metadata(self): | |
1074 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
1075 p = DoGet(_REMOTE, '/patients')[0] | |
1076 i = DoGet(_REMOTE, '/instances')[0] | |
369
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1077 series = DoGet(_REMOTE, '/series')[0] |
12 | 1078 |
1079 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
1080 self.assertEqual(1, len(m)) | |
1081 self.assertEqual('LastUpdate', m[0]) | |
1082 | |
369
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1083 # The lines below failed on Orthanc <= 1.8.2 |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1084 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/studies/%s/metadata' % p)) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1085 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/series/%s/metadata' % p)) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1086 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/metadata' % p)) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1087 |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1088 m = DoGet(_REMOTE, '/studies/%s/metadata' % DoGet(_REMOTE, '/studies')[0]) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1089 self.assertEqual(1, len(m)) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1090 self.assertEqual('LastUpdate', m[0]) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1091 |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1092 m = DoGet(_REMOTE, '/series/%s/metadata' % series) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1093 self.assertEqual(2, len(m)) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1094 self.assertTrue('LastUpdate' in m) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1095 |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1096 # New in Orthanc 1.9.0 |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1097 self.assertTrue('RemoteAET' in m) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1098 self.assertEqual(DoGet(_REMOTE, '/series/%s/metadata/RemoteAET' % series), '') # None, received by REST API |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1099 |
12 | 1100 m = DoGet(_REMOTE, '/instances/%s/metadata' % i) |
379
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
1101 if IsOrthancVersionAbove(_REMOTE, 1, 9, 1): |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
1102 self.assertEqual(9, len(m)) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
1103 self.assertTrue('PixelDataOffset' in m) # New in Orthanc 1.9.1 |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
1104 self.assertEqual(int(DoGet(_REMOTE, '/instances/%s/metadata/PixelDataOffset' % i)), 0x0c78) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
1105 else: |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
1106 self.assertEqual(8, len(m)) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
1107 |
12 | 1108 self.assertTrue('IndexInSeries' in m) |
1109 self.assertTrue('ReceptionDate' in m) | |
1110 self.assertTrue('RemoteAET' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1111 self.assertTrue('Origin' in m) |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1112 self.assertTrue('TransferSyntax' in m) |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1113 self.assertTrue('SopClassUid' in m) |
145 | 1114 self.assertTrue('RemoteIP' in m) |
1115 self.assertTrue('HttpUsername' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1116 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
|
1117 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
|
1118 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
|
1119 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
|
1120 self.assertEqual(DoGet(_REMOTE, '/instances/%s/metadata/SopClassUid' % i), '1.2.840.10008.5.1.4.1.1.4') |
12 | 1121 |
1122 # Play with custom metadata | |
1123 DoPut(_REMOTE, '/patients/%s/metadata/5555' % p, 'coucou') | |
1124 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
1125 self.assertEqual(2, len(m)) | |
1126 self.assertTrue('LastUpdate' in m) | |
1127 self.assertTrue('5555' in m) | |
1128 self.assertEqual('coucou', DoGet(_REMOTE, '/patients/%s/metadata/5555' % p)) | |
1129 DoPut(_REMOTE, '/patients/%s/metadata/5555' % p, 'hello') | |
1130 self.assertEqual('hello', DoGet(_REMOTE, '/patients/%s/metadata/5555' % p)) | |
1131 DoDelete(_REMOTE, '/patients/%s/metadata/5555' % p) | |
1132 m = DoGet(_REMOTE, '/patients/%s/metadata' % p) | |
1133 self.assertEqual(1, len(m)) | |
1134 self.assertTrue('LastUpdate' in m) | |
13 | 1135 |
1136 | |
1137 def test_statistics(self): | |
1138 # Upload 16 instances | |
1139 for i in range(4): | |
1140 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1141 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1142 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1143 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1144 | |
1145 s = DoGet(_REMOTE, '/statistics') | |
1146 self.assertEqual(16, s['CountInstances']) | |
1147 self.assertEqual(2, s['CountPatients']) | |
1148 self.assertEqual(2, s['CountStudies']) | |
1149 self.assertEqual(4, s['CountSeries']) | |
1150 d = int(s['TotalUncompressedSize']) | |
1151 | |
1152 e = 0 | |
1153 for patient in DoGet(_REMOTE, '/patients'): | |
1154 s = DoGet(_REMOTE, '/patients/%s/statistics' % patient) | |
1155 self.assertEqual(8, s['CountInstances']) | |
1156 self.assertEqual(1, s['CountStudies']) | |
1157 self.assertEqual(2, s['CountSeries']) | |
1158 e += int(s['UncompressedSize']) | |
1159 | |
1160 for study in DoGet(_REMOTE, '/studies'): | |
1161 s = DoGet(_REMOTE, '/studies/%s/statistics' % study) | |
1162 self.assertEqual(8, s['CountInstances']) | |
1163 self.assertEqual(2, s['CountSeries']) | |
1164 e += int(s['UncompressedSize']) | |
1165 | |
1166 for series in DoGet(_REMOTE, '/series'): | |
1167 s = DoGet(_REMOTE, '/series/%s/statistics' % series) | |
1168 self.assertEqual(4, s['CountInstances']) | |
1169 e += int(s['UncompressedSize']) | |
1170 | |
1171 self.assertEqual(3 * d, e) | |
1172 | |
1173 | |
1174 def test_custom_attachment(self): | |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
1175 u = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') ['ID'] |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
1176 |
13 | 1177 patient = DoGet(_REMOTE, '/patients')[0] |
1178 instance = DoGet(_REMOTE, '/instances')[0] | |
1179 size = int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']) | |
1180 self.assertEqual(size, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1181 | |
1182 self.assertEqual(0, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1183 self.assertTrue('dicom' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) | |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
1184 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
1185 if IsOrthancVersionAbove(_REMOTE, 1, 9, 1): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
1186 if IsDicomUntilPixelDataStored(_REMOTE): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
1187 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
1188 self.assertTrue('dicom-until-pixel-data' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
1189 else: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
1190 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
1191 else: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
1192 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
1193 self.assertTrue('dicom-as-json' in DoGet(_REMOTE, '/instances/%s/attachments' % instance)) |
13 | 1194 |
1195 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/patients/%s/attachments/22' % patient, 'hello')) | |
1196 hello = 'hellohellohellohellohellohellohellohellohello' | |
1197 DoPut(_REMOTE, '/patients/%s/attachments/1025' % patient, hello) | |
1198 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1199 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1200 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1201 size + int(DoGet(_REMOTE, '/patients/%s/attachments/1025/compressed-size' % patient))) | |
1202 | |
1203 DoPut(_REMOTE, '/patients/%s/attachments/1026' % patient, 'world') | |
1204 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1205 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1206 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1207 size + | |
1208 int(DoGet(_REMOTE, '/patients/%s/attachments/1025/compressed-size' % patient)) + | |
1209 int(DoGet(_REMOTE, '/patients/%s/attachments/1026/compressed-size' % patient))) | |
1210 | |
1211 self.assertEqual(2, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1212 self.assertEqual(hello, DoGet(_REMOTE, '/patients/%s/attachments/1025/data' % patient)) | |
1213 self.assertEqual('world', DoGet(_REMOTE, '/patients/%s/attachments/1026/data' % patient)) | |
1214 DoPost(_REMOTE, '/patients/%s/attachments/1025/verify-md5' % patient) | |
1215 DoPost(_REMOTE, '/patients/%s/attachments/1026/verify-md5' % patient) | |
1216 DoPut(_REMOTE, '/patients/%s/attachments/1026' % patient, 'world2') | |
1217 self.assertEqual('world2', DoGet(_REMOTE, '/patients/%s/attachments/1026/data' % patient)) | |
1218 | |
1219 self.assertRaises(Exception, lambda: DoDelete(_REMOTE, '/instances/%s/attachments/dicom' % instance)) | |
1220 DoDelete(_REMOTE, '/patients/%s/attachments/1025' % patient) | |
1221 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1222 int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1223 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), | |
1224 size + int(DoGet(_REMOTE, '/patients/%s/attachments/1026/compressed-size' % patient))) | |
1225 | |
1226 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1227 DoDelete(_REMOTE, '/patients/%s/attachments/1026' % patient) | |
1228 self.assertEqual(0, len(DoGet(_REMOTE, '/patients/%s/attachments' % patient))) | |
1229 | |
1230 self.assertEqual(int(DoGet(_REMOTE, '/patients/%s/statistics' % patient)['DiskSize']), size) | |
1231 self.assertEqual(size, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) | |
1232 | |
1233 | |
1234 def test_incoming_storescu(self): | |
1235 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
45 | 1236 subprocess.check_call([ FindExecutable('storescu'), |
44
ffa542cce638
Toolbox.FindExecutable()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
43
diff
changeset
|
1237 _REMOTE['Server'], str(_REMOTE['DicomPort']), |
13 | 1238 GetDatabasePath('ColorTestImageJ.dcm') ]) |
1239 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1240 | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1241 i = DoGet(_REMOTE, '/instances') |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1242 self.assertEqual(1, len(i)) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1243 m = DoGet(_REMOTE, '/instances/%s/metadata' % i[0]) |
379
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
1244 |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
1245 if IsOrthancVersionAbove(_REMOTE, 1, 9, 1): |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
1246 self.assertEqual(9, len(m)) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
1247 self.assertTrue('PixelDataOffset' in m) # New in Orthanc 1.9.1 |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
1248 else: |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
1249 self.assertEqual(8, len(m)) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
1250 |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1251 self.assertTrue('IndexInSeries' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1252 self.assertTrue('ReceptionDate' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1253 self.assertTrue('RemoteAET' in m) |
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1254 self.assertTrue('Origin' in m) |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1255 self.assertTrue('TransferSyntax' in m) |
95
a807a4699eb4
testing of metadata SopClassUid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
1256 self.assertTrue('SopClassUid' in m) |
145 | 1257 self.assertTrue('RemoteIP' in m) |
1258 self.assertTrue('CalledAET' in m) | |
63
2652d562267a
test Origin metadata of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
62
diff
changeset
|
1259 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
|
1260 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
|
1261 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
|
1262 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
|
1263 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
|
1264 |
369
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1265 series = DoGet(_REMOTE, '/series')[0] |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1266 m = DoGet(_REMOTE, '/series/%s/metadata' % series) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1267 self.assertEqual(2, len(m)) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1268 self.assertTrue('LastUpdate' in m) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1269 self.assertTrue('RemoteAET' in m) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1270 self.assertEqual(DoGet(_REMOTE, '/series/%s/metadata/RemoteAET' % series), 'STORESCU') |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1271 self.assertEqual(DoGet(_REMOTE, '/series/%s/metadata/LastUpdate' % series), |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1272 DoGet(_REMOTE, '/instances/%s/metadata/ReceptionDate' % i[0])) |
24d93b42873a
test "RemoteAET" metadata at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
368
diff
changeset
|
1273 |
13 | 1274 |
1275 def test_incoming_findscu(self): | |
1276 UploadInstance(_REMOTE, 'Multiframe.dcm') | |
1277 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') | |
1278 | |
1279 i = CallFindScu([ '-k', '0008,0052=PATIENT', '-k', '0010,0010' ]) | |
1280 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', i) | |
1281 self.assertEqual(2, len(patientNames)) | |
1282 self.assertTrue('Test Patient BG ' in patientNames) | |
1283 self.assertTrue('Anonymized' in patientNames) | |
1284 | |
1285 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,0021' ]) | |
1286 series = re.findall('\(0008,0021\).*?\[\s*(.*?)\s*\]', i) | |
1287 self.assertEqual(2, len(series)) | |
1288 self.assertTrue('20070208' in series) | |
1289 self.assertTrue('19980312' in series) | |
1290 | |
335
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
1291 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0008,0021', '-k', 'Modality=MR\\XA' ]) |
56
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1292 series = re.findall('\(0008,0021\).*?\[\s*(.*?)\s*\]', i) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1293 self.assertEqual(1, len(series)) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1294 self.assertTrue('19980312' in series) |
1059b8de42de
ModalitiesInStudy subtest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
55
diff
changeset
|
1295 |
13 | 1296 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'PatientName=Anonymized' ]) |
1297 series = re.findall('\(0010,0010\).*?\[\s*(.*?)\s*\]', i) | |
1298 self.assertEqual(1, len(series)) | |
1299 | |
1300 # Test the "CaseSentitivePN" flag (false by default) | |
1301 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', 'PatientName=anonymized' ]) | |
1302 series = re.findall('\(0010,0010\).*?\[\s*(.*?)\s*\]', i) | |
1303 self.assertEqual(1, len(series)) | |
66
821d9eb73c45
Test returning sequence values
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
1304 |
70 | 1305 # Test range search (buggy if Orthanc <= 0.9.6) |
1306 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=19980312-' ]) | |
1307 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1308 self.assertEqual(2, len(studies)) | |
1309 self.assertTrue('20070208' in studies) | |
1310 self.assertTrue('19980312' in studies) | |
1311 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=19980312-19980312' ]) | |
1312 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1313 self.assertEqual(1, len(studies)) | |
1314 self.assertTrue('19980312' in studies) | |
1315 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyDate=-19980312' ]) | |
1316 studies = re.findall('\(0008,0020\).*?\[\s*(.*?)\s*\]', i) | |
1317 self.assertEqual(1, len(studies)) | |
1318 self.assertTrue('19980312' in studies) | |
326
05f48c19c60d
Test "Retrieve AE Title" is returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
324
diff
changeset
|
1319 |
05f48c19c60d
Test "Retrieve AE Title" is returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
324
diff
changeset
|
1320 # Test that "Retrieve AE Title (0008,0054)" is present, which |
05f48c19c60d
Test "Retrieve AE Title" is returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
324
diff
changeset
|
1321 # was *not* the case in Orthanc <= 1.7.2 |
05f48c19c60d
Test "Retrieve AE Title" is returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
324
diff
changeset
|
1322 i = CallFindScu([ '-k', '0008,0052=INSTANCE' ]) |
05f48c19c60d
Test "Retrieve AE Title" is returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
324
diff
changeset
|
1323 instances = re.findall('\(0008,0054\).*?\[\s*(.*?)\s*\]', i) |
05f48c19c60d
Test "Retrieve AE Title" is returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
324
diff
changeset
|
1324 self.assertEqual(2, len(instances)) |
05f48c19c60d
Test "Retrieve AE Title" is returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
324
diff
changeset
|
1325 self.assertEqual('ORTHANC', instances[0].strip()) |
05f48c19c60d
Test "Retrieve AE Title" is returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
324
diff
changeset
|
1326 self.assertEqual('ORTHANC', instances[1].strip()) |
13 | 1327 |
1328 | |
191
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1329 def test_incoming_findscu_2(self): |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1330 # This test fails if "LookupMode_DatabaseOnly" is used |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1331 # (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
|
1332 # DICOM tags are returned) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1333 UploadInstance(_REMOTE, 'Multiframe.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1334 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1335 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1336 # 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
|
1337 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
|
1338 sequences = re.findall('\(0008,2112\)', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1339 self.assertEqual(1, len(sequences)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1340 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1341 # Test returning a non-main DICOM tag, |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1342 # "SecondaryCaptureDeviceID" (0018,1010), whose value is |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1343 # "MEDPC" in "ColorTestImageJ.dcm" |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1344 i = CallFindScu([ '-k', '0008,0052=SERIES', '-k', '0018,1010' ]) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1345 tags = re.findall('\(0018,1010\).*MEDPC', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1346 self.assertEqual(1, len(tags)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1347 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1348 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1349 def test_incoming_findscu_3(self): |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1350 # This test fails if "LookupMode_DatabaseOnly" or |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1351 # "LookupMode_DiskOnAnswer" is used, as |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1352 # "SecondaryCaptureDeviceID" (0018,1010) is not a main DICOM |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1353 # 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
|
1354 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1355 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1356 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
|
1357 sequences = re.findall('\(0018,1010\)', i) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1358 self.assertEqual(1, len(sequences)) |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1359 |
bc8bc83465dc
testing C-FIND optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
189
diff
changeset
|
1360 |
13 | 1361 def test_incoming_movescu(self): |
1362 UploadInstance(_REMOTE, 'Multiframe.dcm') | |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1363 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1364 # No matching patient, so no job is created |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1365 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1366 CallMoveScu([ '--patient', '-k', '0008,0052=PATIENT', '-k', 'PatientID=none' ]) |
13 | 1367 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1368 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
1369 # 1 Matching patient, track the job |
138 | 1370 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
1371 '--patient', | |
1372 '-k', '0008,0052=PATIENT', | |
1373 '-k', 'PatientID=12345678' | |
1374 ]))) | |
13 | 1375 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) |
1376 | |
1377 | |
1378 def test_findscu(self): | |
1379 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1380 j = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] | |
1381 k = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] | |
1382 DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1383 | |
1384 # Test the "find-patient" level | |
1385 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }) | |
1386 self.assertEqual(1, len(p)) | |
1387 self.assertEqual('ozp00SjY2xG', p[0]['PatientID']) | |
1388 | |
1389 # Test wildcards constraints. The "LO" value representation | |
1390 # for PatientID is always case-sensitive, but the "PN" for | |
1391 # PatientName might depend on the implementation: | |
1392 # "GenerateConfigurationForTests.py" will force it to be case | |
1393 # insensitive (which was the default until Orthanc 0.8.6). | |
1394 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'K*' }) | |
1395 self.assertEqual(1, len(p)) | |
1396 | |
1397 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'k*' }) | |
1398 self.assertEqual(1, len(p)) | |
1399 | |
1400 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : 'ozp*' }) | |
1401 self.assertEqual(1, len(p)) | |
1402 | |
1403 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : 'o?p*' }) | |
1404 self.assertEqual(1, len(p)) | |
1405 | |
1406 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientID' : '0?q*' }) | |
1407 self.assertEqual(0, len(p)) | |
1408 | |
1409 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'B*' }) | |
1410 self.assertEqual(0, len(p)) | |
1411 | |
1412 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'b*' }) | |
1413 self.assertEqual(0, len(p)) | |
1414 | |
1415 DoPost(_REMOTE, '/modalities/orthanctest/store', str(j), 'text/plain') | |
1416 DoPost(_REMOTE, '/modalities/orthanctest/store', str(k), 'text/plain') | |
1417 DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }) | |
1418 self.assertEqual(3, len(DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { }))) | |
1419 | |
1420 p = DoPost(_REMOTE, '/modalities/orthanctest/find-patient', { 'PatientName' : 'A*' }) | |
1421 self.assertEqual(2, len(p)) | |
1422 | |
1423 # Test the "find-study" level. This is the instance "ColorTestImageJ.dcm" | |
1424 s = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ' }) | |
1425 self.assertEqual(1, len(s)) | |
1426 self.assertEqual('20070208', s[0]['StudyDate']) | |
1427 | |
1428 # Test range searches | |
1429 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1430 'StudyDate' : '-20070101' }) | |
1431 self.assertEqual(0, len(t)) | |
1432 | |
1433 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1434 'StudyDate' : '20090101-' }) | |
1435 self.assertEqual(0, len(t)) | |
1436 | |
1437 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1438 'StudyDate' : '20070101-' }) | |
1439 self.assertEqual(1, len(t)) | |
1440 | |
1441 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1442 'StudyDate' : '-20090101' }) | |
1443 self.assertEqual(1, len(t)) | |
1444 | |
1445 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1446 'StudyDate' : '20070207-20070207' }) | |
1447 self.assertEqual(0, len(t)) | |
1448 | |
1449 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1450 'StudyDate' : '20070208-20070208' }) | |
1451 self.assertEqual(1, len(t)) | |
1452 | |
1453 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { 'PatientID' : 'B9uTHKOZ', | |
1454 'StudyDate' : '20070209-20070209' }) | |
1455 self.assertEqual(0, len(t)) | |
1456 | |
1457 # Test the ModalitiesInStudy tag | |
1458 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1459 'PatientID' : 'B9uTHKOZ', | |
1460 'ModalitiesInStudy' : 'US' }) | |
1461 self.assertEqual(0, len(t)) | |
1462 | |
1463 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1464 'PatientID' : 'B9uTHKOZ', | |
1465 'ModalitiesInStudy' : 'CT' }) | |
1466 self.assertEqual(1, len(t)) | |
1467 | |
1468 t = DoPost(_REMOTE, '/modalities/orthanctest/find-study', { | |
1469 'PatientID' : 'B9uTHKOZ', | |
1470 'ModalitiesInStudy' : 'US\\CT' }) | |
1471 self.assertEqual(1, len(t)) | |
1472 | |
1473 # Test the "find-series" level | |
1474 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1475 'PatientID' : 'B9uTHKOZ', | |
1476 'StudyInstanceUID' : s[0]['StudyInstanceUID'] }) | |
1477 self.assertEqual(1, len(t)) | |
1478 | |
1479 # Test "\" separator | |
1480 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1481 'PatientID' : 'B9uTHKOZ', | |
1482 'StudyInstanceUID' : s[0]['StudyInstanceUID'], | |
1483 'Modality' : 'MR\\CT\\US' }) | |
1484 self.assertEqual(1, len(t)) | |
1485 | |
1486 t = DoPost(_REMOTE, '/modalities/orthanctest/find-series', { | |
1487 'PatientID' : 'B9uTHKOZ', | |
1488 'StudyInstanceUID' : s[0]['StudyInstanceUID'], | |
1489 'Modality' : 'MR\\US' }) | |
1490 self.assertEqual(0, len(t)) | |
1491 | |
1492 | |
1493 def test_update_modalities(self): | |
1494 try: | |
1495 DoDelete(_REMOTE, '/modalities/toto') | |
1496 except: | |
1497 pass | |
1498 try: | |
1499 DoDelete(_REMOTE, '/modalities/tata') | |
1500 except: | |
1501 pass | |
1502 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/toto')) | |
348
bed0ab3a1391
test deleting inexistent modality/peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
342
diff
changeset
|
1503 self.assertRaises(Exception, lambda: DoDelete(_REMOTE, '/modalities/toto')) |
13 | 1504 DoPut(_REMOTE, '/modalities/toto', [ "STORESCP", "localhost", 2000 ]) |
116 | 1505 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'MedInria' ]) # check backward compatiblity with obsolete manufacturer |
1506 DoDelete(_REMOTE, '/modalities/tata') | |
124 | 1507 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'GenericNoUniversalWildcard' ]) |
121
1a19f953f53c
also test GenericNoWildcardInDates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
120
diff
changeset
|
1508 DoDelete(_REMOTE, '/modalities/tata') |
1a19f953f53c
also test GenericNoWildcardInDates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
120
diff
changeset
|
1509 DoPut(_REMOTE, '/modalities/tata', [ "STORESCP", "localhost", 2000, 'GenericNoWildcardInDates' ]) |
128 | 1510 modalitiesReadback = DoGet(_REMOTE, '/modalities?expand') |
182
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1511 self.assertEqual('STORESCP', modalitiesReadback['tata']['AET']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1512 self.assertEqual('localhost', modalitiesReadback['tata']['Host']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1513 self.assertEqual(2000, modalitiesReadback['tata']['Port']) |
7a6b532853ab
modalities are now described as JSON objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
1514 self.assertEqual('GenericNoWildcardInDates', modalitiesReadback['tata']['Manufacturer']) |
116 | 1515 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/modalities/toto', [ "STORESCP", "localhost", 2000, 'InvalidManufacturerName' ])) |
13 | 1516 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/toto')) |
1517 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/tata')) | |
351
429cc9d03610
test access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
350
diff
changeset
|
1518 |
429cc9d03610
test access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
350
diff
changeset
|
1519 # New in Orthanc 1.8.1 |
429cc9d03610
test access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
350
diff
changeset
|
1520 self.assertTrue('configuration' in DoGet(_REMOTE, '/modalities/tata')) |
429cc9d03610
test access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
350
diff
changeset
|
1521 self.assertEqual(modalitiesReadback['tata'], DoGet(_REMOTE, '/modalities/tata/configuration')) |
429cc9d03610
test access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
350
diff
changeset
|
1522 |
13 | 1523 DoDelete(_REMOTE, '/modalities/toto') |
1524 DoDelete(_REMOTE, '/modalities/tata') | |
1525 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/toto')) | |
1526 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/tata')) | |
1527 | |
1528 | |
1529 def test_update_peers(self): | |
1530 # curl -X PUT http://localhost:8042/peers/toto -d '["http://localhost:8042/"]' -v | |
1531 try: | |
1532 DoDelete(_REMOTE, '/peers/toto') | |
1533 except: | |
1534 pass | |
1535 try: | |
1536 DoDelete(_REMOTE, '/peers/tata') | |
1537 except: | |
1538 pass | |
1539 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/toto')) | |
348
bed0ab3a1391
test deleting inexistent modality/peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
342
diff
changeset
|
1540 self.assertRaises(Exception, lambda: DoDelete(_REMOTE, '/peers/toto')) |
13 | 1541 DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/' ]) |
214 | 1542 DoPut(_REMOTE, '/peers/tata', { 'Url': 'http://localhost:8042/', |
1543 'Username': 'user', | |
1544 'Password' : 'pass', | |
1545 'RemoteSelf' : 'self' }) | |
128 | 1546 self.assertTrue('tata' in DoGet(_REMOTE, '/peers')) |
1547 peersReadback = DoGet(_REMOTE, '/peers?expand') | |
1548 self.assertEqual('http://localhost:8042/', peersReadback['tata']['Url']) | |
1549 self.assertEqual('user', peersReadback['tata']['Username']) | |
214 | 1550 |
1551 if IsOrthancVersionAbove(_REMOTE, 1, 5, 4): | |
1552 self.assertEqual(None, peersReadback['tata']['Password']) # make sure no sensitive data is included | |
1553 self.assertFalse(peersReadback['tata']['Pkcs11']) # make sure no sensitive data is included | |
1554 self.assertEqual('self', peersReadback['tata']['RemoteSelf']) | |
1555 else: | |
1556 self.assertFalse('Password' in peersReadback['tata']) # make sure no sensitive data is included | |
1557 self.assertFalse('Pkcs11' in peersReadback['tata']) # make sure no sensitive data is included | |
1558 self.assertFalse('RemoteSelf' in peersReadback['tata']) | |
1559 | |
128 | 1560 self.assertFalse('CertificateFile' in peersReadback['tata']) # make sure no sensitive data is included |
1561 self.assertFalse('CertificateKeyFile' in peersReadback['tata']) # make sure no sensitive data is included | |
1562 self.assertFalse('CertificateKeyPassword' in peersReadback['tata']) # make sure no sensitive data is included | |
214 | 1563 |
13 | 1564 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/', 'a' ])) |
1565 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/peers/toto', [ 'http://localhost:8042/', 'a', 'b', 'c' ])) | |
1566 self.assertTrue('store' in DoGet(_REMOTE, '/peers/toto')) | |
1567 self.assertTrue('store' in DoGet(_REMOTE, '/peers/tata')) | |
351
429cc9d03610
test access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
350
diff
changeset
|
1568 |
429cc9d03610
test access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
350
diff
changeset
|
1569 # New in Orthanc 1.8.1 |
429cc9d03610
test access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
350
diff
changeset
|
1570 self.assertTrue('configuration' in DoGet(_REMOTE, '/peers/tata')) |
429cc9d03610
test access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
350
diff
changeset
|
1571 self.assertEqual(peersReadback['tata'], DoGet(_REMOTE, '/peers/tata/configuration')) |
429cc9d03610
test access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
350
diff
changeset
|
1572 |
13 | 1573 DoDelete(_REMOTE, '/peers/toto') |
1574 DoDelete(_REMOTE, '/peers/tata') | |
1575 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/toto')) | |
1576 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/peers/tata')) | |
1577 | |
1578 | |
1579 def test_mesterhazy_modification(self): | |
1580 # When I modify a series ( eg. curl | |
1581 # http://localhost:8042/series/uidhere/modify -X POST -d | |
1582 # '{"Replace":{"SeriesDate":"19990101"}}' ) the modified | |
1583 # series is added to a new Study, instead of the existing | |
1584 # Study. Fixed in Orthanc 0.7.5 | |
1585 | |
1586 u = UploadInstance(_REMOTE, 'DummyCT.dcm') | |
1587 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' | |
1588 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
1589 | |
1590 modified = DoPost(_REMOTE, '/series/%s/modify' % series, | |
1591 json.dumps({ "Replace" : { "SeriesDate" : "19990101" }})) | |
1592 | |
1593 self.assertEqual(study, DoGet(_REMOTE, '/series/%s' % modified['ID']) ['ParentStudy']) | |
1594 | |
1595 | |
1596 def test_create(self): | |
1597 i = DoPost(_REMOTE, '/tools/create-dicom', | |
1598 json.dumps({ | |
1599 'PatientName' : 'Jodogne', | |
1600 'Modality' : 'CT', | |
58 | 1601 'SOPClassUID' : '1.2.840.10008.5.1.4.1.1.1', |
13 | 1602 'PixelData' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==' # red dot in RGBA |
1603 })) | |
1604 | |
1605 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
1606 self.assertEqual('CT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i['ID']).strip()) | |
1607 | |
1608 png = GetImage(_REMOTE, '/instances/%s/preview' % i['ID']) | |
1609 self.assertEqual((5, 5), png.size) | |
1610 | |
38 | 1611 j = DoGet(_REMOTE, i['Path']) |
1612 self.assertEqual('Instance', j['Type']) | |
1613 self.assertEqual(j['ID'], i['ID']) | |
1614 | |
13 | 1615 |
1616 def test_pilates(self): | |
1617 # "SCU failed error when accessing orthanc with osirix" by | |
1618 # Pilates Agentur (Mar 10, 2014 at 9:33 PM) | |
1619 i = UploadInstance(_REMOTE, 'PilatesArgenturGEUltrasoundOsiriX.dcm')['ID'] | |
1620 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) | |
1621 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
1622 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) | |
1623 | |
1624 | |
1625 def test_shared_tags(self): | |
1626 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1627 b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm')['ID'] | |
1628 p = DoGet(_REMOTE, '/patients')[0] | |
1629 | |
1630 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1631 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
|
1632 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
|
1633 |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
1634 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
|
1635 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
|
1636 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
|
1637 |
13 | 1638 self.assertTrue('0008,1030' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) |
1639 self.assertTrue('StudyDescription' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1640 self.assertTrue('0008,103e' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1641 self.assertTrue('SeriesDescription' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1642 self.assertFalse('0008,0018' in DoGet(_REMOTE, '/patients/%s/shared-tags' % p)) | |
1643 self.assertFalse('SOPInstanceUID' in DoGet(_REMOTE, '/patients/%s/shared-tags?simplify' % p)) | |
1644 | |
1645 self.assertTrue('0008,0018' in DoGet(_REMOTE, '/instances/%s/tags' % a)) | |
1646 self.assertTrue('SOPInstanceUID' in DoGet(_REMOTE, '/instances/%s/tags?simplify' % a)) | |
1647 | |
1648 | |
1649 def test_modules(self): | |
1650 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1651 p = DoGet(_REMOTE, '/patients')[0] | |
1652 s = DoGet(_REMOTE, '/studies')[0] | |
1653 t = DoGet(_REMOTE, '/series')[0] | |
1654 | |
1655 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/patients/%s/module' % p)) | |
1656 self.assertTrue('PatientName' in DoGet(_REMOTE, '/patients/%s/module?simplify' % p)) | |
1657 self.assertTrue('0010,0010' in DoGet(_REMOTE, '/studies/%s/module-patient' % p)) | |
1658 self.assertTrue('PatientName' in DoGet(_REMOTE, '/studies/%s/module-patient?simplify' % p)) | |
1659 self.assertTrue('0008,1030' in DoGet(_REMOTE, '/studies/%s/module' % s)) | |
1660 self.assertTrue('StudyDescription' in DoGet(_REMOTE, '/studies/%s/module?simplify' % s)) | |
1661 self.assertTrue('0008,103e' in DoGet(_REMOTE, '/series/%s/module' % p)) | |
1662 self.assertTrue('SeriesDescription' in DoGet(_REMOTE, '/series/%s/module?simplify' % p)) | |
1663 self.assertTrue('0008,0018' in DoGet(_REMOTE, '/instances/%s/module' % a)) | |
1664 self.assertTrue('SOPInstanceUID' in DoGet(_REMOTE, '/instances/%s/module?simplify' % a)) | |
1665 | |
1666 | |
1667 def test_auto_directory(self): | |
1668 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
1669 self.assertTrue('now' in DoGet(_REMOTE, '/tools')) | |
1670 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
|
1671 self.assertTrue('invalidate-tags' in DoGet(_REMOTE, '/tools')) |
13 | 1672 self.assertTrue(len(DoGet(_REMOTE, '/tools/dicom-conformance')) > 1000) |
1673 self.assertTrue('orthanctest' in DoGet(_REMOTE, '/modalities')) | |
1674 self.assertTrue('echo' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1675 self.assertTrue('find' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1676 self.assertTrue('find-instance' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1677 self.assertTrue('find-patient' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1678 self.assertTrue('find-series' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1679 self.assertTrue('find-study' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1680 self.assertTrue('store' in DoGet(_REMOTE, '/modalities/orthanctest')) | |
1681 self.assertTrue('store' in DoGet(_REMOTE, '/peers/peer')) | |
1682 self.assertTrue('matlab' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) | |
79 | 1683 self.assertTrue('raw' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) |
13 | 1684 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/tools/nope')) |
28 | 1685 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope')) |
1686 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope/nope.html')) | |
1687 self.assertEqual(404, DoGetRaw(_REMOTE, '/nope')[0].status) | |
1688 self.assertEqual(404, DoGetRaw(_REMOTE, '/nope/nope.html')[0].status) | |
13 | 1689 |
1690 | |
1691 def test_echo(self): | |
1692 DoPost(_REMOTE, '/modalities/orthanctest/echo') | |
359
8b476a383999
test empty body in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
357
diff
changeset
|
1693 DoPost(_REMOTE, '/modalities/orthanctest/echo', '{}') |
8b476a383999
test empty body in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
357
diff
changeset
|
1694 |
8b476a383999
test empty body in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
357
diff
changeset
|
1695 # The following was not working in Orthanc 1.7.0 -> 1.8.1 |
8b476a383999
test empty body in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
357
diff
changeset
|
1696 DoPost(_REMOTE, '/modalities/orthanctest/echo', '') |
352
3d406c0261fc
test /tools/dicom-echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
351
diff
changeset
|
1697 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/modalities/nope/echo')) |
3d406c0261fc
test /tools/dicom-echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
351
diff
changeset
|
1698 |
3d406c0261fc
test /tools/dicom-echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
351
diff
changeset
|
1699 # New in Orthanc 1.8.1 |
3d406c0261fc
test /tools/dicom-echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
351
diff
changeset
|
1700 DoPost(_REMOTE, '/tools/dicom-echo', [ |
355 | 1701 _REMOTE['DicomAet'], _REMOTE['Server'], _REMOTE['DicomPort'] ]) |
352
3d406c0261fc
test /tools/dicom-echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
351
diff
changeset
|
1702 DoPost(_REMOTE, '/tools/dicom-echo', DoGet(_REMOTE, '/modalities/orthanctest/configuration')) |
13 | 1703 |
353 | 1704 # Use the 'CheckFind' new option in Orthanc 1.8.1 |
1705 DoPost(_REMOTE, '/modalities/self/echo', { 'CheckFind' : True }) | |
1706 DoPost(_REMOTE, '/tools/dicom-echo', { | |
1707 'AET' : _REMOTE['DicomAet'], | |
1708 'Host' : _REMOTE['Server'], | |
1709 'Port' : _REMOTE['DicomPort'], | |
1710 'CheckFind' : True | |
1711 }) | |
1712 | |
13 | 1713 |
1714 def test_xml(self): | |
1715 json = DoGet(_REMOTE, '/tools', headers = { 'accept' : 'application/json' }) | |
1716 xml = minidom.parseString(DoGet(_REMOTE, '/tools', headers = { 'accept' : 'application/xml' })) | |
1717 items = xml.getElementsByTagName('root')[0].getElementsByTagName('item') | |
1718 self.assertEqual(len(items), len(json)) | |
1719 | |
1720 self.assertTrue('dicom-conformance' in json) | |
1721 | |
1722 ok = False | |
1723 for i in items: | |
1724 if i.childNodes[0].data == 'dicom-conformance': | |
1725 ok = True | |
1726 self.assertTrue(ok) | |
1727 | |
1728 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1729 def test_googlecode_issue_16(self): |
13 | 1730 i = UploadInstance(_REMOTE, 'Issue16.dcm')['ID'] |
1731 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i)['FrameIncrementPointer'] | |
1732 self.assertEqual('0018,1063', t) | |
1733 | |
1734 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1735 def test_googlecode_issue_22(self): |
13 | 1736 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] |
1737 a = [ | |
1738 "f804691f62197040438f4627c6b994f1", # Frame 0 | |
1739 "c69eee9a51eea3e8611e82e578897254", | |
1740 "315666be83e2d0111c77bc0996d84901", | |
1741 "3e27aa959d911172c48a1436443c72b1", | |
1742 "958642c9e7e9d232d3869faff546058c", | |
1743 "5e7ea8e3e4230cae707d143481355c59", | |
1744 "eda37f83558d858a596175aed8b2ad47", | |
1745 "486713bd2895c4ecbe0e97715ac7f80a", | |
1746 "091ef729eb169e67da8a0faa9631f9a8", | |
1747 "5aa2b8c7ffe0a483efaa8e12417686ca", | |
1748 "e2f39e85896fe58876654b94cd0b5013", | |
1749 "6fd2129e4950abbe1be053bc814d5da8", | |
1750 "c3331a8ba7a757f3d423735ab7fa81f9", | |
1751 "746f808582156734dd6b6fdfd3a0b72c", | |
1752 "8075ea2b227a70c60ea6b7b75a6bb190", | |
1753 "806b8b3e300c615099c11a5ec23465aa", | |
1754 "7c836aa298ba6eef96434579af631a11", | |
1755 "a0357dc9f4f72d73a885c33d7c287446", | |
1756 "f25ba3be1cc7d7fad95706adc199ea7d", | |
1757 "8b114c526b8cbed6cad8a3248b7b480c", | |
1758 "44e6670f127e612a2b4aa60a0d207698", | |
1759 "b8945f90fe02facf2ace24ca1ecbe0a5", | |
1760 "95c796c2fa8f59018b15cf2987b1f79b", | |
1761 "ce0a51ab30224205b44920221dc27351", # Frame 23 | |
1762 ] | |
1763 | |
1764 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
1765 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/24/preview' % s)) | |
1766 | |
1767 for i in range(len(a)): | |
1768 self.assertEqual(a[i], ComputeMD5(DoGet(_REMOTE, '/instances/%s/frames/%d/preview' % (s, i)))) | |
1769 | |
1770 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1771 def test_googlecode_issue_19(self): |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
1772 # This is an image with "YBR_FULL" photometric interpretation, it is not supported by Orthanc |
13 | 1773 # gdcmconv -i /home/jodogne/DICOM/GdcmDatabase/US_DataSet/HDI5000_US/3EAF5E01 -w -o Issue19.dcm |
1774 | |
1775 a = UploadInstance(_REMOTE, 'Issue19.dcm')['ID'] | |
304 | 1776 if not HasGdcmPlugin(_REMOTE): |
299
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
1777 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/941ad3c8-05d05b88-560459f9-0eae0e20-6cddd533/preview')) |
13 | 1778 |
1779 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
1780 def test_googlecode_issue_37(self): |
13 | 1781 # Same test for issues 35 and 37. Fixed in Orthanc 0.9.1 |
1782 u = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] | |
1783 | |
1784 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
1785 'CaseSensitive' : True, | |
1786 'Query' : { 'StationName' : 'SMR4-MP3' }}) | |
1787 self.assertEqual(1, len(a)) | |
14 | 1788 |
1789 | |
1790 def test_rest_find(self): | |
1791 # Upload 8 instances | |
1792 for i in range(2): | |
1793 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1794 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1795 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1796 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1797 | |
1798 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1799 'CaseSensitive' : False, | |
194
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1800 'Query' : { 'PatientName' : 'BRAINIX' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1801 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1802 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1803 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1804 'CaseSensitive' : False, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1805 'Query' : { 'PatientName' : 'BRAINIX\\KNEE\\NOPE' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1806 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1807 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1808 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1809 'CaseSensitive' : False, |
14 | 1810 'Query' : { 'PatientName' : '*n*' }}) |
1811 self.assertEqual(2, len(a)) | |
1812 | |
1813 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1814 'CaseSensitive' : True, | |
1815 'Query' : { 'PatientName' : '*n*' }}) | |
1816 self.assertEqual(0, len(a)) | |
1817 | |
1818 a = DoPost(_REMOTE, '/tools/find', { 'Expand' : True, | |
1819 'Level' : 'Patient', | |
1820 'CaseSensitive' : False, | |
1821 'Query' : { 'PatientName' : '*ne*' }}) | |
1822 self.assertEqual(1, len(a)) | |
1823 self.assertEqual('20080822', a[0]['MainDicomTags']['PatientBirthDate']) | |
1824 | |
1825 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', | |
1826 'CaseSensitive' : True, | |
1827 'Query' : { 'PatientName' : '*ne*' }}) | |
1828 self.assertEqual(0, len(a)) | |
1829 | |
1830 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', | |
1831 'CaseSensitive' : True, | |
1832 'Query' : { 'PatientName' : '*NE*' }}) | |
1833 self.assertEqual(1, len(a)) | |
1834 | |
1835 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', | |
1836 'CaseSensitive' : True, | |
1837 'Query' : { 'PatientName' : '*NE*' }}) | |
1838 self.assertEqual(2, len(a)) | |
1839 | |
1840 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', | |
1841 'CaseSensitive' : True, | |
1842 'Query' : { 'PatientName' : '*NE*' }}) | |
1843 self.assertEqual(4, len(a)) | |
1844 | |
1845 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', 'Query' : { }}) | |
1846 self.assertEqual(2, len(a)) | |
1847 | |
1848 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', 'Query' : { }}) | |
1849 self.assertEqual(2, len(a)) | |
1850 | |
1851 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', 'Query' : { }}) | |
1852 self.assertEqual(4, len(a)) | |
1853 | |
1854 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', 'Query' : { }}) | |
1855 self.assertEqual(8, len(a)) | |
1856 | |
194
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1857 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1858 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1859 'Query' : { 'StudyDate' : '20061201-20061201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1860 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1861 self.assertEqual('BRAINIX', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1862 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1863 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1864 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1865 'Query' : { 'StudyDate' : '20061201-20091201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1866 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1867 for i in range(2): |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1868 self.assertTrue(a[i]['PatientMainDicomTags']['PatientName'] in ['BRAINIX', 'KNEE']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1869 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1870 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1871 'Query' : { 'StudyDate' : '20061202-20061202' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1872 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1873 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1874 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1875 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1876 'Query' : { 'StudyDate' : '-20061201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1877 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1878 self.assertEqual('BRAINIX', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1879 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1880 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1881 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1882 'Query' : { 'StudyDate' : '-20051201' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1883 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1884 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1885 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1886 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1887 'Query' : { 'StudyDate' : '20061201-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1888 self.assertEqual(2, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1889 for i in range(2): |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1890 self.assertTrue(a[i]['PatientMainDicomTags']['PatientName'] in ['BRAINIX', 'KNEE']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1891 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1892 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1893 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1894 'Query' : { 'StudyDate' : '20061202-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1895 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1896 self.assertEqual('KNEE', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1897 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1898 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1899 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1900 'Query' : { 'StudyDate' : '20080819-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1901 self.assertEqual(1, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1902 self.assertEqual('KNEE', a[0]['PatientMainDicomTags']['PatientName']) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1903 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1904 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1905 'Expand' : True, |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1906 'Query' : { 'StudyDate' : '20080820-' }}) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1907 self.assertEqual(0, len(a)) |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1908 |
9f7ae64c0fda
more tests about find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
1909 |
14 | 1910 |
1911 def test_rest_query_retrieve(self): | |
1912 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1913 | |
1914 # Upload 8 instances | |
1915 for i in range(2): | |
1916 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-000%d.dcm' % (i + 1)) | |
1917 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-000%d.dcm' % (i + 1)) | |
1918 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-000%d.dcm' % (i + 1)) | |
1919 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-000%d.dcm' % (i + 1)) | |
1920 | |
1921 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
1922 for p in DoGet(_REMOTE, '/patients'): | |
1923 DoPost(_REMOTE, '/modalities/orthanctest/store', p) | |
1924 DoDelete(_REMOTE, '/patients/%s' % p) | |
1925 | |
1926 for q in DoGet(_REMOTE, '/queries'): | |
1927 DoDelete(_REMOTE, '/queries/%s' % q) | |
1928 | |
1929 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1930 self.assertEqual(0, len(DoGet(_REMOTE, '/queries'))) | |
1931 a = DoPost(_REMOTE, '/modalities/orthanctest/query', { 'Level' : 'Series', | |
27 | 1932 'Query' : { |
1933 'PatientName' : '*NE*', | |
1934 'StudyDate' : '*', | |
1935 }})['ID'] | |
14 | 1936 self.assertEqual(1, len(DoGet(_REMOTE, '/queries'))) |
1937 | |
1938 b = DoGet(_REMOTE, '/queries/%s' % a) | |
1939 self.assertTrue('answers' in b) | |
1940 self.assertTrue('level' in b) | |
1941 self.assertTrue('modality' in b) | |
1942 self.assertTrue('query' in b) | |
1943 self.assertTrue('retrieve' in b) | |
1944 self.assertEqual('Series', DoGet(_REMOTE, '/queries/%s/level' % a)) | |
1945 self.assertEqual('orthanctest', DoGet(_REMOTE, '/queries/%s/modality' % a)) | |
1946 | |
1947 q = DoGet(_REMOTE, '/queries/%s/query?simplify' % a) | |
27 | 1948 self.assertEqual(2, len(q)) |
14 | 1949 self.assertTrue('PatientName' in q) |
27 | 1950 self.assertTrue('StudyDate' in q) |
14 | 1951 self.assertEqual('*NE*', q['PatientName']) |
27 | 1952 self.assertEqual('*', q['StudyDate']) |
14 | 1953 |
1954 self.assertEqual(2, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) | |
1955 | |
1956 s = DoGet(_REMOTE, '/queries/%s/answers/0' % a) | |
1957 self.assertTrue('content' in s) | |
1958 self.assertTrue('retrieve' in s) | |
1959 | |
1960 s = DoGet(_REMOTE, '/queries/%s/answers/0/content?simplify' % a) | |
1961 self.assertEqual('887', s['PatientID']) | |
1962 self.assertEqual('2.16.840.1.113669.632.20.121711.10000160881', s['StudyInstanceUID']) | |
1963 | |
1964 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
1965 DoPost(_REMOTE, '/queries/%s/answers/0/retrieve' % a, 'ORTHANC') | |
1966 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
1967 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
1968 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
1969 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) | |
1970 | |
112 | 1971 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 | 1972 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) |
1973 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
1974 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
1975 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
1976 | |
186
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1977 # 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
|
1978 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
|
1979 self.assertEqual(2, len(s)) |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1980 for i in range(2): |
8feebc2bf9fc
test options expand and limit to /queries/.../answers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
1981 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
|
1982 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
|
1983 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
|
1984 |
14 | 1985 DoDelete(_REMOTE, '/queries/%s' % a) |
1986 self.assertEqual(0, len(DoGet(_REMOTE, '/queries'))) | |
1987 | |
1988 | |
1989 def test_parent(self): | |
1990 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
1991 patient = '6816cb19-844d5aee-85245eba-28e841e6-2414fae2' | |
1992 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' | |
1993 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
1994 instance = '66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d' | |
107
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
1995 self.assertEqual(instance, u) |
14 | 1996 |
1997 a = DoGet(_REMOTE, '/studies/%s/patient' % study) | |
1998 self.assertEqual('Patient', a['Type']) | |
1999 self.assertEqual(patient, a['ID']) | |
2000 | |
2001 a = DoGet(_REMOTE, '/series/%s/patient' % series) | |
2002 self.assertEqual('Patient', a['Type']) | |
2003 self.assertEqual(patient, a['ID']) | |
2004 | |
2005 a = DoGet(_REMOTE, '/series/%s/study' % series) | |
2006 self.assertEqual('Study', a['Type']) | |
2007 self.assertEqual(study, a['ID']) | |
2008 | |
2009 a = DoGet(_REMOTE, '/instances/%s/patient' % instance) | |
2010 self.assertEqual('Patient', a['Type']) | |
2011 self.assertEqual(patient, a['ID']) | |
2012 | |
2013 a = DoGet(_REMOTE, '/instances/%s/study' % instance) | |
2014 self.assertEqual('Study', a['Type']) | |
2015 self.assertEqual(study, a['ID']) | |
2016 | |
2017 a = DoGet(_REMOTE, '/instances/%s/series' % instance) | |
2018 self.assertEqual('Series', a['Type']) | |
2019 self.assertEqual(series, a['ID']) | |
2020 | |
2021 | |
2022 def test_shanon(self): | |
2023 def Anonymize(instance, replacements = {}): | |
119 | 2024 return DoPost(_REMOTE, '/instances/%s/anonymize' % instance, { |
2025 'Replace' : replacements, | |
2026 'Force' : True, | |
2027 }, 'application/json') | |
14 | 2028 |
2029 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
2030 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
2031 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
2032 | |
2033 tags = [ 'PatientID', 'StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID', 'DeidentificationMethod' ] | |
2034 ids = [ 'ozp00SjY2xG', | |
2035 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
2036 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
2037 '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' ] | |
2038 | |
2039 a = ExtractDicomTags(Anonymize(u), tags) | |
2040 for i in range(4): | |
2041 self.assertNotEqual(ids[i], a[i]) | |
2042 self.assertTrue(a[4].startswith('Orthanc')) | |
2043 | |
2044 a = ExtractDicomTags(Anonymize(u, { 'PatientName' : 'toto' }), tags) | |
2045 for i in range(4): | |
2046 self.assertNotEqual(ids[i], a[i]) | |
2047 self.assertFalse(a[4].startswith('Orthanc')) | |
2048 | |
2049 a = ExtractDicomTags(Anonymize(u, { 'SOPInstanceUID' : 'instance' }), tags) | |
2050 self.assertEqual('instance', a[3]) | |
2051 self.assertFalse(a[4].startswith('Orthanc')) | |
2052 | |
2053 a = ExtractDicomTags(Anonymize(u, { 'SeriesInstanceUID' : 'series' }), tags) | |
2054 self.assertEqual('series', a[2]) | |
2055 self.assertFalse(a[4].startswith('Orthanc')) | |
2056 | |
2057 a = ExtractDicomTags(Anonymize(u, { 'StudyInstanceUID' : 'study' }), tags) | |
2058 self.assertEqual('study', a[1]) | |
2059 self.assertFalse(a[4].startswith('Orthanc')) | |
2060 | |
2061 a = ExtractDicomTags(Anonymize(u, { 'PatientID' : 'patient' }), tags) | |
2062 self.assertEqual('patient', a[0]) | |
2063 self.assertFalse(a[4].startswith('Orthanc')) | |
2064 | |
2065 a = ExtractDicomTags(Anonymize(u, { 'PatientID' : 'patient', | |
2066 'StudyInstanceUID' : 'study', | |
2067 'SeriesInstanceUID' : 'series', | |
2068 'SOPInstanceUID' : 'instance' }), tags) | |
2069 self.assertEqual('patient', a[0]) | |
2070 self.assertFalse(a[4].startswith('Orthanc')) | |
2071 | |
2072 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
2073 | |
2074 | |
2075 def test_shanon_2(self): | |
2076 def Modify(instance, replacements = {}): | |
119 | 2077 return DoPost(_REMOTE, '/instances/%s/modify' % instance, { |
2078 'Replace' : replacements, | |
2079 'Force': True, | |
2080 }, 'application/json') | |
14 | 2081 |
2082 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) | |
2083 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
2084 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
2085 | |
2086 tags = [ 'PatientID', 'StudyInstanceUID', 'SeriesInstanceUID', 'SOPInstanceUID', 'DeidentificationMethod' ] | |
2087 ids = [ 'ozp00SjY2xG', | |
2088 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390', | |
2089 '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394', | |
2090 '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' ] | |
2091 | |
2092 a = ExtractDicomTags(Modify(u), tags) | |
2093 self.assertEqual(ids[0], a[0]) | |
2094 self.assertEqual(ids[1], a[1]) | |
2095 self.assertEqual(ids[2], a[2]) | |
2096 self.assertNotEqual(ids[3], a[3]) | |
2097 self.assertEqual(0, len(a[4])) | |
2098 | |
2099 a = ExtractDicomTags(Modify(u, { 'SOPInstanceUID' : 'instance' }), tags) | |
2100 self.assertEqual(ids[0], a[0]) | |
2101 self.assertEqual(ids[1], a[1]) | |
2102 self.assertEqual(ids[2], a[2]) | |
2103 self.assertEqual('instance', a[3]) | |
2104 | |
2105 a = ExtractDicomTags(Modify(u, { 'SeriesInstanceUID' : 'series' }), tags) | |
2106 self.assertEqual(ids[0], a[0]) | |
2107 self.assertEqual(ids[1], a[1]) | |
2108 self.assertEqual('series', a[2]) | |
2109 self.assertNotEqual(ids[3], a[3]) | |
2110 | |
2111 a = ExtractDicomTags(Modify(u, { 'StudyInstanceUID' : 'study' }), tags) | |
2112 self.assertEqual(ids[0], a[0]) | |
2113 self.assertEqual('study', a[1]) | |
2114 self.assertNotEqual(ids[2], a[2]) | |
2115 self.assertNotEqual(ids[3], a[3]) | |
2116 | |
2117 a = ExtractDicomTags(Modify(u, { 'PatientID' : 'patient' }), tags) | |
2118 self.assertEqual('patient', a[0]) | |
2119 self.assertNotEqual(ids[1], a[1]) | |
2120 self.assertNotEqual(ids[2], a[2]) | |
2121 self.assertNotEqual(ids[3], a[3]) | |
2122 | |
2123 a = ExtractDicomTags(Modify(u, { 'PatientID' : 'patient', | |
2124 'StudyInstanceUID' : 'study', | |
2125 'SeriesInstanceUID' : 'series', | |
2126 'SOPInstanceUID' : 'instance' }), tags) | |
2127 self.assertEqual('patient', a[0]) | |
2128 self.assertEqual('study', a[1]) | |
2129 self.assertEqual('series', a[2]) | |
2130 self.assertEqual('instance', a[3]) | |
2131 | |
2132 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
2133 | |
2134 | |
2135 def test_instances_tags(self): | |
2136 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] | |
2137 b = UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm')['ID'] | |
2138 #a = UploadInstance(_REMOTE, 'Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386937.676343')['ID'] | |
2139 #b = UploadInstance(_REMOTE, 'Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386925.676329')['ID'] | |
2140 | |
2141 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/patients')[0]) | |
2142 self.assertEqual(2, len(i)) | |
2143 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
2144 self.assertEqual('887', i[i.keys()[1]]['PatientID']) | |
2145 | |
2146 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/studies')[0]) | |
2147 self.assertEqual(2, len(i)) | |
2148 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
2149 self.assertEqual('887', i[i.keys()[1]]['PatientID']) | |
2150 | |
2151 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
2152 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/series')[0]) | |
2153 self.assertEqual(1, len(i)) | |
2154 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
2155 | |
2156 i = DoGet(_REMOTE, '/patients/%s/instances-tags?simplify' % DoGet(_REMOTE, '/series')[1]) | |
2157 self.assertEqual(1, len(i)) | |
2158 self.assertEqual('887', i[i.keys()[0]]['PatientID']) | |
2159 | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2160 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
|
2161 self.assertEqual(1, len(i)) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2162 self.assertEqual('887', i[i.keys()[0]]['0010,0020']) |
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2163 |
14 | 2164 |
2165 def test_lookup(self): | |
2166 a = DoPost(_REMOTE, '/tools/lookup', 'ozp00SjY2xG') | |
2167 self.assertEqual(0, len(a)) | |
2168 | |
2169 UploadInstance(_REMOTE, 'DummyCT.dcm') | |
2170 | |
2171 a = DoPost(_REMOTE, '/tools/lookup', 'ozp00SjY2xG') | |
2172 self.assertEqual(1, len(a)) | |
2173 self.assertEqual('Patient', a[0]['Type']) | |
2174 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', a[0]['ID']) | |
2175 self.assertEqual('/patients/%s' % a[0]['ID'], a[0]['Path']) | |
2176 | |
2177 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390') | |
2178 self.assertEqual(1, len(a)) | |
2179 self.assertEqual('Study', a[0]['Type']) | |
2180 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', a[0]['ID']) | |
2181 self.assertEqual('/studies/%s' % a[0]['ID'], a[0]['Path']) | |
2182 | |
2183 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394') | |
2184 self.assertEqual(1, len(a)) | |
2185 self.assertEqual('Series', a[0]['Type']) | |
2186 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', a[0]['ID']) | |
2187 self.assertEqual('/series/%s' % a[0]['ID'], a[0]['Path']) | |
2188 | |
2189 a = DoPost(_REMOTE, '/tools/lookup', '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109') | |
2190 self.assertEqual(1, len(a)) | |
2191 self.assertEqual('Instance', a[0]['Type']) | |
2192 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', a[0]['ID']) | |
2193 self.assertEqual('/instances/%s' % a[0]['ID'], a[0]['Path']) | |
2194 | |
2195 DropOrthanc(_REMOTE) | |
2196 a = DoPost(_REMOTE, '/tools/lookup', '3113719P') | |
2197 self.assertEqual(0, len(a)) | |
2198 | |
15 | 2199 |
2200 def test_autorouting(self): | |
2201 knee1 = 'Knee/T1/IM-0001-0001.dcm' | |
2202 knee2 = 'Knee/T2/IM-0001-0002.dcm' | |
2203 other = 'Brainix/Flair/IM-0001-0001.dcm' | |
2204 | |
2205 # Check that this version is >= 0.8.0 | |
2206 self.assertTrue(IsDefinedInLua(_REMOTE, '_InitializeJob')) | |
2207 self.assertTrue('orthanctest' in DoGet(_REMOTE, '/modalities')) | |
2208 | |
2209 UploadInstance(_REMOTE, knee1) | |
2210 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
2211 | |
2212 DropOrthanc(_REMOTE) | |
2213 DropOrthanc(_LOCAL) | |
174 | 2214 InstallLuaScriptFromPath(_REMOTE, 'Lua/Autorouting.lua') |
15 | 2215 UploadInstance(_REMOTE, knee1) |
2216 UploadInstance(_REMOTE, knee2) | |
2217 UploadInstance(_REMOTE, other) | |
2218 WaitEmpty(_REMOTE) | |
174 | 2219 UninstallLuaCallbacks(_REMOTE) |
15 | 2220 self.assertEqual(3, len(DoGet(_LOCAL, '/instances'))) |
2221 | |
2222 DropOrthanc(_REMOTE) | |
2223 DropOrthanc(_LOCAL) | |
174 | 2224 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingConditional.lua') |
15 | 2225 UploadInstance(_REMOTE, knee1) |
2226 UploadInstance(_REMOTE, knee2) | |
2227 UploadInstance(_REMOTE, other) | |
2228 WaitEmpty(_REMOTE) | |
174 | 2229 UninstallLuaCallbacks(_REMOTE) |
15 | 2230 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
2231 | |
2232 DropOrthanc(_REMOTE) | |
2233 DropOrthanc(_LOCAL) | |
174 | 2234 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingModification.lua') |
15 | 2235 UploadInstance(_REMOTE, knee1) |
2236 WaitEmpty(_REMOTE) | |
174 | 2237 UninstallLuaCallbacks(_REMOTE) |
15 | 2238 i = DoGet(_LOCAL, '/instances') |
2239 self.assertEqual(1, len(i)) | |
2240 | |
2241 with tempfile.NamedTemporaryFile(delete = True) as f: | |
2242 f.write(DoGet(_LOCAL, '/instances/%s/file' % i[0])) | |
2243 f.flush() | |
45 | 2244 routed = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) |
15 | 2245 self.assertEqual('My Medical Device', re.search('"StationName">(.*?)<', routed).group(1).strip()) |
2246 self.assertEqual(None, re.search('"MilitaryRank"', routed)) | |
2247 self.assertEqual(None, re.search('"0051,0010"', routed)) # A private tag | |
17 | 2248 |
2249 | |
2250 def test_storescu_rf(self): | |
2251 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] | |
2252 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
2253 j = DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') | |
2254 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
18 | 2255 |
2256 | |
2257 def test_anonymize_instance(self): | |
2258 def AnonymizeAndUpload(instanceId, parameters): | |
2259 return DoPost(_REMOTE, '/instances', DoPost(_REMOTE, '/instances/%s/anonymize' % instanceId, parameters, | |
2260 'application/json'), 'application/dicom')['ID'] | |
2261 | |
2262 def ModifyAndUpload(instanceId, parameters): | |
2263 return DoPost(_REMOTE, '/instances', DoPost(_REMOTE, '/instances/%s/modify' % instanceId, parameters, | |
2264 'application/json'), 'application/dicom')['ID'] | |
2265 | |
2266 a = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] | |
2267 s1 = DoGet(_REMOTE, '/instances/%s/content/PatientName' % a) | |
2268 s2 = DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % a) # Some private tag | |
2269 s3 = DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % a) | |
2270 s4 = DoGet(_REMOTE, '/instances/%s/content/SeriesDescription' % a) | |
2271 s5 = DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % a) | |
2272 | |
2273 b = AnonymizeAndUpload(a, '{}') | |
2274 self.assertNotEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2275 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2276 | |
2277 # Keep private tag (only OK since Orthanc 0.8.0) | |
2278 b = AnonymizeAndUpload(a, '{"Keep":["00e1-10c2"]}') | |
2279 self.assertNotEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2280 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2281 | |
2282 b = AnonymizeAndUpload(a, '{"Keep":["00e1,10c2","PatientName"]}') | |
2283 self.assertEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2284 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2285 | |
2286 b = AnonymizeAndUpload(a, '{"Keep":["PatientName"],"Replace":{"00e1,10c2":"Hello"}}') | |
2287 self.assertEqual(s1, DoGet(_REMOTE, '/instances/%s/content/PatientName' % b)) | |
2288 self.assertTrue(DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b).startswith('Hello')) | |
2289 | |
2290 # Examples from the Wiki | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2291 b = AnonymizeAndUpload(a, '{"Replace":{"PatientName":"hello","0010-0020":"world"},"Keep":["StudyDescription", "SeriesDescription"],"KeepPrivateTags": true,"Force":true}') |
18 | 2292 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2293 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2294 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2295 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008,103e' % b)) | |
2296 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008-103E' % b)) | |
2297 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2298 DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % a) | |
2299 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2300 | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2301 b = ModifyAndUpload(a, '{"Replace":{"PatientName":"hello","PatientID":"world"},"Remove":["InstitutionName"],"RemovePrivateTags": true,"Force":true}') |
18 | 2302 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2303 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2304 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2305 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008,103e' % b)) | |
2306 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/00e1-10c2' % b)) | |
2307 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2308 | |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
2309 b = ModifyAndUpload(a, '{"Replace":{"PatientName":"hello","PatientID":"world"},"Force":true}') |
18 | 2310 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/0010-0010' % b).strip()) |
2311 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/PatientID' % b).strip()) | |
2312 self.assertEqual(s2, DoGet(_REMOTE, '/instances/%s/content/00e1,10c2' % b)) | |
2313 self.assertEqual(s3, DoGet(_REMOTE, '/instances/%s/content/0008,1030' % b)) | |
2314 self.assertEqual(s4, DoGet(_REMOTE, '/instances/%s/content/0008-103E' % b)) | |
2315 self.assertEqual(s5, DoGet(_REMOTE, '/instances/%s/content/InstitutionName' % b)) | |
2316 | |
2317 | |
2318 # Test modify non-existing | |
2319 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2320 json.dumps({ | |
2321 'PatientName' : 'Jodogne', | |
2322 'Modality' : 'CT', | |
2323 }))['ID'] | |
2324 | |
2325 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i).strip()) | |
2326 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % i)) | |
2327 self.assertEqual('CT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i).strip()) | |
2328 | |
2329 b = ModifyAndUpload(i, '{"Replace":{"StudyDescription":"hello","Modality":"world"}}') | |
2330 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % b).strip()) | |
2331 self.assertEqual('hello', DoGet(_REMOTE, '/instances/%s/content/StudyDescription' % b).strip()) | |
2332 self.assertEqual('world', DoGet(_REMOTE, '/instances/%s/content/Modality' % b).strip()) | |
2333 | |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2334 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2335 def test_incoming_jpeg(self): |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2336 def storescu(image, acceptUnknownSopClassUid): |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2337 if acceptUnknownSopClassUid: |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2338 tmp = [ '-xf', GetDatabasePath('UnknownSopClassUid.cfg'), 'Default' ] |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2339 else: |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2340 tmp = [ '-xs' ] |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2341 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2342 with open(os.devnull, 'w') as FNULL: |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2343 subprocess.check_call([ FindExecutable('storescu') ] + tmp + |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2344 [ _REMOTE['Server'], str(_REMOTE['DicomPort']), |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2345 GetDatabasePath(image) ], |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2346 stderr = FNULL) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2347 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2348 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
373
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2349 |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2350 if IsOrthancVersionAbove(_REMOTE, 1, 9, 0): |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2351 a = DoPut(_REMOTE, '/tools/accepted-transfer-syntaxes', [ |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2352 '1.2.840.10008.1.2', '1.2.840.10008.1.2.1', '1.2.840.10008.1.2.2' |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2353 ]) |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2354 self.assertTrue('1.2.840.10008.1.2' in a) |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2355 self.assertTrue('1.2.840.10008.1.2.1' in a) |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2356 self.assertTrue('1.2.840.10008.1.2.2' in a) |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2357 self.assertEqual(3, len(a)) |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2358 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/tools/unknown-sop-class-accepted', 'nope')) |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2359 DoPut(_REMOTE, '/tools/unknown-sop-class-accepted', '0') |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2360 self.assertEqual(0, DoGet(_REMOTE, '/tools/unknown-sop-class-accepted')) |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2361 else: |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2362 InstallLuaScriptFromPath(_REMOTE, 'Lua/TransferSyntaxDisable.lua') |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2363 |
61
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2364 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
|
2365 self.assertRaises(Exception, lambda: storescu('UnknownSopClassUid.dcm', True)) |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2366 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
373
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2367 |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2368 if IsOrthancVersionAbove(_REMOTE, 1, 9, 0): |
374 | 2369 a = DoPut(_REMOTE, '/tools/accepted-transfer-syntaxes', '*', 'text/plain') |
373
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2370 self.assertGreaterEqual(42, len(a)) |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2371 DoPut(_REMOTE, '/tools/unknown-sop-class-accepted', 'true') |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2372 self.assertEqual(1, DoGet(_REMOTE, '/tools/unknown-sop-class-accepted')) |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2373 else: |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2374 InstallLuaScriptFromPath(_REMOTE, 'Lua/TransferSyntaxEnable.lua') |
f673153f27a4
use of /tools/unknown-sop-class-accepted and /tools/accepted-transfer-syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2375 |
62
f9c4ce95756f
removal of useless information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
61
diff
changeset
|
2376 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
|
2377 storescu('Knix/Loc/IM-0001-0001.dcm', False) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2378 storescu('UnknownSopClassUid.dcm', True) |
967d44407308
test UnknownSopClassAccepted option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
60
diff
changeset
|
2379 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2380 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2381 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2382 def test_storescu_jpeg(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2383 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2384 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2385 knixStudy = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' |
64 | 2386 i = UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm')['ID'] |
2387 | |
2388 # This is JPEG lossless | |
136
5634ef96fcc5
testing "short" option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
133
diff
changeset
|
2389 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header' % i)['0002,0010']['Value']) |
64 | 2390 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
|
2391 self.assertEqual('1.2.840.10008.1.2.4.70', DoGet(_REMOTE, '/instances/%s/header?short' % i)['0002,0010']) |
64 | 2392 |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2393 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0002.dcm') |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2394 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0003.dcm') |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2395 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2396 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
|
2397 b = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2398 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2399 DoPost(_REMOTE, '/modalities/orthanctest/store', [ knixStudy, a, b ]) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2400 self.assertEqual(5, len(DoGet(_LOCAL, '/instances'))) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2401 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2402 self.assertEqual(3, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2403 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2404 DropOrthanc(_REMOTE) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2405 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2406 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2407 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2408 def test_pixel_data(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2409 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
|
2410 color = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2411 phenix = UploadInstance(_REMOTE, 'Phenix/IM-0001-0001.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2412 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2413 phenixSize = 358 * 512 * 2 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2414 colorSize = 1000 * 1000 * 3 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2415 jpegSize = 51918 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2416 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2417 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
|
2418 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
|
2419 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
|
2420 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2421 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
|
2422 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
|
2423 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2424 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
|
2425 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
|
2426 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2427 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2428 def test_decode_brainix(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2429 brainix = [ |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2430 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'], # (*) |
384 | 2431 UploadInstance(_REMOTE, 'Formats/JpegLossless.dcm')['ID'], # JPEG-LS, same as (*) (since Orthanc 0.7.6) => doesn't work on big-endian |
21
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2432 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
|
2433 ] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2434 h = '6fb11b932d535c2be04beabd99793ff8' |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2435 maxValue = 426.0 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2436 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2437 truth = Image.open(GetDatabasePath('Formats/Brainix.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2438 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2439 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2440 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2441 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2442 truth2 = map(lambda x: min(255, x), truth.getdata()) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2443 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2444 self.AssertSameImages(truth2, '/instances/%s/image-uint8' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2445 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2446 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
|
2447 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2448 self.AssertSameImages(truth2, '/instances/%s/preview' % i) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2449 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2450 for i in brainix: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2451 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
|
2452 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2453 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2454 def test_decode_color(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2455 imagej = UploadInstance(_REMOTE, 'ColorTestImageJ.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2456 color = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2457 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2458 for i in [ imagej, color ]: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2459 for j in [ 'image-uint8', 'image-uint16', 'image-int16' ]: |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2460 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
|
2461 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2462 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
|
2463 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
|
2464 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2465 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
|
2466 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
|
2467 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2468 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2469 def test_decode_rf(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2470 rf = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2471 truth = Image.open(GetDatabasePath('Formats/KarstenHilbertRF.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2472 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2473 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint8' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2474 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2475 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2476 self.AssertSameImages(truth.getdata(), '/instances/%s/preview' % rf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2477 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2478 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
|
2479 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2480 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2481 def test_decode_multiframe(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2482 mf = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2483 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2484 # Test the first frame |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2485 truth = Image.open(GetDatabasePath('Formats/Multiframe0.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2486 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint8' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2487 self.AssertSameImages(truth.getdata(), '/instances/%s/image-uint16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2488 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2489 self.AssertSameImages(truth.getdata(), '/instances/%s/preview' % mf) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2490 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
|
2491 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2492 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
|
2493 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2494 # Test the last frame |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2495 truth = Image.open(GetDatabasePath('Formats/Multiframe75.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2496 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
|
2497 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2498 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2499 def test_decode_signed(self): |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2500 signed = UploadInstance(_REMOTE, 'SignedCT.dcm')['ID'] |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2501 minValue = -2000 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2502 maxValue = 4042 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2503 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2504 truth = Image.open(GetDatabasePath('Formats/SignedCT.png')) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2505 self.AssertSameImages(truth.getdata(), '/instances/%s/image-int16' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2506 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2507 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
|
2508 self.AssertSameImages(truth2, '/instances/%s/image-uint16' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2509 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2510 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
|
2511 self.AssertSameImages(truth3, '/instances/%s/image-uint8' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2512 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2513 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
|
2514 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
|
2515 self.AssertSameImages(tmp, '/instances/%s/preview' % signed) |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2516 |
2a29bcff60a7
tests of image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
2517 self.assertEqual('b57e6c872a3da50877c7da689b03a444', ComputeMD5(DoGet(_REMOTE, '/instances/%s/matlab' % signed))) |
22 | 2518 |
2519 | |
46
85b2e36ed392
explicit GoogleCode source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
45
diff
changeset
|
2520 def test_googlecode_issue_32(self): |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2521 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/tools/default-encoding', 'nope')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2522 self.assertEqual('Windows1251', DoPut(_REMOTE, '/tools/default-encoding', 'Windows1251')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2523 self.assertEqual('Windows1251', DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2524 |
22 | 2525 f = UploadInstance(_REMOTE, 'Issue32.dcm')['ID'] |
2526 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % f) | |
2527 self.assertEqual(u'Рентгенография', tags['SeriesDescription']) | |
2528 self.assertEqual(u'Таз', tags['BodyPartExamined']) | |
2529 self.assertEqual(u'Прямая', tags['ViewPosition']) | |
2530 | |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2531 # 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
|
2532 self.assertEqual('Latin1', DoPut(_REMOTE, '/tools/default-encoding', 'Latin1')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2533 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2534 DoDelete(_REMOTE, '/instances/%s' % f) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2535 f = UploadInstance(_REMOTE, 'Issue32.dcm')['ID'] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2536 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % f) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2537 self.assertNotEqual(u'Рентгенография', tags['SeriesDescription']) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2538 |
314 | 2539 # Back to UTF-8 |
2540 self.assertEqual('Utf8', DoPut(_REMOTE, '/tools/default-encoding', 'Utf8')) | |
2541 | |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
2542 |
22 | 2543 def test_encodings(self): |
23 | 2544 # Latin-1 (ISO_IR 100) |
22 | 2545 brainix = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
2546 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % brainix) | |
2547 self.assertEqual(u'IRM cérébrale, neuro-crâne', tags['StudyDescription']) | |
23 | 2548 |
2549 # Latin-2 (ISO_IR 101) | |
2550 a = UploadInstance(_REMOTE, 'MarekLatin2.dcm')['ID'] | |
2551 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % a) | |
2552 # dcm2xml MarekLatin2.dcm | iconv -f latin2 -t utf-8 | xmllint --format - | |
2553 self.assertEqual('Imię i Nazwisko osoby opisującej', | |
2554 i['ContentSequence'][4]['ConceptNameCodeSequence'][0]['CodeMeaning'].encode('utf-8')) | |
2555 | |
26
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2556 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2557 def test_storescu_custom_aet(self): |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2558 # 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
|
2559 # 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
|
2560 # in the REST API)." |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2561 # 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
|
2562 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2563 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2564 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2565 a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2566 b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2567 c = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0003.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2568 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2569 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2570 'LocalAet' : 'YOP', |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2571 'Resources' : [ a['ID'], b['ID'] ] |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2572 }) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2573 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2574 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2575 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
|
2576 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2577 DropOrthanc(_LOCAL) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2578 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2579 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2580 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2581 'Resources' : [ c['ID'] ] |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2582 }) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2583 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2584 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2585 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
|
2586 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2587 DropOrthanc(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2588 DropOrthanc(_LOCAL) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2589 |
174 | 2590 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingChangeAet.lua') |
26
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2591 DoPost(_REMOTE, '/tools/execute-script', 'aet = "HELLO"', 'application/lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2592 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2593 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2594 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2595 WaitEmpty(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2596 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2597 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
|
2598 |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2599 DoPost(_REMOTE, '/tools/execute-script', 'aet = nill', 'application/lua') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2600 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2601 WaitEmpty(_REMOTE) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2602 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
040f6ef1394a
test_storescu_custom_aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
23
diff
changeset
|
2603 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
|
2604 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2605 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
|
2606 # 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
|
2607 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
|
2608 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
|
2609 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
|
2610 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
|
2611 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
|
2612 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2613 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
|
2614 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
|
2615 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
|
2616 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
|
2617 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2618 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
|
2619 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
|
2620 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2621 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
|
2622 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
|
2623 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
|
2624 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
|
2625 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
|
2626 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
|
2627 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
|
2628 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
|
2629 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
|
2630 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
|
2631 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
|
2632 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
|
2633 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
|
2634 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
|
2635 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
|
2636 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2637 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
|
2638 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
|
2639 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
|
2640 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
|
2641 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
|
2642 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
|
2643 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
|
2644 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2645 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
|
2646 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
|
2647 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
|
2648 |
1047d7bc5210
test limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
2649 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
|
2650 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
|
2651 self.assertTrue(instance in s) |
36 | 2652 |
2653 | |
2654 def test_create_pdf(self): | |
2655 # Upload 4 instances | |
2656 brainixInstance = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] | |
2657 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
2658 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
2659 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
2660 | |
2661 brainixPatient = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0' | |
2662 brainixStudy = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' | |
2663 brainixEpi = '2ac1316d-3e432022-62eabff2-c59f5475-9b1ac3f8' | |
2664 | |
2665 with open(GetDatabasePath('HelloWorld.pdf'), 'rb') as f: | |
2666 pdf = f.read() | |
2667 | |
2668 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2669 json.dumps({ | |
2670 'Tags' : { | |
2671 'PatientName' : 'Jodogne', | |
2672 'Modality' : 'CT', | |
2673 }, | |
2674 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2675 })) | |
2676 | |
2677 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2678 self.assertEqual('OT', DoGet(_REMOTE, '/instances/%s/content/Modality' % i['ID']).strip()) | |
2679 | |
2680 b = DoGet(_REMOTE, '/instances/%s/content/0042-0011' % i['ID']) | |
2681 self.assertEqual(len(b), len(pdf) + 1) | |
2682 self.assertEqual(ComputeMD5(b), ComputeMD5(pdf + '\0')) | |
2683 | |
2684 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/tools/create-dicom', | |
2685 json.dumps({ | |
2686 'Parent' : brainixPatient, | |
2687 'Tags' : { | |
2688 'PatientName' : 'Jodogne', | |
2689 } | |
2690 }))) | |
2691 | |
2692 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2693 json.dumps({ | |
2694 'Parent' : brainixPatient, | |
2695 'Tags' : { 'StudyDescription' : 'PDF^Patient' }, | |
2696 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2697 })) | |
2698 | |
2699 self.assertEqual(brainixPatient, DoGet(_REMOTE, '/instances/%s/patient' % i['ID'])['ID']) | |
2700 | |
2701 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2702 json.dumps({ | |
2703 'Parent' : brainixStudy, | |
2704 'Tags' : { 'SeriesDescription' : 'PDF^Study' }, | |
2705 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) | |
2706 })) | |
2707 | |
2708 self.assertEqual(brainixStudy, DoGet(_REMOTE, '/instances/%s/study' % i['ID'])['ID']) | |
2709 | |
2710 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2711 json.dumps({ | |
2712 'Parent' : brainixEpi, | |
37 | 2713 'Tags' : { 'SpecificCharacterSet' : 'ISO_IR 13' }, |
36 | 2714 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) |
2715 })) | |
2716 | |
2717 self.assertEqual(brainixEpi, DoGet(_REMOTE, '/instances/%s/series' % i['ID'])['ID']) | |
2718 | |
2719 b = DoGet(_REMOTE, '/instances/%s/pdf' % i['ID']) | |
2720 self.assertEqual(len(b), len(pdf)) | |
2721 self.assertEqual(ComputeMD5(b), ComputeMD5(pdf)) | |
2722 | |
2723 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/pdf' % brainixInstance)) | |
38 | 2724 |
2725 | |
2726 def test_create_series(self): | |
2727 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2728 json.dumps({ | |
2729 'Tags' : { | |
40 | 2730 'SpecificCharacterSet' : 'ISO_IR 100', |
2731 'PatientName' : 'Sébastien Jodogne', | |
38 | 2732 'Modality' : 'CT', |
2733 }, | |
2734 'Content' : [ | |
40 | 2735 { |
2736 'Content': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', # red dot in RGBA | |
2737 'Tags' : { 'ImageComments' : 'Tutu' } | |
2738 }, | |
38 | 2739 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAoUlEQVQ4jZ2SWw3EIBREjwUsYAELa2EtoAULFUCyXAtroRZqoRbox254BdLC/DZnZjoXWJFgCDg8egW2CBEhEnDzyRk+Ecxz2KP/0AL8S99T+jQccAVs22qKwAuPuq0uyNg9cPLh3am+pe/dkHLZtqJHj6vXJrZ7nvzvxxgemXgUwnGfXqpee09mUwp8m022OYP6bLF7mVuVe0y/umxinsAXRd9z0k1ubWsAAAAASUVORK5CYII=', |
2740 ] | |
2741 })) | |
2742 | |
2743 s = DoGet(_REMOTE, i['Path']) | |
2744 self.assertEqual('Series', s['Type']) | |
2745 self.assertEqual(s['ID'], i['ID']) | |
2746 self.assertEqual(2, len(s['Instances'])) | |
39 | 2747 self.assertEqual(2, s['ExpectedNumberOfInstances']) |
2748 self.assertEqual('Complete', s['Status']) | |
40 | 2749 |
2750 a = DoGet(_REMOTE, '/instances/%s/tags?simplify' % s['Instances'][0]) | |
2751 b = DoGet(_REMOTE, '/instances/%s/tags?simplify' % s['Instances'][1]) | |
2752 self.assertTrue('ImageComments' in a or 'ImageComments' in b) | |
2753 if 'ImageComments' in a: | |
2754 self.assertEqual('Tutu', a['ImageComments']) | |
2755 else: | |
2756 self.assertEqual('Tutu', b['ImageComments']) | |
2757 | |
2758 patient = DoGet(_REMOTE, '/instances/%s/patient' % s['Instances'][0]) | |
2759 self.assertEqual(patient['MainDicomTags']['PatientName'].encode('utf-8'), | |
2760 'Sébastien Jodogne') | |
47 | 2761 |
2762 | |
2763 def test_create_binary(self): | |
2764 binary = ''.join(map(chr, range(256))) | |
2765 encoded = 'data:application/octet-stream;base64,' + base64.b64encode(binary) | |
2766 tags = { | |
2767 'PatientName' : 'Jodogne', | |
2768 '8899-8899' : encoded | |
2769 } | |
2770 | |
2771 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2772 json.dumps({ | |
266 | 2773 'Tags' : tags, |
2774 'PrivateCreator' : 'TestBinary', | |
47 | 2775 })) |
2776 | |
2777 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2778 self.assertEqual(binary, DoGet(_REMOTE, '/instances/%s/content/8899-8899' % i['ID']).strip()) | |
2779 | |
2780 i = DoPost(_REMOTE, '/tools/create-dicom', | |
2781 json.dumps({ | |
2782 'InterpretBinaryTags' : False, | |
266 | 2783 'Tags' : tags, |
2784 'PrivateCreator' : 'TestBinary', | |
47 | 2785 })) |
2786 | |
2787 self.assertEqual('Jodogne', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i['ID']).strip()) | |
2788 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
|
2789 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2790 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2791 def test_patient_ids_collision(self): |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2792 # 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
|
2793 # same PatientID |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2794 for i in range(3): |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2795 UploadInstance(_REMOTE, 'PatientIdsCollision/Image%d.dcm' % (i + 1)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2796 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2797 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2798 'Query' : { 'PatientName' : '*' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2799 self.assertEqual(1, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2800 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
|
2801 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2802 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2803 'CaseSensitive' : True, |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2804 'Query' : { 'PatientName' : 'FOO\\HELLO' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2805 self.assertEqual(2, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2806 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2807 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Series', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2808 'CaseSensitive' : False, |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2809 'Query' : { 'PatientName' : 'Foo' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2810 self.assertEqual(1, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2811 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
|
2812 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
|
2813 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
|
2814 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2815 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2816 'Query' : { 'PatientName' : '*' }}) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2817 self.assertEqual(3, len(a)) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2818 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
|
2819 self.assertTrue('FOO^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2820 self.assertTrue('HELLO^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2821 self.assertTrue('WORLD^SERIES' in d) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2822 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2823 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
|
2824 self.assertEqual(1, len(set(d))) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2825 self.assertEqual('COMMON', d[0]) |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2826 |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2827 for i in a: |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2828 d = DoGet(_REMOTE, '/studies/%s' % i) ['MainDicomTags']['StudyDescription'] |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2829 p = DoGet(_REMOTE, '/studies/%s' % i) ['PatientMainDicomTags']['PatientName'] |
e4352463ff74
test_patient_ids_collision
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
2830 self.assertEqual('%s^SERIES' % p, d) |
49
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2831 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2832 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2833 def test_bitbucket_issue_4(self): |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2834 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2835 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2836 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0003.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2837 UploadInstance(_REMOTE, 'Formats/Jpeg.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2838 UploadInstance(_REMOTE, 'Formats/JpegLossless.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2839 UploadInstance(_REMOTE, 'Formats/Rle.dcm') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2840 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2841 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2842 self.assertEqual(6, len(DoGet(_REMOTE, '/instances'))) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2843 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2844 p = DoGet(_REMOTE, '/patients') |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2845 self.assertEqual(2, len(p)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2846 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
|
2847 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
|
2848 self.assertEqual(3, len(i1)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2849 self.assertEqual(3, len(i2)) |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2850 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2851 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
|
2852 |
e7f9b8199545
test_bitbucket_issue_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
48
diff
changeset
|
2853 self.assertEqual(6, len(DoGet(_LOCAL, '/instances'))) |
50
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2854 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2855 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2856 def test_create_sequence(self): |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2857 i = DoPost(_REMOTE, '/tools/create-dicom', |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2858 json.dumps({ |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2859 'Tags' : { |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2860 'SpecificCharacterSet': 'ISO_IR 100', # Encode using Latin1 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2861 'PatientName': 'Jodogne^', |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2862 'ReferencedStudySequence': GenerateTestSequence(), |
50
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2863 } |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2864 }))['ID'] |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2865 |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2866 self.assertEqual('Jodogne^', DoGet(_REMOTE, '/instances/%s/content/PatientName' % i)) |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2867 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
|
2868 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
|
2869 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
|
2870 self.assertEqual(u'Sébastien^'.encode('latin-1'), |
8de63d56cf11
test_create_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
49
diff
changeset
|
2871 DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence/1/StudyDescription' % i)) |
51
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2872 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2873 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2874 def test_modify_sequence(self): |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2875 i = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2876 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
|
2877 |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2878 j = DoPost(_REMOTE, '/instances/%s/modify' % i, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2879 json.dumps({ |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2880 "Replace" : { |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2881 "PatientName" : "hello", |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2882 'ReferencedStudySequence': GenerateTestSequence(), |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2883 }, |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2884 }), |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2885 'application/json') |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2886 j = DoPost(_REMOTE, '/instances', j, 'application/dicom')['ID'] |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2887 DoDelete(_REMOTE, '/instances/%s' % i) |
264a20a0276d
test_modify_sequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
50
diff
changeset
|
2888 |
52 | 2889 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/content/ReferencedStudySequence' % j))) |
2890 | |
2891 | |
2892 def test_compression(self): | |
2893 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | |
2894 | |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2895 aa = DoGet(_REMOTE, '/instances/%s/attachments/' % i) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2896 if IsOrthancVersionAbove(_REMOTE, 1, 9, 1): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2897 # This file has *no* pixel data, so "dicom-until-pixel-data" is not stored |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2898 self.assertEqual(1, len(aa)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2899 self.assertTrue('dicom' in aa) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2900 else: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2901 self.assertEqual(2, len(aa)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2902 self.assertTrue('dicom' in aa) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2903 self.assertTrue('dicom-as-json' in aa) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2904 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2905 data = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/data' % i)[1] |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2906 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2907 # If "StorageCompression" is enabled in the Orthanc to be |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2908 # tested, uncompress the attachment before running the test |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2909 if DoGet(_REMOTE, '/instances/%s/attachments/dicom/is-compressed' % i) != 0: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2910 DoPost(_REMOTE, '/instances/%s/attachments/dicom/uncompress' % i) |
52 | 2911 |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2912 cs = int(DoGet(_REMOTE, '/statistics')['TotalDiskSize']) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2913 us = int(DoGet(_REMOTE, '/statistics')['TotalUncompressedSize']) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2914 size = int(DoGet(_REMOTE, '/instances/%s/attachments/dicom/size' % i)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2915 md5 = DoGet(_REMOTE, '/instances/%s/attachments/dicom/md5' % i) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2916 self.assertEqual(data, DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i)[1]) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2917 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom/compressed-md5' % i)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2918 self.assertEqual(size, int(DoGet(_REMOTE, '/instances/%s/attachments/dicom/compressed-size' % i))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2919 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2920 ops = DoGet(_REMOTE, '/instances/%s/attachments/dicom' % i) |
52 | 2921 self.assertTrue('compress' in ops) |
2922 self.assertTrue('uncompress' in ops) | |
2923 self.assertTrue('is-compressed' in ops) | |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2924 self.assertEqual(0, DoGet(_REMOTE, '/instances/%s/attachments/dicom/is-compressed' % i)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2925 DoPost(_REMOTE, '/instances/%s/attachments/dicom/verify-md5' % i) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2926 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2927 # Re-compress the attachment |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2928 DoPost(_REMOTE, '/instances/%s/attachments/dicom/compress' % i) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2929 DoPost(_REMOTE, '/instances/%s/attachments/dicom/verify-md5' % i) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2930 self.assertEqual(1, DoGet(_REMOTE, '/instances/%s/attachments/dicom/is-compressed' % i)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2931 self.assertGreater(cs, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2932 self.assertEqual(us, int(DoGet(_REMOTE, '/statistics')['TotalUncompressedSize'])) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2933 self.assertGreater(len(data), len(DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i)[1])) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2934 self.assertGreater(size, int(DoGet(_REMOTE, '/instances/%s/attachments/dicom/compressed-size' % i))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2935 self.assertEqual(size, int(DoGet(_REMOTE, '/instances/%s/attachments/dicom/size' % i))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2936 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom/md5' % i)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2937 self.assertNotEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom/compressed-md5' % i)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2938 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2939 DoPost(_REMOTE, '/instances/%s/attachments/dicom/uncompress' % i) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2940 DoPost(_REMOTE, '/instances/%s/attachments/dicom/verify-md5' % i) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2941 self.assertEqual(0, DoGet(_REMOTE, '/instances/%s/attachments/dicom/is-compressed' % i)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2942 self.assertEqual(data, DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i)[1]) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2943 self.assertEqual(size, int(DoGet(_REMOTE, '/instances/%s/attachments/dicom/compressed-size' % i))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2944 self.assertEqual(size, int(DoGet(_REMOTE, '/instances/%s/attachments/dicom/size' % i))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2945 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom/md5' % i)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2946 self.assertEqual(md5, DoGet(_REMOTE, '/instances/%s/attachments/dicom/compressed-md5' % i)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2947 self.assertEqual(cs, int(DoGet(_REMOTE, '/statistics')['TotalDiskSize'])) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
2948 self.assertEqual(us, int(DoGet(_REMOTE, '/statistics')['TotalUncompressedSize'])) |
53 | 2949 |
2950 | |
2951 def test_ordered_slices(self): | |
2952 i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] | |
2953 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2954 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2955 self.assertEqual('Sequence', o['Type']) | |
2956 self.assertEqual(1, len(o['Dicom'])) | |
2957 self.assertEqual('/instances/9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02/file', o['Dicom'][0]) | |
2958 self.assertEqual(76, len(o['Slices'])) | |
2959 for j in range(76): | |
2960 self.assertEqual('/instances/9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02/frames/%d' % j, o['Slices'][j]) | |
2961 | |
68 | 2962 self.assertEqual(1, len(o['SlicesShort'])) |
2963 self.assertEqual('9e05eb0a-18b6268c-e0d36085-8ddab517-3b5aec02', o['SlicesShort'][0][0]) | |
2964 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2965 self.assertEqual(76, o['SlicesShort'][0][2]) | |
2966 | |
53 | 2967 i = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
2968 j = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm')['ID'] | |
2969 k = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0003.dcm')['ID'] | |
2970 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2971 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2972 | |
2973 self.assertEqual('Volume', o['Type']) | |
2974 self.assertEqual(3, len(o['Dicom'])) | |
2975 self.assertEqual(3, len(o['Slices'])) | |
2976 self.assertEqual('/instances/%s/file' % i, o['Dicom'][2]) | |
2977 self.assertEqual('/instances/%s/file' % j, o['Dicom'][1]) | |
2978 self.assertEqual('/instances/%s/file' % k, o['Dicom'][0]) | |
2979 self.assertEqual('/instances/%s/frames/0' % i, o['Slices'][2]) | |
2980 self.assertEqual('/instances/%s/frames/0' % j, o['Slices'][1]) | |
2981 self.assertEqual('/instances/%s/frames/0' % k, o['Slices'][0]) | |
2982 | |
68 | 2983 self.assertEqual(3, len(o['SlicesShort'])) |
2984 self.assertEqual(k, o['SlicesShort'][0][0]) | |
2985 self.assertEqual(0, o['SlicesShort'][0][1]) | |
2986 self.assertEqual(1, o['SlicesShort'][0][2]) | |
2987 self.assertEqual(j, o['SlicesShort'][1][0]) | |
2988 self.assertEqual(0, o['SlicesShort'][1][1]) | |
2989 self.assertEqual(1, o['SlicesShort'][1][2]) | |
2990 self.assertEqual(i, o['SlicesShort'][2][0]) | |
2991 self.assertEqual(0, o['SlicesShort'][2][1]) | |
2992 self.assertEqual(1, o['SlicesShort'][2][2]) | |
2993 | |
53 | 2994 i = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] |
2995 j = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0002.dcm')['ID'] | |
2996 s = DoGet(_REMOTE, '/instances/%s' % i)['ParentSeries'] | |
2997 o = DoGet(_REMOTE, '/series/%s/ordered-slices' % s) | |
2998 | |
2999 self.assertEqual('Sequence', o['Type']) | |
3000 self.assertEqual(2, len(o['Dicom'])) | |
3001 self.assertEqual(2, len(o['Slices'])) | |
3002 self.assertEqual('/instances/%s/file' % i, o['Dicom'][0]) | |
3003 self.assertEqual('/instances/%s/file' % j, o['Dicom'][1]) | |
3004 self.assertEqual('/instances/%s/frames/0' % i, o['Slices'][0]) | |
3005 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
|
3006 |
68 | 3007 self.assertEqual(2, len(o['SlicesShort'])) |
3008 self.assertEqual(i, o['SlicesShort'][0][0]) | |
3009 self.assertEqual(0, o['SlicesShort'][0][1]) | |
3010 self.assertEqual(1, o['SlicesShort'][0][2]) | |
3011 self.assertEqual(j, o['SlicesShort'][1][0]) | |
3012 self.assertEqual(0, o['SlicesShort'][1][1]) | |
3013 self.assertEqual(1, o['SlicesShort'][1][2]) | |
3014 | |
3015 | |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
3016 |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
3017 def test_incoming_movescu_accession(self): |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
3018 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
3019 |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
3020 # No matching patient, so no job is created |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
3021 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
3022 CallMoveScu([ '--study', '-k', '0008,0052=STUDY', '-k', 'AccessionNumber=nope' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
3023 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
3024 CallMoveScu([ '--study', '-k', '0008,0052=PATIENT', '-k', 'AccessionNumber=A10003245599' ]) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
3025 self.assertEqual(0, len(DoGet(_LOCAL, '/patients'))) |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
3026 |
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
3027 # 1 Matching patient, track the job |
138 | 3028 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
3029 '--study', | |
3030 '-k', '0008,0052=STUDY', | |
3031 '-k', 'AccessionNumber=A10003245599' | |
3032 ]))) | |
137
412d5f70447e
testing asynchronous c-move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
3033 |
54
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
3034 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) |
c5f8a6b0d85e
test_incoming_movescu_accession
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
3035 |
55 | 3036 |
3037 def test_dicom_to_json(self): | |
3038 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
|
3039 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
|
3040 |
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
3041 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
|
3042 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
|
3043 self.assertTrue(CompareTags(t, json.loads(f.read()), [ |
123 | 3044 # Tags for compatibility with DCMTK 3.6.0 |
3045 'RETIRED_OtherPatientIDs', | |
3046 'OtherPatientIDs', | |
3047 'ACR_NEMA_2C_VariablePixelDataGroupLength', | |
80
8466dbfcb22b
fix test against dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
79
diff
changeset
|
3048 ])) |
55 | 3049 |
3050 t = DoGet(_REMOTE, '/instances/%s/tags' % i) | |
3051 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
|
3052 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
|
3053 ])) |
55 | 3054 |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
3055 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
|
3056 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
|
3057 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
|
3058 ])) |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
3059 |
372
e9b03d8f3b78
fix for DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
3060 |
e9b03d8f3b78
fix for DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
3061 # NB: To get the actual value of the "tags" JSON file, use the |
e9b03d8f3b78
fix for DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
3062 # following command: |
e9b03d8f3b78
fix for DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
3063 # $ curl http://alice:orthanctest@localhost:8042/instances/d29ead49-43e8601d-72f1e922-7de676ee-ea77c2b4/tags |
60
cd3c7f70f139
test backward compatibility with Orthanc 0.9.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
59
diff
changeset
|
3064 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
|
3065 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
|
3066 a = json.loads(f.read()) |
378
a4b8450a1158
fix test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
3067 |
a4b8450a1158
fix test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
3068 # Starting with Orthanc 1.9.1, the DICOM-as-JSON |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3069 # reports are truncated starting with PixelData |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3070 if IsOrthancVersionAbove(_REMOTE, 1, 9, 1): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3071 self.assertFalse('7fe1,0010' in t) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3072 self.assertFalse('7fe1,1001' in t) |
378
a4b8450a1158
fix test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
3073 del a['7fe1,0010'] |
a4b8450a1158
fix test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
3074 del a['7fe1,1001'] |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3075 else: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3076 self.assertTrue('7fe1,0010' in t) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3077 self.assertTrue('7fe1,1001' in t) |
378
a4b8450a1158
fix test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
3078 |
65
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
3079 aa = json.dumps(a).replace('2e+022', '2e+22') |
372
e9b03d8f3b78
fix for DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
3080 tt = (json.dumps(t) |
e9b03d8f3b78
fix for DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
3081 .replace('2e+022', '2e+22') |
e9b03d8f3b78
fix for DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
3082 # The "IllegalPrivatePixelSequence" tag was introduced in DCMTK 3.6.6 dictionary |
e9b03d8f3b78
fix for DCMTK 3.6.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
3083 .replace('IllegalPrivatePixelSequence', 'Unknown Tag & Data')) |
65
09fc27e0899a
patch for testing windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
64
diff
changeset
|
3084 self.assertEqual(aa, tt) |
57 | 3085 |
3086 | |
3087 def test_batch_archive(self): | |
3088 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
3089 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm') | |
3090 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
3091 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0002.dcm') | |
3092 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
3093 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0002.dcm') | |
3094 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
3095 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0002.dcm') | |
3096 | |
3097 s = DoPost(_REMOTE, '/tools/create-archive', [ ]) | |
3098 z = zipfile.ZipFile(StringIO(s), "r") | |
3099 self.assertEqual(0, len(z.namelist())) | |
3100 | |
3101 # One patient | |
3102 s = DoPost(_REMOTE, '/tools/create-archive', [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ]) | |
3103 z = zipfile.ZipFile(StringIO(s), "r") | |
3104 self.assertEqual(4, len(z.namelist())) | |
3105 | |
3106 # One patient + twice its study + one series from other patient | |
3107 s = DoPost(_REMOTE, '/tools/create-archive', [ | |
3108 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
3109 '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918', | |
3110 '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' | |
3111 ]) | |
3112 z = zipfile.ZipFile(StringIO(s), "r") | |
3113 self.assertEqual(6, len(z.namelist())) | |
3114 | |
3115 # One patient + one series + one instance | |
3116 s = DoPost(_REMOTE, '/tools/create-archive', [ | |
3117 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
3118 '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0', | |
3119 '1d429ccb-bdcc78a1-7d129d6a-ba4966ed-fe4dbd87' | |
3120 ]) | |
3121 z = zipfile.ZipFile(StringIO(s), "r") | |
3122 self.assertEqual(7, len(z.namelist())) | |
59
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3123 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3124 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3125 def test_decode_brainix_as_jpeg(self): |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3126 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
|
3127 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3128 j = GetImage(_REMOTE, '/instances/%s/preview' % i) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3129 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3130 self.assertEqual(j.size[0], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3131 self.assertEqual(j.size[1], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3132 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3133 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
|
3134 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3135 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3136 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
|
3137 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3138 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3139 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
|
3140 self.assertEqual('PNG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3141 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3142 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
|
3143 self.assertEqual('JPEG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3144 self.assertEqual(j.size[0], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3145 self.assertEqual(j.size[1], 256) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3146 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3147 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
|
3148 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
|
3149 self.assertLess(a, b) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3150 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3151 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
|
3152 self.assertEqual('JPEG', j.format) |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3153 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3154 # 16bit encoding is not supported with JPEG |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3155 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
|
3156 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
|
3157 |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3158 # No matching content type |
84378ada15ab
test_decode_brainix_as_jpeg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
58
diff
changeset
|
3159 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
|
3160 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3161 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3162 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3163 def test_media_encodings(self): |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3164 ascii = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3165 latin1 = UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3166 latin2 = UploadInstance(_REMOTE, 'MarekLatin2.dcm')['ID'] |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3167 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3168 tmp = DoPost(_REMOTE, '/tools/create-media', [ascii,latin1,latin2]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3169 z = zipfile.ZipFile(StringIO(tmp), "r") |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3170 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3171 self.assertEqual(4, len(z.namelist())) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3172 self.assertTrue('IMAGES/IM0' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3173 self.assertTrue('IMAGES/IM1' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3174 self.assertTrue('IMAGES/IM2' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3175 self.assertTrue('DICOMDIR' in z.namelist()) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3176 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3177 try: |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3178 os.remove('/tmp/DICOMDIR') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3179 except: |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3180 # The file does not exist |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3181 pass |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3182 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3183 z.extract('DICOMDIR', '/tmp') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3184 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3185 stderr = subprocess.STDOUT).split('\n') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3186 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3187 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3188 stderr = subprocess.STDOUT).split('\n') |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3189 self.assertEqual(1, len(a)) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3190 self.assertEqual('', a[0]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3191 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3192 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3193 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
|
3194 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
|
3195 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
|
3196 |
83fd88230097
test_media_encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
68
diff
changeset
|
3197 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
|
3198 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3199 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3200 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
|
3201 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
|
3202 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
|
3203 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
|
3204 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3205 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
|
3206 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
|
3207 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
|
3208 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
|
3209 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3210 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
|
3211 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
|
3212 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
|
3213 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
|
3214 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3215 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
|
3216 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
|
3217 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
|
3218 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
|
3219 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3220 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
|
3221 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
|
3222 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
|
3223 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
|
3224 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3225 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
|
3226 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
|
3227 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
|
3228 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
|
3229 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3230 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
|
3231 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
|
3232 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
|
3233 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
|
3234 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
|
3235 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3236 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
|
3237 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
|
3238 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
|
3239 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
|
3240 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
|
3241 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
|
3242 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3243 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
|
3244 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
|
3245 self.assertEqual(1, len(s)) |
176
48cc188ffb09
strip trailing 0 char that appears with some findscu versions
am@osimis.io
parents:
175
diff
changeset
|
3246 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
|
3247 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
|
3248 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
|
3249 |
48740070cbf1
TDD: tests for ongoing development of counter tags in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
3250 |
78
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3251 def test_decode_transfer_syntax(self): |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3252 def Check(t, md5): |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3253 i = UploadInstance(_REMOTE, 'TransferSyntaxes/%s.dcm' % t)['ID'] |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3254 |
89
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3255 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
|
3256 transferSyntax = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % i) |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3257 self.assertEqual(t, transferSyntax) |
74b7b9aed5f8
test TransferSyntax metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
3258 |
78
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3259 if md5 == None: |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3260 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
|
3261 else: |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3262 m = ComputeMD5(DoGet(_REMOTE, '/instances/%s/preview' % i)) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3263 self.assertEqual(m, md5) |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3264 |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3265 Check('1.2.840.10008.1.2.1', 'fae08d5415c4c0cd2cdbae4522408631') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3266 Check('1.2.840.10008.1.2.2', 'f3d9784768b8feb54d6a50b6d5c37682') |
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3267 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
|
3268 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
|
3269 Check('1.2.840.10008.1.2.4.70', '7132cfbc457305b04b59787030c785d2') |
384 | 3270 Check('1.2.840.10008.1.2.5', '6ff51ae525d362e0d04f550a64075a0e') # RLE, supported since Orthanc 1.0.1 |
3271 Check('1.2.840.10008.1.2', 'd54aed9f67a100984b42942cc2e9939b') | |
3272 | |
3273 # The 3 checks below don't work on big-endian | |
3274 Check('1.2.840.10008.1.2.4.50', '496326046974eea718dbc16b997c646b') # TODO - Doesn't work with GDCM 3.0.7 alone | |
78
b89af51797ff
test_decode_transfer_syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
3275 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
|
3276 Check('1.2.840.10008.1.2.4.81', '801579ae7cbf28e604ea74f2c99fa2ca') |
299
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
3277 |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
3278 # JPEG2k image, not supported without GDCM plugin |
304 | 3279 if not HasGdcmPlugin(_REMOTE): |
299
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
3280 Check('1.2.840.10008.1.2.4.90', None) |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
3281 Check('1.2.840.10008.1.2.4.91', None) |
79 | 3282 |
3283 | |
3284 def test_raw_frame(self): | |
3285 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] | |
3286 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3287 a = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3288 self.assertEqual(512 * 512 * 2, len(a)) | |
3289 self.assertEqual(512 * 512 * 2, len(DoGet(_REMOTE, '/instances/%s/frames/23/raw' % s))) | |
3290 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/24/raw' % s)) | |
3291 self.assertEqual('1914287dc4d958eca21fdaacfb3482fa', ComputeMD5(a)) | |
3292 | |
3293 s = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID'] | |
3294 self.assertEqual(76, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3295 self.assertEqual(186274, len(DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s))) | |
3296 self.assertEqual(189424, len(DoGet(_REMOTE, '/instances/%s/frames/75/raw' % s))) | |
3297 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/76/raw' % s)) | |
3298 im = GetImage(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3299 self.assertEqual("L", im.mode) | |
3300 self.assertEqual(512, im.size[0]) | |
3301 self.assertEqual(512, im.size[1]) | |
3302 | |
3303 # Test an image with 2 JPEG frames spread over multiple fragments | |
3304 s = UploadInstance(_REMOTE, 'LenaTwiceWithFragments.dcm')['ID'] | |
3305 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) | |
3306 a = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3307 b = DoGet(_REMOTE, '/instances/%s/frames/1/raw' % s) | |
3308 self.assertEqual(69214, len(a)) | |
3309 self.assertEqual(ComputeMD5(a), ComputeMD5(b)) | |
3310 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/frames/2/raw' % s)) | |
3311 im = GetImage(_REMOTE, '/instances/%s/frames/0/raw' % s) | |
3312 self.assertEqual("RGB", im.mode) | |
3313 self.assertEqual(512, im.size[0]) | |
3314 self.assertEqual(512, im.size[1]) | |
323 | 3315 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % s) # TODO - Doesn't work with GDCM 3.0.7 alone |
79 | 3316 self.assertEqual("RGB", im.mode) |
3317 self.assertEqual(512, im.size[0]) | |
3318 self.assertEqual(512, im.size[1]) | |
81 | 3319 |
3320 | |
3321 | |
3322 def test_rest_movescu(self): | |
3323 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3324 | |
3325 # Upload 4 instances | |
3326 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') | |
3327 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0002.dcm') | |
3328 UploadInstance(_REMOTE, 'Brainix/Epi/IM-0001-0001.dcm') | |
3329 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
3330 | |
3331 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3332 for p in DoGet(_REMOTE, '/patients'): | |
3333 DoPost(_REMOTE, '/modalities/orthanctest/store', p) | |
3334 DoDelete(_REMOTE, '/patients/%s' % p) | |
3335 | |
3336 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3337 | |
3338 # Upload instance Brainix/Flair/IM-0001-0001.dcm | |
3339 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Instance', | |
3340 'Resources' : [ | |
3341 { | |
3342 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3343 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497', | |
3344 'SOPInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549', | |
3345 } | |
3346 ]}) | |
3347 | |
3348 # Upload series Brainix/Flair/* | |
3349 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3350 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3351 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
3352 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
3353 | |
3354 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Series', | |
3355 'Resources' : [ | |
3356 { | |
3357 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3358 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497', | |
3359 } | |
3360 ]}) | |
3361 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3362 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3363 self.assertEqual(1, len(DoGet(_REMOTE, '/series'))) | |
3364 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) | |
3365 | |
3366 # Upload series Brainix/Epi/* | |
3367 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Series', | |
3368 'Resources' : [ | |
3369 { | |
3370 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3371 'SeriesInstanceUID' : '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314125550', | |
3372 } | |
3373 ]}) | |
3374 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) | |
3375 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) | |
3376 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) | |
3377 self.assertEqual(3, len(DoGet(_REMOTE, '/instances'))) | |
3378 | |
3379 # Upload study Knee/* | |
3380 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Study', | |
3381 'Resources' : [ | |
3382 { | |
3383 'StudyInstanceUID' : '2.16.840.1.113669.632.20.121711.10000160881', | |
3384 } | |
3385 ]}) | |
3386 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3387 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) | |
3388 self.assertEqual(3, len(DoGet(_REMOTE, '/series'))) | |
3389 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
3390 | |
3391 # Reset | |
3392 for p in DoGet(_REMOTE, '/patients'): | |
3393 DoDelete(_REMOTE, '/patients/%s' % p) | |
3394 | |
3395 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | |
3396 | |
3397 | |
3398 # Upload all at once | |
3399 DoPost(_REMOTE, '/modalities/orthanctest/move', { 'Level' : 'Study', | |
3400 'Resources' : [ | |
3401 { | |
3402 'StudyInstanceUID' : '2.16.840.1.113669.632.20.121711.10000160881', | |
3403 }, | |
3404 { | |
3405 'StudyInstanceUID' : '2.16.840.1.113669.632.20.1211.10000357775', | |
3406 } | |
3407 ]}) | |
3408 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | |
3409 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) | |
3410 self.assertEqual(3, len(DoGet(_REMOTE, '/series'))) | |
3411 self.assertEqual(4, len(DoGet(_REMOTE, '/instances'))) | |
3412 | |
86
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3413 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3414 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3415 def test_reconstruct_json(self): |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3416 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3417 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3418 instance = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3419 first = DoGet(_REMOTE, '/instances/%s/tags' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3420 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3421 self.assertEqual('TWINOW', first['0008,1010']['Value']) |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3422 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3423 if IsOrthancVersionAbove(_REMOTE, 1, 9, 1): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3424 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3425 else: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3426 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
86
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3427 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3428 # Cannot delete the "DICOM" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3429 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
|
3430 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3431 # Can delete the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3432 r = DoDelete(_REMOTE, '/instances/%s/attachments/dicom-as-json' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3433 self.assertTrue(type(r) is dict and len(r) == 0) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3434 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3435 # Only the "DICOM" attachment subsists |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3436 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3437 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3438 # Cannot manually reconstruct the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3439 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
|
3440 |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3441 # Transparently reconstruct the "DICOM as JSON" attachment |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3442 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
|
3443 second = DoGet(_REMOTE, '/instances/%s/tags' % instance) |
0401ef51f5c1
test_reconstruct_json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
83
diff
changeset
|
3444 self.assertEqual(str(first), str(second)) |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3445 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3446 if IsOrthancVersionAbove(_REMOTE, 1, 9, 1): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3447 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3448 else: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3449 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % instance))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3450 third = DoGet(_REMOTE, '/instances/%s/attachments/dicom-as-json/data' % instance) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3451 self.assertEqual(str(first), str(third)) |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3452 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3453 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3454 def test_reconstruct_json2(self): |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3455 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3456 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3457 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
|
3458 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
|
3459 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3460 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
|
3461 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
|
3462 |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3463 aa = DoGet(_REMOTE, '/instances/%s/attachments' % a) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3464 bb = DoGet(_REMOTE, '/instances/%s/attachments' % b) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3465 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3466 if not IsOrthancVersionAbove(_REMOTE, 1, 9, 1): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3467 self.assertEqual(2, len(aa)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3468 self.assertEqual(aa, bb) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3469 self.assertTrue('dicom' in aa) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3470 self.assertTrue('dicom-as-json' in aa) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3471 elif IsDicomUntilPixelDataStored(_REMOTE): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3472 self.assertEqual(2, len(aa)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3473 self.assertEqual(aa, bb) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3474 self.assertTrue('dicom' in aa) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3475 self.assertTrue('dicom-until-pixel-data' in aa) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3476 else: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3477 self.assertEqual(1, len(aa)) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3478 self.assertEqual(aa, bb) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3479 self.assertTrue('dicom' in aa) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3480 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3481 # In Orthanc <= 1.9.0, this call deletes "dicom-as-json" |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3482 DoPost(_REMOTE, '/tools/invalidate-tags', '', 'text/plain') |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3483 |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3484 if IsOrthancVersionAbove(_REMOTE, 1, 9, 1) and IsDicomUntilPixelDataStored(_REMOTE): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3485 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % a))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3486 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % b))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3487 else: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3488 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % a))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3489 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % b))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3490 |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3491 # In Orthanc <= 1.9.0, this call reconstructs "dicom-as-json" |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3492 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
|
3493 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
|
3494 |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3495 if IsOrthancVersionAbove(_REMOTE, 1, 9, 1) and not IsDicomUntilPixelDataStored(_REMOTE): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3496 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % a))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3497 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/attachments' % b))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3498 else: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3499 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % a))) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
3500 self.assertEqual(2, len(DoGet(_REMOTE, '/instances/%s/attachments' % b))) |
87
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3501 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3502 |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3503 def test_private_tags(self): |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3504 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] |
4b24faec842b
test_reconstruct_json2 + test_private_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
3505 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
|
3506 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
|
3507 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
|
3508 |
92
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3509 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3510 def test_findscu_encoding(self): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3511 # Check out ../Database/Encodings/Generate.sh |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3512 TEST = u'Test-éüäöòДΘĝדصķћ๛ネİ' |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3513 ENCODINGS = { |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3514 'Arabic' : [ 'ISO_IR 127' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3515 'Ascii' : [ 'ISO_IR 6' ], # More accurately, ISO 646 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3516 'Cyrillic' : [ 'ISO_IR 144' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3517 'Greek' : [ 'ISO_IR 126' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3518 'Hebrew' : [ 'ISO_IR 138' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3519 'Japanese' : [ 'ISO_IR 13', 'shift-jis' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3520 'Latin1' : [ 'ISO_IR 100' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3521 'Latin2' : [ 'ISO_IR 101' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3522 'Latin3' : [ 'ISO_IR 109' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3523 'Latin4' : [ 'ISO_IR 110' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3524 'Latin5' : [ 'ISO_IR 148' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3525 'Thai' : [ 'ISO_IR 166', 'tis-620' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3526 'Utf8' : [ 'ISO_IR 192' ], |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3527 } |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3528 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3529 for name in ENCODINGS.iterkeys(): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3530 if len(ENCODINGS[name]) == 1: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3531 ENCODINGS[name].append(name.lower()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3532 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3533 UploadInstance(_REMOTE, 'Encodings/Lena-utf8.dcm') |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3534 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3535 for name in ENCODINGS.iterkeys(): |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3536 self.assertEqual(name, DoPut(_REMOTE, '/tools/default-encoding', name)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3537 self.assertEqual(name, DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3538 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3539 i = CallFindScu([ '-k', '0008,0052=STUDY', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3540 '-k', 'SpecificCharacterSet', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3541 '-k', 'PatientName' ]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3542 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3543 characterSet = re.findall('\(0008,0005\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3544 self.assertEqual(1, len(characterSet)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3545 self.assertEqual(ENCODINGS[name][0], characterSet[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3546 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3547 patientName = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3548 self.assertEqual(1, len(patientName)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3549 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3550 expected = TEST.encode(ENCODINGS[name][1], 'ignore') |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3551 self.assertEqual(expected, patientName[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3552 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3553 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3554 #for master in ENCODINGS: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3555 for master in [ 'Latin1', 'Utf8', 'Cyrillic' ]: # Shortcut to speedup tests |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3556 self.assertEqual(master, DoPut(_REMOTE, '/tools/default-encoding', master)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3557 self.assertEqual(master, DoGet(_REMOTE, '/tools/default-encoding')) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3558 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3559 for name in ENCODINGS: |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3560 DropOrthanc(_REMOTE) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3561 UploadInstance(_REMOTE, 'Encodings/Lena-%s.dcm' % ENCODINGS[name][1]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3562 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3563 i = CallFindScu([ '-k', '0008,0052=STUDY', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3564 '-k', 'PatientID', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3565 '-k', 'SpecificCharacterSet', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3566 '-k', 'PatientName' ]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3567 i = i.decode(ENCODINGS[master][1]) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3568 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3569 characterSet = re.findall('\(0008,0005\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3570 self.assertEqual(1, len(characterSet)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3571 self.assertEqual(ENCODINGS[master][0], characterSet[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3572 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3573 patientId = re.findall('\(0010,0020\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3574 self.assertEqual(1, len(patientId)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3575 self.assertEqual(ENCODINGS[name][1], patientId[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3576 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3577 patientName = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3578 self.assertEqual(1, len(patientName)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3579 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3580 tmp = ENCODINGS[name][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3581 expected = TEST.encode(tmp, 'ignore').decode(tmp) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3582 tmp = ENCODINGS[master][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3583 expected = expected.encode(tmp, 'ignore').decode(tmp) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3584 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3585 self.assertEqual(expected, patientName[0].strip()) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3586 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3587 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3588 a = DoPost(_REMOTE, '/tools/find', { 'Expand' : True, |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3589 'Level' : 'Study', |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3590 'Query' : { }}) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3591 self.assertEqual(1, len(a)) |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3592 |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3593 tmp = ENCODINGS[name][1] |
dbcbffb889da
test_findscu_encoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
3594 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
|
3595 |
314 | 3596 # Back to UTF-8 |
3597 self.assertEqual('Utf8', DoPut(_REMOTE, '/tools/default-encoding', 'Utf8')) | |
3598 | |
96
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3599 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3600 def test_reconstruct(self): |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3601 def CompareMainDicomTag(expected, instance, level, tag): |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3602 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
|
3603 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3604 a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3605 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3606 studies = DoGet(_REMOTE, '/studies/') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3607 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3608 self.assertEqual(1, len(studies)) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3609 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3610 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3611 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3612 modified = DoPost(_REMOTE, '/studies/%s/modify' % studies[0], { |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3613 "Replace" : { |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3614 "StudyDescription" : "hello", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3615 "SeriesDescription" : "world", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3616 "SOPClassUID" : "test", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3617 "SOPInstanceUID" : "myid", |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3618 }, |
119 | 3619 "Keep" : [ "StudyInstanceUID", "SeriesInstanceUID" ], |
3620 "Force" : True | |
96
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3621 }) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3622 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3623 instances = DoGet(_REMOTE, '/instances/') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3624 self.assertEqual(1, len(DoGet(_REMOTE, '/patients/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3625 self.assertEqual(1, len(DoGet(_REMOTE, '/studies/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3626 self.assertEqual(1, len(DoGet(_REMOTE, '/series/'))) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3627 self.assertEqual(2, len(instances)) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3628 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3629 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
|
3630 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3631 CompareMainDicomTag('Knee (R)', a, 'study', 'StudyDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3632 CompareMainDicomTag('AX. FSE PD', a, 'series', 'SeriesDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3633 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
|
3634 CompareMainDicomTag('myid', b, '', 'SOPInstanceUID') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3635 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
|
3636 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
|
3637 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3638 DoPost(_REMOTE, '/instances/%s/reconstruct' % b, {}) |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3639 |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3640 CompareMainDicomTag('hello', a, 'study', 'StudyDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3641 CompareMainDicomTag('world', a, 'series', 'SeriesDescription') |
272d1229cb49
test reconstruction of tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
95
diff
changeset
|
3642 CompareMainDicomTag('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', a, '', 'SOPInstanceUID') |
102 | 3643 |
104 | 3644 def test_httpClient_lua(self): |
3645 with open(GetDatabasePath('Lua/HttpClient.lua'), 'r') as f: | |
102 | 3646 result = DoPost(_REMOTE, '/tools/execute-script', f.read(), 'application/lua') |
3647 | |
3648 self.assertIn('OK', result) | |
107
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3649 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3650 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3651 def test_bitbucket_issue_44(self): |
319 | 3652 # https://bugs.orthanc-server.com/show_bug.cgi?id=44 |
107
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3653 UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3654 UploadInstance(_REMOTE, 'Issue44/Monochrome2.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3655 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3656 # dcmcjpeg +ua +eb Monochrome1.dcm Monochrome1-Jpeg.dcm |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3657 UploadInstance(_REMOTE, 'Issue44/Monochrome1-Jpeg.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3658 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3659 # dcmcjpeg +ua Monochrome1.dcm Monochrome1-JpegLS.dcm |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3660 UploadInstance(_REMOTE, 'Issue44/Monochrome1-JpegLS.dcm') |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3661 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3662 monochrome1 = 'bcdd600a-a6a9c522-5f0a6e84-8657c9f3-b76e59b7' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3663 monochrome1_jpeg = '9df82121-208a2da8-0038674a-3d7a773b-b7008cd2' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3664 monochrome1_jpegls = '0486d1a2-9165573f-b1976b20-e927b016-6b8d67ab' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3665 monochrome2 = 'f00947b7-f61f7164-c93414d1-c6fbda6a-9e92ed20' |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3666 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3667 for i in [ monochrome1, monochrome1_jpeg, monochrome1_jpegls ]: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3668 im = GetImage(_REMOTE, '/instances/%s/preview' % i) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3669 self.assertEqual("L", im.mode) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3670 self.assertEqual(2010, im.size[0]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3671 self.assertEqual(2446, im.size[1]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3672 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3673 # 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
|
3674 # white (255), should be rendered as black (0) => invert |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3675 if i == monochrome1_jpeg: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3676 # Add some tolerance because of JPEG destructive compression |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3677 self.assertGreater(10, im.getpixel((0,0))) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3678 else: |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3679 self.assertEqual(0, im.getpixel((0,0))) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3680 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3681 im = GetImage(_REMOTE, '/instances/%s/preview' % monochrome2) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3682 self.assertEqual("L", im.mode) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3683 self.assertEqual(1572, im.size[0]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3684 self.assertEqual(2010, im.size[1]) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3685 |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3686 # 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
|
3687 # white (255), should be rendered as white (255) |
fddb35f7289d
test_bitbucket_issue_44
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
3688 self.assertEqual(255, im.getpixel((0,0))) |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3689 |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3690 |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3691 def test_bitbucket_issue_42(self): |
319 | 3692 # https://bugs.orthanc-server.com/show_bug.cgi?id=42 |
123 | 3693 # 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
|
3694 UploadInstance(_REMOTE, 'Issue42.dcm')['ID'] |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3695 modified = DoPost(_REMOTE, |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3696 '/patients/da128605-e040d0c4-310615d2-3475da63-df2d1ef4/modify', |
119 | 3697 '{"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
|
3698 'application/json') |
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3699 self.assertTrue('PatientID' in modified) |
113
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3700 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3701 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3702 def test_rest_find_limit(self): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3703 # Check the "Since" and "Limit" parameters in URI "/tools/find" |
319 | 3704 # Related to issue 53: https://bugs.orthanc-server.com/show_bug.cgi?id=53 |
111
7005cdeeb704
test_bitbucket_issue_42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
3705 |
113
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3706 # Upload 6 instances |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3707 brainix = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3708 knee = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3709 for i in range(2): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3710 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
|
3711 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
|
3712 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
|
3713 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3714 # Check using BRAINIX |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3715 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3716 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3717 'Limit' : 10 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3718 self.assertEqual(4, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3719 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3720 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3721 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3722 'Limit' : 4 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3723 self.assertEqual(4, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3724 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3725 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3726 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3727 'Since' : 2, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3728 'Limit' : 4 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3729 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3730 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3731 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3732 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3733 'Limit' : 3 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3734 self.assertEqual(3, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3735 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3736 b = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3737 for i in range(4): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3738 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3739 'Query' : { 'PatientName' : 'B*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3740 'Limit' : 1, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3741 'Since' : i }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3742 self.assertEqual(1, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3743 b.append(a[0]) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3744 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3745 # 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
|
3746 self.assertEqual(0, len(set(b) ^ set(brainix))) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3747 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3748 # Check using KNEE |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3749 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3750 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3751 'Limit' : 10 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3752 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3753 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3754 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3755 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3756 'Limit' : 2 }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3757 self.assertEqual(2, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3758 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3759 b = [] |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3760 for i in range(2): |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3761 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3762 'Query' : { 'PatientName' : 'K*' }, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3763 'Limit' : 1, |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3764 'Since' : i }) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3765 self.assertEqual(1, len(a)) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3766 b.append(a[0]) |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3767 |
3e5934363e76
test_rest_find_limitµ
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
3768 self.assertEqual(0, len(set(b) ^ set(knee))) |
115
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3769 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3770 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3771 def test_bitbucket_issue_46(self): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3772 # "PHI remaining after anonymization" |
319 | 3773 # https://bugs.orthanc-server.com/show_bug.cgi?id=46 |
115
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3774 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3775 def GetAnonymizedTags(study, version): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3776 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3777 { 'DicomVersion' : version }, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3778 'application/json') ['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3779 a = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3780 self.assertEqual(1, len(a)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3781 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3782 instance = a[0]['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3783 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3784 return (instance, DoGet(_REMOTE, '/instances/%s/tags' % instance)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3785 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3786 UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm') |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3787 origStudy = '6068a14b-d4df27af-9ec22145-538772d8-74f228ff' |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3788 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3789 # 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
|
3790 # (Patient's Mother's Birth Name) tags |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3791 newStudy = DoPost(_REMOTE, '/studies/%s/modify' % origStudy, |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3792 '{"Replace":{"0010,1060":"OSIMIS","0032,1033":"MOTHER"}}', |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3793 'application/json')['ID'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3794 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3795 # 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
|
3796 # 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
|
3797 (instance, tags) = GetAnonymizedTags(newStudy, "2008") |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3798 self.assertTrue('0032,1033' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3799 self.assertTrue('0010,1060' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3800 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3801 # 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
|
3802 # 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
|
3803 (instance, tags) = GetAnonymizedTags(newStudy, "2017c") |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3804 self.assertFalse('0032,1033' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3805 self.assertFalse('0010,1060' in tags) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3806 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3807 t = {} |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3808 for (key, value) in tags.iteritems(): |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3809 t[value['Name']] = value['Value'] |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3810 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3811 self.assertEqual('', t['StudyDate']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3812 self.assertEqual('', t['StudyTime']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3813 self.assertEqual('', t['PatientSex']) # Type 1 tag => cleared |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3814 self.assertFalse('SeriesDate' in t) # Type 3 tag => null |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3815 self.assertFalse('SeriesTime' in t) # Type 3 tag => null |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3816 |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3817 with tempfile.NamedTemporaryFile(delete = True) as f: |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3818 # 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
|
3819 f.write(DoGet(_REMOTE, '/instances/%s/file' % instance)) |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3820 f.flush() |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3821 subprocess.check_output([ FindExecutable('dciodvfy'), f.name ], |
45ebfab035b7
test_bitbucket_issue_46
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
3822 stderr = subprocess.STDOUT).split('\n') |
118
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3823 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3824 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3825 def test_bitbucket_issue_55(self): |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3826 def Run(modify, query): |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3827 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3828 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3829 operation = 'modify' if modify else 'anonymize' |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3830 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3831 self.assertRaises(Exception, lambda: DoPost( |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3832 _REMOTE, '/studies/%s/%s' % (study, operation), query)) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3833 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3834 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3835 query["Force"] = True |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3836 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
|
3837 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3838 DoDelete(_REMOTE, a) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3839 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3840 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3841 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3842 UploadInstance(_REMOTE, 'DummyCT.dcm') |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3843 study = 'b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0' |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3844 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3845 Run(True, { "Replace" : { "StudyInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3846 Run(True, { "Replace" : { "SeriesInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3847 Run(True, { "Replace" : { "SOPInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3848 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3849 Run(False, { "Keep" : [ "StudyInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3850 Run(False, { "Keep" : [ "SeriesInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3851 Run(False, { "Keep" : [ "SOPInstanceUID" ]}) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3852 |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3853 Run(False, { "Replace" : { "StudyInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3854 Run(False, { "Replace" : { "SeriesInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3855 Run(False, { "Replace" : { "SOPInstanceUID" : "world" } }) |
a954c535fef6
test_bitbucket_issue_55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
3856 |
120
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3857 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3858 def test_bitbucket_issue_56(self): |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3859 # Case-insensitive matching over accents. This test assumes |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3860 # that the "CaseSensitivePN" configuration option of Orthanc |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3861 # is set to "false" (default value). |
319 | 3862 # https://bugs.orthanc-server.com/show_bug.cgi?id=56 |
120
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3863 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3864 def Check(name, expected, expectedSensitive): |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3865 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
|
3866 '-k', '0008,0052=PATIENT', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3867 '-k', 'PatientName=%s' % name ]) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3868 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', a) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3869 self.assertEqual(expected, len(patientNames)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3870 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3871 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3872 'CaseSensitive' : False, |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3873 'Query' : { 'PatientName' : name }}) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3874 self.assertEqual(expected, len(a)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3875 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3876 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Patient', |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3877 'CaseSensitive' : True, |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3878 'Query' : { 'PatientName' : name }}) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3879 self.assertEqual(expectedSensitive, len(a)) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3880 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3881 UploadInstance(_REMOTE, 'Encodings/Lena-latin1.dcm') |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3882 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3883 # WildcardConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3884 Check('TeSt*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3885 Check('TeSt-a*', 0, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3886 Check('TeSt-É*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3887 Check('TeSt-é*', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3888 Check('Test-é*', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3889 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3890 # ListConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3891 Check('Test-éüäöò\\nope', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3892 Check('Test-ÉÜÄÖÒ\\nope', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3893 |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3894 # ValueConstraint |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3895 Check('Test-éüäöò', 1, 1) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3896 Check('Test-ÉÜÄÖÒ', 1, 0) |
fce08afe6b2d
test_bitbucket_issue_56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
3897 |
125 | 3898 |
3899 def test_gbk_alias(self): | |
3900 # https://groups.google.com/d/msg/orthanc-users/WMM8LMbjpUc/02-1f_yFCgAJ | |
3901 # This test fails on Orthanc <= 1.3.0 | |
3902 i = UploadInstance(_REMOTE, '2017-09-19-GBK-Tumashu.dcm')['ID'] | |
3903 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
3904 self.assertEqual(tags['PatientName'], u'徐浩凯') | |
3905 self.assertEqual(tags['InstitutionName'], u'灌云县疾病预防控制中心') | |
126 | 3906 |
3907 | |
3908 def test_long_tag(self): | |
3909 i = UploadInstance(_REMOTE, 'DummyCTWithLongTag.dcm')['ID'] | |
3910 series = 'f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe' | |
3911 | |
3912 tags = DoGet(_REMOTE, '/instances/%s/tags' % i) | |
3913 self.assertTrue('0018,1020' in tags) | |
3914 self.assertEqual('SoftwareVersions', tags['0018,1020']['Name']) | |
3915 self.assertEqual('TooLong', tags['0018,1020']['Type']) | |
3916 self.assertEqual(None, tags['0018,1020']['Value']) | |
3917 | |
3918 tags = DoGet(_REMOTE, '/instances/%s/tags?ignore-length=0018-1020' % i) | |
3919 self.assertTrue('0018,1020' in tags) | |
3920 self.assertEqual('SoftwareVersions', tags['0018,1020']['Name']) | |
3921 self.assertEqual('String', tags['0018,1020']['Type']) | |
3922 self.assertTrue(tags['0018,1020']['Value'].startswith('Lorem ipsum dolor sit amet')) | |
3923 | |
3924 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
3925 self.assertTrue('SoftwareVersions' in tags) | |
3926 self.assertEqual(None, tags['SoftwareVersions']) | |
3927 self.assertTrue('HeartRate' in tags) | |
3928 self.assertEqual(474, int(tags['HeartRate'])) | |
3929 | |
3930 tags = DoGet(_REMOTE, '/instances/%s/simplified-tags' % i) | |
3931 self.assertTrue('SoftwareVersions' in tags) | |
3932 self.assertEqual(None, tags['SoftwareVersions']) | |
3933 | |
3934 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify&ignore-length=0018-1020' % i) | |
3935 self.assertTrue('SoftwareVersions' in tags) | |
3936 self.assertTrue(tags['SoftwareVersions'].startswith('Lorem ipsum dolor sit amet')) | |
3937 | |
3938 tags = DoGet(_REMOTE, '/instances/%s/tags?simplify&ignore-length=SoftwareVersions' % i) | |
3939 self.assertTrue('SoftwareVersions' in tags) | |
3940 self.assertTrue(tags['SoftwareVersions'].startswith('Lorem ipsum dolor sit amet')) | |
3941 | |
3942 tags = DoGet(_REMOTE, '/series/%s/instances-tags' % series) | |
3943 self.assertEqual(1, len(tags)) | |
3944 self.assertTrue(i in tags.keys()) | |
3945 self.assertTrue('0018,1020' in tags[i]) | |
3946 self.assertEqual('TooLong', tags[i]['0018,1020']['Type']) | |
3947 | |
3948 tags = DoGet(_REMOTE, '/series/%s/instances-tags?ignore-length=SoftwareVersions' % series) | |
3949 self.assertEqual(1, len(tags)) | |
3950 self.assertTrue(i in tags.keys()) | |
3951 self.assertTrue('0018,1020' in tags[i]) | |
3952 self.assertEqual('String', tags[i]['0018,1020']['Type']) | |
3953 self.assertTrue(tags[i]['0018,1020']['Value'].startswith('Lorem ipsum dolor sit amet')) | |
3954 | |
127
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3955 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3956 def test_extended_media(self): |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3957 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3958 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3959 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
|
3960 self.assertEqual(2, len(z.namelist())) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3961 self.assertTrue('IMAGES/IM0' in z.namelist()) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3962 self.assertTrue('DICOMDIR' in z.namelist()) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3963 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3964 try: |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3965 os.remove('/tmp/DICOMDIR') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3966 except: |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3967 # The file does not exist |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3968 pass |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3969 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3970 z.extract('DICOMDIR', '/tmp') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3971 a = subprocess.check_output([ FindExecutable('dciodvfy'), '/tmp/DICOMDIR' ], |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3972 stderr = subprocess.STDOUT).split('\n') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3973 self.assertEqual(5, len(a)) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3974 self.assertTrue(a[0].startswith('Warning')) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3975 self.assertEqual('BasicDirectory', a[1]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3976 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
|
3977 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
|
3978 self.assertEqual('', a[4]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3979 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3980 a = subprocess.check_output([ FindExecutable('dcentvfy'), '/tmp/DICOMDIR' ], |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3981 stderr = subprocess.STDOUT).split('\n') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3982 self.assertEqual(1, len(a)) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3983 self.assertEqual('', a[0]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3984 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3985 a = subprocess.check_output([ FindExecutable('dcm2xml'), '/tmp/DICOMDIR' ]) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3986 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
|
3987 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3988 # Check the presence of the series description (extended tag) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3989 self.assertTrue(re.search('T1W_aTSE', a) != None) |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3990 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3991 os.remove('/tmp/DICOMDIR') |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3992 |
1eea4d3a1ba9
test_extended_media
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
126
diff
changeset
|
3993 |
132
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3994 def test_anonymize_relationships_1(self): |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3995 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
3996 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
|
3997 study = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3998 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
3999 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4000 '{}', |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4001 'application/json')['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4002 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4003 a = DoGet(_REMOTE, '/studies/%s/instances' % study) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4004 self.assertEqual(2, len(a)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4005 a1 = a[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4006 a2 = a[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4007 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4008 b = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4009 self.assertEqual(2, len(b)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4010 b1 = b[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4011 b2 = b[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4012 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4013 SEQUENCE = '/instances/%s/content/ReferencedImageSequence' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4014 SOP = '/instances/%s/content/ReferencedImageSequence/%d/ReferencedSOPInstanceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4015 CLASS = '/instances/%s/content/ReferencedImageSequence/%d/ReferencedSOPClassUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4016 FRAME = '/instances/%s/content/FrameOfReferenceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4017 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4018 self.assertEqual(DoGet(_REMOTE, FRAME % a1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4019 DoGet(_REMOTE, FRAME % a2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4020 self.assertEqual(DoGet(_REMOTE, FRAME % b1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4021 DoGet(_REMOTE, FRAME % b2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4022 self.assertNotEqual(DoGet(_REMOTE, FRAME % a1), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4023 DoGet(_REMOTE, FRAME % b1)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4024 self.assertNotEqual(DoGet(_REMOTE, FRAME % a2), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4025 DoGet(_REMOTE, FRAME % b2)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4026 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4027 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
|
4028 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
|
4029 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
|
4030 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
|
4031 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4032 for i in range(3): |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4033 self.assertEqual(DoGet(_REMOTE, SOP % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4034 DoGet(_REMOTE, SOP % (a2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4035 self.assertEqual(DoGet(_REMOTE, SOP % (b1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4036 DoGet(_REMOTE, SOP % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4037 self.assertNotEqual(DoGet(_REMOTE, SOP % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4038 DoGet(_REMOTE, SOP % (b1, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4039 self.assertNotEqual(DoGet(_REMOTE, SOP % (a2, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4040 DoGet(_REMOTE, SOP % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4041 self.assertEqual(DoGet(_REMOTE, CLASS % (a1, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4042 DoGet(_REMOTE, CLASS % (b1, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4043 self.assertEqual(DoGet(_REMOTE, CLASS % (a2, i)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4044 DoGet(_REMOTE, CLASS % (b2, i))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4045 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4046 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4047 def test_anonymize_relationships_2(self): |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4048 UploadInstance(_REMOTE, 'Comunix/Ct/IM-0001-0001.dcm') |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4049 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
|
4050 study = '6c65289b-db2fcb71-7eaf73f4-8e12470c-a4d6d7cf' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4051 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4052 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4053 '{}', |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4054 'application/json')['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4055 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4056 a = DoGet(_REMOTE, '/studies/%s/instances' % study) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4057 self.assertEqual(2, len(a)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4058 a1 = a[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4059 a2 = a[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4060 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4061 b = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4062 self.assertEqual(2, len(b)) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4063 b1 = b[0]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4064 b2 = b[1]['ID'] |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4065 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4066 SEQUENCE = '/instances/%s/content/SourceImageSequence' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4067 SOP = '/instances/%s/content/SourceImageSequence/%d/ReferencedSOPInstanceUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4068 CLASS = '/instances/%s/content/SourceImageSequence/%d/ReferencedSOPClassUID' |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4069 |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4070 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
|
4071 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
|
4072 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
|
4073 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
|
4074 self.assertEqual(DoGet(_REMOTE, SOP % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4075 DoGet(_REMOTE, SOP % (a2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4076 self.assertEqual(DoGet(_REMOTE, SOP % (b1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4077 DoGet(_REMOTE, SOP % (b2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4078 self.assertNotEqual(DoGet(_REMOTE, SOP % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4079 DoGet(_REMOTE, SOP % (b1, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4080 self.assertNotEqual(DoGet(_REMOTE, SOP % (a2, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4081 DoGet(_REMOTE, SOP % (b2, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4082 self.assertEqual(DoGet(_REMOTE, CLASS % (a1, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4083 DoGet(_REMOTE, CLASS % (b1, 0))) |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4084 self.assertEqual(DoGet(_REMOTE, CLASS % (a2, 0)), |
149144d854bb
Orthanc.test_anonymize_relationships_1/2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
4085 DoGet(_REMOTE, CLASS % (b2, 0))) |
133
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4086 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4087 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4088 def test_anonymize_relationships_3(self): |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4089 sr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/StructuredReports/IM0')['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4090 mr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/StructuredReports/IM631')['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4091 study = 'ef351eb2-c1147229-062736b8-35a151e3-e32d526b' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4092 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4093 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4094 { "Keep" : [ "ContentSequence" ] }) ['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4095 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4096 a = DoGet(_REMOTE, '/studies/%s/instances' % anonymized) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4097 self.assertEqual(2, len(a)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4098 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4099 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
|
4100 sr2 = a[0]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4101 mr2 = a[1]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4102 else: |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4103 sr2 = a[1]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4104 mr2 = a[0]['ID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4105 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4106 self.assertEqual(DoGet(_REMOTE, '/instances/%s/content/Modality' % sr1), |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4107 DoGet(_REMOTE, '/instances/%s/content/Modality' % sr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4108 self.assertEqual(DoGet(_REMOTE, '/instances/%s/content/Modality' % mr1), |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4109 DoGet(_REMOTE, '/instances/%s/content/Modality' % mr2)) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4110 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4111 mrUid1 = DoGet(_REMOTE, '/instances/%s' % mr1)['MainDicomTags']['SOPInstanceUID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4112 mrUid2 = DoGet(_REMOTE, '/instances/%s' % mr2)['MainDicomTags']['SOPInstanceUID'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4113 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
|
4114 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
|
4115 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
|
4116 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
|
4117 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4118 PATH1 = '/instances/%s/content/CurrentRequestedProcedureEvidenceSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4119 PATH2 = PATH1 + '/0/ReferencedSeriesSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4120 PATH3 = PATH2 + '/0/ReferencedSOPSequence' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4121 PATH4 = PATH3 + '/0/ReferencedSOPInstanceUID' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4122 PATH5 = PATH3 + '/0/ReferencedSOPClassUID' |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4123 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4124 self.assertEqual(1, len(DoGet(_REMOTE, PATH1 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4125 self.assertEqual(1, len(DoGet(_REMOTE, PATH2 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4126 self.assertEqual(1, len(DoGet(_REMOTE, PATH3 % sr1))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4127 self.assertEqual(DoGet(_REMOTE, PATH4 % sr1), mrUid1) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4128 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
|
4129 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
|
4130 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4131 self.assertEqual(1, len(DoGet(_REMOTE, PATH1 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4132 self.assertEqual(1, len(DoGet(_REMOTE, PATH2 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4133 self.assertEqual(1, len(DoGet(_REMOTE, PATH3 % sr2))) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4134 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
|
4135 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4136 self.assertEqual(mrUid2, DoGet(_REMOTE, PATH4 % sr2).strip('\x00')) |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4137 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
|
4138 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
|
4139 |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4140 content1 = DoGet(_REMOTE, '/instances/%s/tags?simplify' % sr1) ['ContentSequence'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4141 content2 = DoGet(_REMOTE, '/instances/%s/tags?simplify' % sr2) ['ContentSequence'] |
f0d4c4707e64
test_anonymize_relationships_3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
132
diff
changeset
|
4142 self.assertEqual(str(content1), str(content2)) |
141
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4143 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4144 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4145 def test_bitbucket_issue_94(self): |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4146 # "a simple instance modification should not modify FrameOfReferenceUID + ..." |
319 | 4147 # https://bugs.orthanc-server.com/show_bug.cgi?id=94 |
141
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4148 i = UploadInstance(_REMOTE, 'Issue94.dcm')['ID'] |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4149 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4150 source = DoGet(_REMOTE, '/instances/%s/attachments/dicom/data' % i) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4151 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4152 modified = DoPost(_REMOTE, '/instances/%s/modify' % i, |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4153 { "Replace" : {"PatientID" : "toto"}, "Force": True}) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4154 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4155 anonymized = DoPost(_REMOTE, '/instances/%s/anonymize' % i) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4156 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4157 a = ExtractDicomTags(source, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4158 self.assertEqual(1, len(a)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4159 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4160 b = ExtractDicomTags(modified, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4161 self.assertEqual(1, len(b)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4162 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4163 c = ExtractDicomTags(anonymized, [ 'FrameOfReferenceUID' ]) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4164 self.assertEqual(1, len(c)) |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4165 |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4166 self.assertEqual(a, b) # Modified DICOM |
5de178abe4d8
test_bitbucket_issue_94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
4167 self.assertNotEqual(a, c) # Anonymized DICOM |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4168 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4169 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4170 def test_metadata_origin(self): |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4171 # Upload using the REST API |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4172 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
|
4173 self.assertEqual('RestApi', DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4174 self.assertEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4175 self.assertNotEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteIP' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4176 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/%s/metadata/CalledAET' % i)) |
315 | 4177 |
4178 # "HttpUsername" is empty iff "AuthenticationEnabled" is "false" | |
4179 self.assertTrue(DoGet(_REMOTE, '/instances/%s/metadata/HttpUsername' % i) in [ '', 'alice' ]) | |
4180 | |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4181 m = DoGet(_REMOTE, '/instances/%s/metadata?expand' % i) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4182 self.assertEqual('RestApi', m['Origin']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4183 self.assertEqual('', m['RemoteAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4184 self.assertNotEqual('', m['RemoteIP']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4185 self.assertFalse('CalledAET' in m) |
315 | 4186 self.assertTrue('HttpUsername' in m) |
4187 self.assertTrue(m['HttpUsername'] in [ '', 'alice' ]) | |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4188 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4189 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
|
4190 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
|
4191 self.assertEqual('1', m['IndexInSeries']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4192 self.assertTrue('ReceptionDate' in m) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4193 |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4194 DoDelete(_REMOTE, '/instances/%s' % i) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4195 |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4196 # Upload using the DICOM protocol |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4197 subprocess.check_call([ FindExecutable('storescu'), |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4198 _REMOTE['Server'], str(_REMOTE['DicomPort']), |
144
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4199 GetDatabasePath('Knee/T1/IM-0001-0001.dcm'), |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4200 '-xw' ]) # Propose JPEG2000 |
143
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4201 self.assertEqual('DicomProtocol', DoGet(_REMOTE, '/instances/%s/metadata/Origin' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4202 self.assertEqual('STORESCU', DoGet(_REMOTE, '/instances/%s/metadata/RemoteAET' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4203 self.assertNotEqual('', DoGet(_REMOTE, '/instances/%s/metadata/RemoteIP' % i)) |
28d50ffac07d
test_metadata_origin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
142
diff
changeset
|
4204 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
|
4205 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
|
4206 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4207 m = DoGet(_REMOTE, '/instances/%s/metadata?expand' % i) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4208 self.assertEqual('DicomProtocol', m['Origin']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4209 self.assertEqual('STORESCU', m['RemoteAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4210 self.assertNotEqual('', m['RemoteIP']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4211 self.assertEqual('ANY-SCP', m['CalledAET']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4212 self.assertFalse('HttpUsername' in m) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4213 |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4214 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
|
4215 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
|
4216 self.assertEqual('1', m['IndexInSeries']) |
7809fdf8056f
testing metadata?expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
4217 self.assertTrue('ReceptionDate' in m) |
147 | 4218 |
4219 | |
4220 def test_lua_deadlock(self): | |
4221 # Rana Asim Wajid (2018-07-14): "It does seem that the issue | |
4222 # is with the lua script I'm using for conversion of images to | |
4223 # JPEG2000. When the script is used with 1.4.0 the first | |
4224 # instance appears to be stored and then everything just | |
4225 # halts, ie Orthanc wont respond to anything after that." | |
4226 # https://groups.google.com/d/msg/orthanc-users/Rc-Beb42xc8/JUgdzrmCAgAJ | |
174 | 4227 InstallLuaScriptFromPath(_REMOTE, 'Lua/Jpeg2000Conversion.lua') |
147 | 4228 |
4229 subprocess.check_call([ FindExecutable('storescu'), | |
4230 _REMOTE['Server'], str(_REMOTE['DicomPort']), | |
4231 GetDatabasePath('Brainix/Flair/IM-0001-0001.dcm'), | |
4232 GetDatabasePath('Brainix/Flair/IM-0001-0002.dcm'), | |
4233 ]) | |
4234 | |
4235 instances = DoGet(_REMOTE, '/instances') | |
4236 self.assertEqual(2, len(instances)) | |
4237 | |
4238 t1 = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % instances[0]) | |
4239 t2 = DoGet(_REMOTE, '/instances/%s/metadata/TransferSyntax' % instances[1]) | |
175 | 4240 self.assertEqual('1.2.840.10008.1.2.4.90', t1) # this will fail if libgdcm-tools is not installed |
147 | 4241 self.assertEqual(t1, t2); |
154
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4242 |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4243 |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4244 def test_find_group_length(self): |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4245 # 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
|
4246 # one of the Generic Group Length tags (*, 0x0000) |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4247 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
|
4248 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
|
4249 self.assertFalse('UnableToProcess' in result) |
4a533d003080
test_find_group_length
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
147
diff
changeset
|
4250 self.assertFalse('E:' in result) |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4251 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4252 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4253 def test_split(self): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4254 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4255 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') |
254
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4256 knee1Sop = '1.3.46.670589.11.17521.5.0.3124.2008081908590448738' |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4257 knee2Sop = '1.3.46.670589.11.17521.5.0.3124.2008081909113806560' |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4258 study = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4259 t1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4260 t2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4261 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4262 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4263 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4264 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4265 info = DoGet(_REMOTE, '/studies/%s' % study) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4266 self.assertTrue('ReferringPhysicianName' in info['MainDicomTags']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4267 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4268 job = MonitorJob2(_REMOTE, lambda: DoPost |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4269 (_REMOTE, '/studies/%s/split' % study, { |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4270 'Series' : [ t2 ], |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4271 'Replace' : { 'PatientName' : 'Hello' }, |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4272 'Remove' : [ 'ReferringPhysicianName' ], |
181 | 4273 'KeepSource' : False, |
4274 'Asynchronous' : True | |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4275 })) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4276 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4277 self.assertNotEqual(None, job) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4278 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4279 studies = set(DoGet(_REMOTE, '/studies')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4280 self.assertEqual(2, len(studies)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4281 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4282 series = set(DoGet(_REMOTE, '/series')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4283 self.assertEqual(2, len(series)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4284 self.assertTrue(t1 in series) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4285 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4286 study2 = DoGet(_REMOTE, '/jobs/%s' % job)['Content']['TargetStudy'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4287 self.assertTrue(study in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4288 self.assertTrue(study2 in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4289 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4290 info = DoGet(_REMOTE, '/studies/%s' % study2) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4291 self.assertTrue('Hello', info['PatientMainDicomTags']['PatientName']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4292 self.assertFalse('ReferringPhysicianName' in info['MainDicomTags']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4293 |
254
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4294 sopInstanceUids = set() |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4295 for i in DoGet(_REMOTE, '/instances?expand'): |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4296 sopInstanceUids.add(i['MainDicomTags']['SOPInstanceUID']) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4297 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4298 self.assertTrue(knee1Sop in sopInstanceUids) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4299 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4300 # Fails if Orthanc <= 1.5.7 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4301 self.assertFalse(knee2Sop in sopInstanceUids) # Because "KeepSource" is False |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4302 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4303 # One original instance is kept, another one is added because of the split |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4304 self.assertEqual(2, len(sopInstanceUids)) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4305 |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4306 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4307 def test_merge(self): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4308 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
254
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4309 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4310 kneeSop = '1.3.46.670589.11.17521.5.0.3124.2008081908590448738' |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4311 brainixSop = '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549' |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4312 knee = '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4313 t1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4314 brainix = '27f7126f-4f66fb14-03f4081b-f9341db2-53925988' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4315 flair = '1e2c125c-411b8e86-3f4fe68e-a7584dd3-c6da78f0' |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4316 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4317 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4318 self.assertEqual(2, len(DoGet(_REMOTE, '/series'))) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4319 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4320 job = MonitorJob2(_REMOTE, lambda: DoPost |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4321 (_REMOTE, '/studies/%s/merge' % knee, { |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4322 'Resources' : [ brainix ], |
181 | 4323 'KeepSource' : True, |
4324 'Synchronous' : False | |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4325 })) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4326 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4327 self.assertNotEqual(None, job) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4328 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4329 studies = set(DoGet(_REMOTE, '/studies')) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4330 self.assertEqual(2, len(studies)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4331 self.assertTrue(knee in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4332 self.assertTrue(brainix in studies) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4333 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4334 series = set(DoGet(_REMOTE, '/studies/%s' % knee)['Series']) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4335 self.assertTrue(t1 in series) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4336 series.remove(t1) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4337 self.assertEqual(1, len(series)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4338 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4339 instances = DoGet(_REMOTE, '/series/%s' % list(series)[0])['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4340 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4341 merged = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4342 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4343 instances = DoGet(_REMOTE, '/series/%s' % t1)['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4344 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4345 a = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4346 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4347 instances = DoGet(_REMOTE, '/series/%s' % flair)['Instances'] |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4348 self.assertEqual(1, len(instances)) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4349 b = DoGet(_REMOTE, '/instances/%s/tags?simplify' % instances[0]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4350 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4351 tags = DoGet(_REMOTE, '/studies/%s' % knee) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4352 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4353 for key in tags['PatientMainDicomTags']: |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4354 self.assertEqual(a[key], merged[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4355 if (key in b and key != 'PatientSex'): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4356 self.assertNotEqual(a[key], b[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4357 |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4358 for key in tags['MainDicomTags']: |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4359 # Not in the patient/study module |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4360 if (not key in [ 'InstitutionName', |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4361 'RequestingPhysician', |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4362 'RequestedProcedureDescription', ]): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4363 self.assertEqual(a[key], merged[key]) |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4364 if (key in b): |
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4365 self.assertNotEqual(a[key], b[key]) |
254
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4366 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4367 sopInstanceUids = set() |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4368 for i in DoGet(_REMOTE, '/instances?expand'): |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4369 sopInstanceUids.add(i['MainDicomTags']['SOPInstanceUID']) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4370 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4371 self.assertTrue(kneeSop in sopInstanceUids) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4372 self.assertTrue(brainixSop in sopInstanceUids) |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4373 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4374 # Fails if Orthanc <= 1.5.7 |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4375 # The 2 original instances are kept, another one is added because of the merge |
05b77ade5e1d
test generation of sopinstanceuid in split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
247
diff
changeset
|
4376 self.assertEqual(3, len(sopInstanceUids)) |
179
8a2dd77d4035
testing split/merge
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
177
diff
changeset
|
4377 |
187 | 4378 |
4379 def test_async_archive(self): | |
4380 # Testing the asynchronous generation of archives/medias (new | |
4381 # in Orthanc 1.4.3) | |
4382 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | |
4383 UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm') | |
4384 | |
4385 kneeT1 = '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' | |
4386 kneeT2 = 'bbf7a453-0d34251a-03663b55-46bb31b9-ffd74c59' | |
4387 | |
4388 job = MonitorJob2(_REMOTE, lambda: DoPost | |
4389 (_REMOTE, '/studies/%s/archive' % kneeT1, { | |
4390 'Synchronous' : False | |
4391 })) | |
4392 | |
4393 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4394 self.assertEqual(1, len(z.namelist())) | |
4395 self.assertFalse('DICOMDIR' in z.namelist()) | |
4396 | |
354
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4397 info = DoGet(_REMOTE, '/jobs/%s' % job) |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4398 self.assertEqual(0, info['Content']['ArchiveSizeMB']) # New in Orthanc 1.8.1 |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4399 self.assertEqual(1, info['Content']['InstancesCount']) |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4400 self.assertEqual(0, info['Content']['UncompressedSizeMB']) |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4401 |
187 | 4402 job2 = MonitorJob2(_REMOTE, lambda: DoPost |
4403 (_REMOTE, '/studies/%s/media' % kneeT1, { | |
4404 'Synchronous' : False | |
4405 })) | |
4406 | |
4407 # The archive from the first job has been replaced by the | |
4408 # archive from second job (as MediaArchiveSize == 1) | |
4409 self.assertRaises(Exception, lambda: GetArchive(_REMOTE, '/jobs/%s/archive' % job)) | |
4410 | |
4411 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job2) | |
4412 self.assertEqual(2, len(z.namelist())) | |
4413 self.assertTrue('DICOMDIR' in z.namelist()) | |
4414 | |
354
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4415 info = DoGet(_REMOTE, '/jobs/%s' % job2) |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4416 self.assertEqual(0, info['Content']['ArchiveSizeMB']) # New in Orthanc 1.8.1 |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4417 self.assertEqual(1, info['Content']['InstancesCount']) |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4418 self.assertEqual(0, info['Content']['UncompressedSizeMB']) |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4419 |
187 | 4420 job = MonitorJob2(_REMOTE, lambda: DoPost |
4421 (_REMOTE, '/tools/create-archive', { | |
4422 'Synchronous' : False, | |
4423 'Resources' : [ kneeT1, kneeT2 ], | |
4424 })) | |
4425 | |
4426 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4427 self.assertEqual(2, len(z.namelist())) | |
4428 self.assertFalse('DICOMDIR' in z.namelist()) | |
4429 | |
354
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4430 info = DoGet(_REMOTE, '/jobs/%s' % job) |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4431 self.assertEqual(0, info['Content']['ArchiveSizeMB']) # New in Orthanc 1.8.1 |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4432 self.assertEqual(2, info['Content']['InstancesCount']) |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4433 self.assertEqual(0, info['Content']['UncompressedSizeMB']) |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4434 |
187 | 4435 job = MonitorJob2(_REMOTE, lambda: DoPost |
4436 (_REMOTE, '/tools/create-media', { | |
4437 'Synchronous' : False, | |
4438 'Resources' : [ kneeT1, kneeT2 ], | |
4439 })) | |
4440 | |
4441 z = GetArchive(_REMOTE, '/jobs/%s/archive' % job) | |
4442 self.assertEqual(3, len(z.namelist())) | |
4443 self.assertTrue('DICOMDIR' in z.namelist()) | |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4444 |
354
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4445 self.assertEqual(0, info['Content']['ArchiveSizeMB']) # New in Orthanc 1.8.1 |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4446 self.assertEqual(2, info['Content']['InstancesCount']) |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4447 self.assertEqual(0, info['Content']['UncompressedSizeMB']) |
88f076b906ca
test ArchiveSizeMB in archive jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
353
diff
changeset
|
4448 |
187 | 4449 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4450 def test_queries_hierarchy(self): |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4451 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4452 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
|
4453 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4454 tags = { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4455 'NumberOfPatientRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4456 'NumberOfPatientRelatedSeries' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4457 'NumberOfPatientRelatedStudies' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4458 'NumberOfStudyRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4459 'NumberOfStudyRelatedSeries' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4460 'NumberOfSeriesRelatedInstances' : '', |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4461 } |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4462 |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4463 tags2 = copy.copy(tags) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4464 tags2['PatientID'] = '887' # Only consider the "Knee" patient |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4465 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4466 patient = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4467 'Level' : 'Patient', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4468 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4469 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4470 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4471 study = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4472 'Level' : 'Study', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4473 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4474 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4475 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4476 series = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4477 'Level' : 'Series', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4478 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4479 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4480 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4481 instance = DoPost(_REMOTE, '/modalities/self/query', { |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4482 'Level' : 'Instance', |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4483 'Query' : tags2 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4484 }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4485 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4486 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
|
4487 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4488 self.assertEqual('887', p[0]['PatientID']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4489 self.assertEqual('1', p[0]['NumberOfPatientRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4490 self.assertEqual('1', p[0]['NumberOfPatientRelatedSeries']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4491 self.assertEqual('1', p[0]['NumberOfPatientRelatedStudies']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4492 self.assertFalse('NumberOfStudyRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4493 self.assertFalse('NumberOfStudyRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4494 self.assertFalse('NumberOfSeriesRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4495 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4496 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
|
4497 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4498 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
|
4499 self.assertEqual('1', p[0]['NumberOfStudyRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4500 self.assertEqual('1', p[0]['NumberOfStudyRelatedSeries']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4501 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4502 self.assertFalse('NumberOfPatientRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4503 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4504 self.assertFalse('NumberOfSeriesRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4505 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4506 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
|
4507 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4508 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
|
4509 self.assertEqual('1', p[0]['NumberOfSeriesRelatedInstances']) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4510 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4511 self.assertFalse('NumberOfPatientRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4512 self.assertFalse('NumberOfPatientRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4513 self.assertFalse('NumberOfStudyRelatedInstances' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4514 self.assertFalse('NumberOfStudyRelatedSeries' in p[0]) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4515 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4516 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
|
4517 self.assertEqual(1, len(p)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4518 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
|
4519 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4520 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
|
4521 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4522 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
|
4523 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % study)) |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4524 |
188
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4525 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
|
4526 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4527 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
|
4528 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % series)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4529 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4530 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
|
4531 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4532 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
|
4533 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4534 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4535 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
|
4536 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4537 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
|
4538 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % series)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4539 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4540 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
|
4541 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4542 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
|
4543 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4544 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4545 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
|
4546 { 'Query' : tags }) ['ID'] |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4547 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
|
4548 DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % instance)) |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4549 |
7d585263808b
new test: test_queries_hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
4550 |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4551 def test_dicom_disk_size(self): |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4552 dicomSize = 0 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4553 |
379
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
4554 a = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm') ['ID'] |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
4555 isCompressed = (DoGet(_REMOTE, '/instances/%s/attachments/dicom/is-compressed' % a) != 0) |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4556 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4557 for i in range(2): |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4558 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
|
4559 UploadInstance(_REMOTE, p) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4560 dicomSize += os.path.getsize(GetDatabasePath(p)) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4561 |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4562 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
|
4563 self.assertEqual(2, s['CountInstances']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4564 self.assertEqual(2, s['CountSeries']) |
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4565 self.assertEqual(1, s['CountStudies']) |
379
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
4566 |
189
11719f19bd62
test_dicom_disk_size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
188
diff
changeset
|
4567 self.assertEqual(dicomSize, int(s['DicomUncompressedSize'])) |
379
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
4568 |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
4569 if isCompressed: |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
4570 self.assertGreater(dicomSize, int(s['DicomDiskSize'])) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
4571 self.assertGreater(s['UncompressedSize'], s['DiskSize']) |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
4572 self.assertLess(dicomSize, int(s['UncompressedSize'])) |
379
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
4573 else: |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
4574 self.assertEqual(dicomSize, int(s['DicomDiskSize'])) |
097329b67509
fix tests if StorageCompression is true
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
4575 self.assertEqual(s['UncompressedSize'], s['DiskSize']) |
380
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
4576 if IsOrthancVersionAbove(_REMOTE, 1, 9, 1): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
4577 if IsDicomUntilPixelDataStored(_REMOTE): |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
4578 self.assertLess(dicomSize, int(s['UncompressedSize'])) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
4579 else: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
4580 self.assertEqual(dicomSize, int(s['UncompressedSize'])) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
4581 else: |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
4582 # In Orthanc <= 1.9.0, there is the "dicom-as-json" |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
4583 # attachment in addition to the DICOM file |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
4584 self.assertLess(dicomSize, int(s['UncompressedSize'])) |
b9adc7d06347
update tests following removal of dicom-as-json attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
4585 |
202
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4586 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4587 def test_changes_2(self): |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4588 # 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
|
4589 # 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
|
4590 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4591 # 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
|
4592 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
|
4593 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
|
4594 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
|
4595 DoDelete(_REMOTE, '/instances/%s' % a) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4596 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4597 # 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
|
4598 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
|
4599 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4600 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4601 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
|
4602 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4603 seq = c['Last'] |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4604 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4605 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4606 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
|
4607 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4608 self.assertEqual(seq, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4609 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4610 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
|
4611 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
|
4612 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4613 self.assertEqual(seq, c['Last']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4614 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4615 # Add one instance |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4616 UploadInstance(_REMOTE, 'DummyCT.dcm') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4617 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
|
4618 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4619 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4620 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
|
4621 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4622 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
|
4623 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4624 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4625 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
|
4626 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4627 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
|
4628 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4629 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
|
4630 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
|
4631 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4632 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
|
4633 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4634 # Remove the uploaded instance |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4635 DoDelete(_REMOTE, '/instances/%s' % a) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4636 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
|
4637 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4638 c = DoGet(_REMOTE, '/changes') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4639 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
|
4640 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4641 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
|
4642 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4643 c = DoGet(_REMOTE, '/changes?last') |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4644 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
|
4645 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4646 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
|
4647 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4648 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
|
4649 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
|
4650 self.assertTrue(c['Done']) |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4651 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
|
4652 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4653 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4654 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
|
4655 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
|
4656 |
f26f9ae9c599
test_changes_2 and test_bitbucket_issue_124
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
4657 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
|
4658 self.assertEqual(2, len(z.namelist())) |
207
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4659 |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4660 |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4661 def test_invalid_findscp(self): |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4662 UploadInstance(_REMOTE, 'DummyCT.dcm') |
a515eec74078
test_invalid_findscp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
4663 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
|
4664 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
|
4665 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4666 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4667 def test_bitbucket_issue_90(self): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4668 def CountDicomResults(sex): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4669 a = CallFindScu([ '-S', '-k', '8,52=STUDY', '-k', sex ]) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4670 return len(re.findall('\(0010,0040\)', a)) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4671 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4672 def CountRestResults(sex): |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4673 a = DoPost(_REMOTE, '/tools/find', |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4674 { 'Level' : 'Study', 'Query' : { 'PatientSex' : sex } }) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4675 return len(a) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4676 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4677 # 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
|
4678 # "DummyCT.dcm" has the tag PatientSex (0010,0040) unset |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4679 UploadInstance(_REMOTE, 'DummyCT.dcm') |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4680 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4681 # 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
|
4682 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4683 # 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
|
4684 self.assertEqual(0, CountDicomResults('PatientSex=*')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4685 self.assertEqual(0, CountRestResults('*')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4686 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4687 # 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
|
4688 self.assertEqual(0, CountDicomResults('PatientSex=F')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4689 self.assertEqual(0, CountDicomResults('PatientSex=M')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4690 self.assertEqual(0, CountRestResults('F')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4691 self.assertEqual(0, CountRestResults('M')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4692 |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4693 # 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
|
4694 # 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
|
4695 # as a filter in such a situation. |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4696 self.assertEqual(1, CountDicomResults('PatientSex')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4697 self.assertEqual(1, CountDicomResults('PatientSex=')) |
2444c9a7c422
test_bitbucket_issue_90
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
207
diff
changeset
|
4698 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
|
4699 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4700 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4701 def test_rest_modalities_in_study(self): |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4702 # 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
|
4703 # 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
|
4704 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4705 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4706 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4707 'Query' : { 'ModalitiesInStudy' : 'US' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4708 self.assertEqual(0, len(a)) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4709 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4710 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4711 'Query' : { 'ModalitiesInStudy' : 'US\\CT' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4712 self.assertEqual(1, len(a)) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4713 |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4714 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4715 'Query' : { 'ModalitiesInStudy' : 'CT' }}) |
2c50c8f340c2
test_rest_modalities_in_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
208
diff
changeset
|
4716 self.assertEqual(1, len(a)) |
211 | 4717 |
4718 | |
4719 def test_series_status(self): | |
4720 def HasCompletedInChanges(): | |
4721 for c in DoGet(_REMOTE, '/changes?limit=1000&since=0')['Changes']: | |
4722 if c['ChangeType'] == 'CompletedSeries': | |
4723 return True; | |
4724 | |
4725 return False | |
4726 | |
4727 UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm') | |
4728 series = '8ea120d7-5057d919-837dfbcc-ccd04e0f-7f3a94aa' | |
4729 self.assertEqual('Unknown', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4730 self.assertFalse(HasCompletedInChanges()) | |
4731 | |
4732 series = 'ce25ecb6-ed79d004-5ae43ca7-3fc89bc5-67511614' | |
4733 | |
4734 for i in range(3): | |
4735 UploadInstance(_REMOTE, 'Series/Lena-%d.dcm' % (i + 1)) | |
4736 self.assertEqual('Missing', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4737 self.assertFalse(HasCompletedInChanges()) | |
4738 | |
4739 UploadInstance(_REMOTE, 'Series/Lena-4.dcm') | |
4740 self.assertEqual('Complete', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4741 self.assertTrue(HasCompletedInChanges()) | |
4742 | |
4743 DoDelete(_REMOTE, '/changes') | |
4744 self.assertFalse(HasCompletedInChanges()) | |
4745 | |
4746 UploadInstance(_REMOTE, 'Series/Lena-5.dcm') | |
4747 self.assertEqual('Inconsistent', DoGet(_REMOTE, '/series/%s' % series)['Status']) | |
4748 self.assertFalse(HasCompletedInChanges()) | |
4749 | |
215 | 4750 |
4751 def test_dicomweb(self): | |
4752 def Compare(dicom, reference): | |
4753 a = UploadInstance(_REMOTE, dicom) ['ID'] | |
4754 b = DoGet(_REMOTE, '/instances/%s/file' % a, | |
4755 headers = { 'Accept' : 'application/dicom+json' }) | |
4756 with open(GetDatabasePath(reference), 'rb') as c: | |
4757 d = json.load(c) | |
220 | 4758 AssertAlmostEqualRecursive(self, d, b) |
215 | 4759 |
4760 Compare('DummyCT.dcm', 'DummyCT.json') | |
4761 Compare('MarekLatin2.dcm', 'MarekLatin2.json') | |
4762 Compare('HierarchicalAnonymization/StructuredReports/IM0', | |
4763 'HierarchicalAnonymization/StructuredReports/IM0.json') | |
217 | 4764 |
4765 | |
4766 def test_issue_95_encodings(self): | |
319 | 4767 # https://bugs.orthanc-server.com/show_bug.cgi?id=95 |
217 | 4768 # Check out image: "../Database/Encodings/DavidClunie/charsettests.screenshot.png" |
4769 | |
4770 # Very useful tool: "file2" from package "file-kanji" | |
4771 | |
4772 def GetPatientName(dicom): | |
4773 i = UploadInstance(_REMOTE, dicom) ['ID'] | |
4774 j = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) | |
4775 return j['PatientName'] | |
4776 | |
4777 def ComparePatientName(name, dicom): | |
4778 self.assertEqual(name, GetPatientName(dicom)) | |
4779 | |
4780 # gdcmraw -t 10,10 -i SCSFREN -o /tmp/tag && uconv -f ISO-IR-100 -t UTF-8 /tmp/tag && echo | |
4781 ComparePatientName(u'Buc^Jérôme', 'Encodings/DavidClunie/SCSFREN') | |
4782 | |
4783 # gdcmraw -t 10,10 -i SCSI2 -o /tmp/tag && uconv -f KOREAN -t UTF-8 /tmp/tag && echo | |
4784 ComparePatientName(u'Hong^Gildong=洪^吉洞=홍^길동', 'Encodings/DavidClunie/SCSI2') # Since Orthanc 1.5.5 | |
4785 | |
4786 # gdcmraw -t 10,10 -i SCSX2 -o /tmp/tag && uconv -f GB18030 -t UTF-8 /tmp/tag && echo | |
4787 ComparePatientName(u'Wang^XiaoDong=王^小东=', 'Encodings/DavidClunie/SCSX2') | |
4788 | |
4789 # gdcmraw -t 10,10 -i SCSX1 -o /tmp/tag && cat /tmp/tag && echo | |
4790 ComparePatientName(u'Wang^XiaoDong=王^小東=', 'Encodings/DavidClunie/SCSX1') | |
4791 | |
4792 # gdcmraw -t 10,10 -i SCSH31 -o /tmp/tag && uconv -f JIS -t UTF-8 /tmp/tag && echo | |
4793 ComparePatientName(u'Yamada^Tarou=山田^太郎=やまだ^たろう', 'Encodings/DavidClunie/SCSH31') | |
4794 | |
4795 # gdcmraw -t 10,10 -i SCSGERM -o /tmp/tag && uconv -f ISO-IR-100 -t UTF-8 /tmp/tag && echo | |
4796 ComparePatientName(u'Äneas^Rüdiger', 'Encodings/DavidClunie/SCSGERM') | |
4797 | |
4798 # gdcmraw -t 10,10 -i SCSGREEK -o /tmp/tag && uconv -f ISO-IR-126 -t UTF-8 /tmp/tag && echo | |
4799 ComparePatientName(u'Διονυσιος', 'Encodings/DavidClunie/SCSGREEK') | |
4800 | |
4801 # gdcmraw -t 10,10 -i SCSRUSS -o /tmp/tag && uconv -f ISO-IR-144 -t UTF-8 /tmp/tag && echo | |
4802 ComparePatientName(u'Люкceмбypг', 'Encodings/DavidClunie/SCSRUSS') | |
4803 | |
4804 # gdcmraw -t 10,10 -i SCSHBRW -o /tmp/tag && uconv -f ISO-IR-138 -t UTF-8 /tmp/tag && echo | |
4805 # NB: Hebrew is a right-to-left encoding, copying/pasting from | |
4806 # Linux console into Emacs automatically reverse the string | |
4807 ComparePatientName(u'שרון^דבורה', 'Encodings/DavidClunie/SCSHBRW') | |
4808 | |
4809 # gdcmraw -t 10,10 -i SCSARAB -o /tmp/tag && uconv -f ISO-IR-127 -t UTF-8 /tmp/tag && echo | |
4810 # NB: Right-to-left as for Hebrew (SCSHBRW), and the Ubuntu console can't display such | |
4811 # characters by default, but copy/paste works with Emacs | |
4812 ComparePatientName(u'قباني^لنزار', 'Encodings/DavidClunie/SCSARAB') | |
4813 | |
4814 # SCSH32: This SpecificCharacterSet is composed of 2 | |
4815 # codepages: "ISO 2022 IR 13" (i.e. "SHIFT_JIS") until the | |
4816 # first equal, then "ISO 2022 IR 87" (i.e. "JIS") for the | |
4817 # remainer. Orthanc only takes into consideration the first | |
4818 # codepage: This is a limitation. | |
4819 # gdcmraw -t 10,10 -i SCSH32 -o /tmp/tag && cut -d '=' -f 1 /tmp/tag | uconv -f SHIFT_JIS -t UTF-8 | |
4820 self.assertTrue(GetPatientName('Encodings/DavidClunie/SCSH32').startswith(u'ヤマダ^タロウ=')) | |
218
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4821 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4822 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4823 def test_findscu_missing_tags(self): |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4824 # dcmodify -e Rows DummyCTInvalidRows.dcm -gst -gse -gin |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4825 UploadInstance(_REMOTE, 'DummyCT.dcm') |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4826 UploadInstance(_REMOTE, 'DummyCTInvalidRows.dcm') |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4827 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4828 i = CallFindScu([ '-k', '0008,0052=IMAGES', '-k', 'Rows', '-k', 'PatientName' ]) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4829 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4830 # We have 2 instances... |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4831 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4832 self.assertEqual(2, len(patientNames)) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4833 self.assertEqual('KNIX', patientNames[0]) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4834 self.assertEqual('KNIX', patientNames[1]) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4835 |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4836 # ...but only 1 value for the "Rows" tag |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4837 rows = re.findall('\(0028,0010\) US ([0-9]+)', i) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4838 self.assertEqual(1, len(rows)) |
70fba41776be
test_findscu_missing_tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
217
diff
changeset
|
4839 self.assertEqual('512', rows[0]) |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4840 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4841 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4842 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4843 def test_bitbucket_issue_131(self): |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4844 # "Orthanc PACS silently fails to C-MOVE due to duplicate |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4845 # StudyInstanceUID in it's database." |
319 | 4846 # https://bugs.orthanc-server.com/show_bug.cgi?id=131 |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4847 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4848 # Insert 2 instances, with the same StudyInstanceUID, but with |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4849 # different patient IDs. Orthanc will create 2 distincts |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4850 # patients, and the hierarchy of resources above the two |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4851 # instances will be fully disjoint. |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4852 UploadInstance(_REMOTE, 'PatientIdsCollision/Issue131-a.dcm') |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4853 UploadInstance(_REMOTE, 'PatientIdsCollision/Issue131-b.dcm') |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4854 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4855 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4856 self.assertEqual(2, len(DoGet(_REMOTE, '/studies'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4857 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4858 a = DoPost(_REMOTE, '/modalities/self/query', { |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4859 'Level' : 'Study', |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4860 'Query' : {"PatientID": "A" }})['ID'] |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4861 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4862 # 1 study is matched |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4863 self.assertEqual(1, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4864 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4865 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
220 | 4866 WaitAllNewJobsDone(_REMOTE, lambda: DoPost |
4867 (_REMOTE, '/queries/%s/retrieve' % a, | |
4868 '{"TargetAet":"ORTHANCTEST","Synchronous":false}')) | |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4869 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4870 # The two studies are matched, as we made the request at the |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4871 # Study level, thus the shared StudyInstanceUID is used as the key |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4872 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4873 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4874 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4875 # Match the 2 studies |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4876 a = DoPost(_REMOTE, '/modalities/self/query', { |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4877 'Level' : 'Study', |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4878 'Query' : {"StudyInstanceUID": "2.25.123" }})['ID'] |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4879 self.assertEqual(2, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4880 DropOrthanc(_LOCAL) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4881 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
220 | 4882 WaitAllNewJobsDone(_REMOTE, lambda: DoPost |
4883 (_REMOTE, '/queries/%s/retrieve' % a, | |
4884 '{"TargetAet":"ORTHANCTEST","Synchronous":false}')) | |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4885 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4886 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4887 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4888 # Same test, at the patient level => only 1 instance is transfered |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4889 a = DoPost(_REMOTE, '/modalities/self/query', { |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4890 'Level' : 'Patient', |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4891 'Query' : {"PatientID": "A" }})['ID'] |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4892 self.assertEqual(1, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4893 DropOrthanc(_LOCAL) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4894 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
220 | 4895 WaitAllNewJobsDone(_REMOTE, lambda: DoPost |
4896 (_REMOTE, '/queries/%s/retrieve' % a, | |
4897 '{"TargetAet":"ORTHANCTEST","Synchronous":false}')) | |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4898 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4899 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4900 |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4901 # Same test, at the series level => only 1 instance is transfered |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4902 a = DoPost(_REMOTE, '/modalities/self/query', { |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4903 'Level' : 'Series', |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4904 'Query' : {"PatientID": "A" }})['ID'] |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4905 self.assertEqual(1, len(DoGet(_REMOTE, '/queries/%s/answers' % a))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4906 DropOrthanc(_LOCAL) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4907 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
220 | 4908 WaitAllNewJobsDone(_REMOTE, lambda: DoPost |
4909 (_REMOTE, '/queries/%s/retrieve' % a, | |
4910 '{"TargetAet":"ORTHANCTEST","Synchronous":false}')) | |
219
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4911 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
00e5aeea33dd
test_bitbucket_issue_131
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
4912 |
233
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4913 |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4914 def test_bitbucket_issue_136(self): |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4915 UploadInstance(_REMOTE, 'Issue137.dcm') |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4916 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', '0010,0010', '-k', '0028,0010', '-k', '0040,0275' ]) |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4917 patientNames = re.findall('\(0010,0010\).*?\[(.*?)\]', i) |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4918 self.assertEqual(1, len(patientNames)) |
ce0b19a2c807
test_bitbucket_issue_136
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
4919 self.assertEqual('John Doe', patientNames[0]) |
234
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4920 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4921 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4922 def test_anonymize_relationships_4(self): |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4923 # https://groups.google.com/d/msg/orthanc-users/UkcsqyTpszE/bXUpzU0vAAAJ |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4924 sr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/2019-03-28/CR000000.dcm')['ID'] |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4925 mr1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/2019-03-28/PR000000.dcm')['ID'] |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4926 study = '0c923249-d52121a9-2b7167f7-6b85534f-0943697e' |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4927 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4928 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, '{}', |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4929 'application/json')['ID'] |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4930 series = DoGet(_REMOTE, '/studies/%s/series' % anonymized) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4931 self.assertEqual(2, len(series)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4932 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4933 cr = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'CR', series)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4934 pr = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'PR', series)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4935 self.assertEqual(1, len(cr)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4936 self.assertEqual(1, len(pr)) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4937 self.assertEqual(1, len(cr[0]['Instances'])) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4938 self.assertEqual(1, len(pr[0]['Instances'])) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4939 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4940 crinstance = DoGet(_REMOTE, '/instances/%s' % cr[0]['Instances'][0]) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4941 tags = DoGet(_REMOTE, '/instances/%s/tags?short' % pr[0]['Instances'][0]) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4942 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4943 self.assertEqual(tags['0008,1115'][0]['0008,1140'][0]['0008,1155'], |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4944 crinstance['MainDicomTags']['SOPInstanceUID']) |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4945 self.assertEqual(tags['0008,1115'][0]['0008,1140'][0]['0008,1150'], |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4946 '1.2.840.10008.5.1.4.1.1.1') # SOP class for CR Image Storage |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4947 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4948 # This fails on Orthanc <= 1.5.6 |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4949 self.assertEqual(tags['0008,1115'][0]['0020,000e'], |
93cd4fdd4a67
test_anonymize_relationships_4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
4950 cr[0]['MainDicomTags']['SeriesInstanceUID']) |
235
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4951 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
4952 |
255
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4953 def test_anonymize_relationships_5(self): |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4954 ct1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/RTH/CT01.dcm') |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4955 rt1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/RTH/RT.dcm') |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4956 oStudyId = ct1['ParentStudy'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4957 oCtInstanceId = ct1['ID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4958 oRtInstanceId = rt1['ID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4959 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4960 oCtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % oCtInstanceId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4961 oRtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % oRtInstanceId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4962 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4963 # first validate the relationships in the source data |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4964 oStudyUID = oCtTags['StudyInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4965 oRtSeriesUID = oRtTags['SeriesInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4966 oRtInstanceUID = oRtTags['SOPInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4967 oRtFrameOfReferenceUID = oRtTags['ReferencedFrameOfReferenceSequence'][0]['FrameOfReferenceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4968 oCtSeriesUID = oCtTags['SeriesInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4969 oCtInstanceUID = oCtTags['SOPInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4970 oCtFrameOfReferenceUID = oCtTags['FrameOfReferenceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4971 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4972 oContourSequenceCount = len(oRtTags['ROIContourSequence'][0]['ContourSequence']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4973 self.assertEqual(oCtFrameOfReferenceUID, oRtFrameOfReferenceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4974 self.assertEqual(oStudyUID, oRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4975 self.assertEqual(oCtSeriesUID, oRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['RTReferencedSeriesSequence'][0]['SeriesInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4976 self.assertEqual(oCtInstanceUID, oRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['RTReferencedSeriesSequence'][0]['ContourImageSequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4977 self.assertEqual(oCtInstanceUID, oRtTags['ROIContourSequence'][0]['ContourSequence'][oContourSequenceCount-1]['ContourImageSequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4978 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4979 ### anonymize |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4980 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4981 aStudyId = DoPost(_REMOTE, '/studies/%s/anonymize' % oStudyId, '{}', |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4982 'application/json')['ID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4983 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4984 ### validate |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4985 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4986 aSeries = DoGet(_REMOTE, '/studies/%s/series' % aStudyId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4987 self.assertEqual(2, len(aSeries)) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4988 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4989 aCt = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'CT', aSeries)) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4990 aRt = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'RTSTRUCT', aSeries)) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4991 aCtInstanceId = aCt[0]['Instances'][0] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4992 aRtInstanceId = aRt[0]['Instances'][0] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4993 aCtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % aCtInstanceId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4994 aRtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % aRtInstanceId) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4995 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4996 # now validate the relationships in the anonymized data |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4997 aStudyUID = aCtTags['StudyInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4998 aRtSeriesUID = aRtTags['SeriesInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
4999 aRtInstanceUID = aRtTags['SOPInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5000 aRtFrameOfReferenceUID = aRtTags['ReferencedFrameOfReferenceSequence'][0]['FrameOfReferenceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5001 aCtSeriesUID = aCtTags['SeriesInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5002 aCtInstanceUID = aCtTags['SOPInstanceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5003 aCtFrameOfReferenceUID = aCtTags['FrameOfReferenceUID'] |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5004 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5005 aContourSequenceCount = len(aRtTags['ROIContourSequence'][0]['ContourSequence']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5006 # make sure all UIDs have been updated |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5007 self.assertNotEqual(oStudyUID, aStudyUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5008 self.assertNotEqual(oRtSeriesUID, aRtSeriesUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5009 self.assertNotEqual(oRtInstanceUID, aRtInstanceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5010 self.assertNotEqual(oRtFrameOfReferenceUID, aRtFrameOfReferenceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5011 self.assertNotEqual(oCtSeriesUID, aCtSeriesUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5012 self.assertNotEqual(oCtInstanceUID, aCtInstanceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5013 self.assertNotEqual(oCtFrameOfReferenceUID, aCtFrameOfReferenceUID) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5014 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5015 # validate the relationships |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5016 self.assertEqual(oContourSequenceCount, aContourSequenceCount) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5017 self.assertEqual(aCtFrameOfReferenceUID, aRtFrameOfReferenceUID) |
256 | 5018 self.assertEqual(aStudyUID, aRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['ReferencedSOPInstanceUID']) |
5019 self.assertEqual(aCtSeriesUID, aRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['RTReferencedSeriesSequence'][0]['SeriesInstanceUID']) | |
255
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5020 self.assertEqual(aCtInstanceUID, aRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['RTReferencedSeriesSequence'][0]['ContourImageSequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5021 self.assertEqual(aCtInstanceUID, aRtTags['ROIContourSequence'][0]['ContourSequence'][aContourSequenceCount-1]['ContourImageSequence'][0]['ReferencedSOPInstanceUID']) |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5022 |
256 | 5023 def test_anonymize_relationships_5b(self): |
5024 # same test as previous one but, this time, we force the StudyInstanceUID | |
5025 ct1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/RTH/CT01.dcm') | |
5026 rt1 = UploadInstance(_REMOTE, 'HierarchicalAnonymization/RTH/RT.dcm') | |
5027 oStudyId = ct1['ParentStudy'] | |
5028 oCtInstanceId = ct1['ID'] | |
5029 oRtInstanceId = rt1['ID'] | |
5030 | |
5031 oCtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % oCtInstanceId) | |
5032 oRtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % oRtInstanceId) | |
5033 | |
5034 ### anonymize while forcing the StudyInstanceUID | |
5035 | |
5036 aStudyId = DoPost(_REMOTE, '/studies/%s/anonymize' % oStudyId, '{ "Replace" : { "StudyInstanceUID" : "1.2.3.4"}, "Force": true}', | |
5037 'application/json')['ID'] | |
5038 | |
5039 ### validate | |
5040 | |
5041 aSeries = DoGet(_REMOTE, '/studies/%s/series' % aStudyId) | |
5042 self.assertEqual(2, len(aSeries)) | |
5043 | |
5044 aCt = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'CT', aSeries)) | |
5045 aRt = list(filter(lambda x: x['MainDicomTags']['Modality'] == 'RTSTRUCT', aSeries)) | |
5046 aCtInstanceId = aCt[0]['Instances'][0] | |
5047 aRtInstanceId = aRt[0]['Instances'][0] | |
5048 aCtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % aCtInstanceId) | |
5049 aRtTags = DoGet(_REMOTE, '/instances/%s/tags?simplify' % aRtInstanceId) | |
5050 | |
5051 self.assertEqual("1.2.3.4", aCtTags['StudyInstanceUID']) | |
5052 self.assertEqual("1.2.3.4", aRtTags['StudyInstanceUID']) | |
5053 self.assertEqual("1.2.3.4", aRtTags['ReferencedFrameOfReferenceSequence'][0]['RTReferencedStudySequence'][0]['ReferencedSOPInstanceUID']) | |
255
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5054 |
02c3d91b155c
added anonymization test for RTH data (currently failing)
amazy
parents:
254
diff
changeset
|
5055 |
235
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5056 def test_bitbucket_issue_140(self): |
266 | 5057 # "Modifying private tags with REST API changes VR from LO to |
267 | 5058 # UN." This test fails if DCMTK <= 3.6.1 (e.g. fails on Ubuntu 16.04). |
319 | 5059 # https://bugs.orthanc-server.com/show_bug.cgi?id=140 |
235
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5060 source = UploadInstance(_REMOTE, 'Issue140.dcm') ['ID'] |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5061 series = DoGet(_REMOTE, '/instances/%s' % source) ['ParentSeries'] |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5062 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5063 target = DoPost(_REMOTE, '/series/%s/modify' % series, { |
266 | 5064 'Replace' : { 'RadioButton3' : 'aaabbbccc' }, |
5065 'PrivateCreator' : 'RadioLogic', # <= the trick is here | |
235
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5066 }, 'application/json') ['ID'] |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5067 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5068 instances = DoGet(_REMOTE, '/series/%s/instances' % target) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5069 self.assertEqual(1, len(instances)) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5070 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5071 tags = DoGet(_REMOTE, '/instances/%s/tags' % source) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5072 t = tags['4321,1012'] |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5073 self.assertEqual('String', t['Type']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5074 self.assertEqual('RadioButton3', t['Name']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5075 self.assertEqual('RadioLogic', t['PrivateCreator']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5076 self.assertEqual('jklmopq', t['Value']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5077 |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5078 tags = DoGet(_REMOTE, '/instances/%s/tags' % instances[0]['ID']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5079 t = tags['4321,1012'] |
327 | 5080 self.assertEqual('String', t['Type']) # This fails if DCMTK <= 3.6.1 |
235
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5081 self.assertEqual('RadioButton3', t['Name']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5082 self.assertEqual('RadioLogic', t['PrivateCreator']) |
9929e4af2b7a
test_bitbucket_issue_140
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
5083 self.assertEqual('aaabbbccc', t['Value']) |
236
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5084 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5085 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5086 def test_find_normalize(self): |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5087 # https://groups.google.com/d/msg/orthanc-users/AIwooGjsh94/YL28MNY4AgAJ |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5088 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5089 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5090 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5091 a = DoPost(_REMOTE, '/modalities/self/query', { |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5092 'Level' : 'Instance', |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5093 'Query' : { 'Rows' : '42' } |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5094 }) ['ID'] |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5095 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5096 b = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % a) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5097 self.assertEqual(1, len(b)) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5098 self.assertFalse('Rows' in b[0]) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5099 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5100 a = DoPost(_REMOTE, '/modalities/self/query', { |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5101 'Level' : 'Instance', |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5102 'Query' : { 'Rows' : '42' }, |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5103 'Normalize' : False |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5104 }) ['ID'] |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5105 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5106 b = DoGet(_REMOTE, '/queries/%s/answers' % a) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5107 self.assertEqual(0, len(b)) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5108 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5109 a = DoPost(_REMOTE, '/modalities/self/query', { |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5110 'Level' : 'Instance', |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5111 'Query' : { 'Rows' : '512' }, |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5112 'Normalize' : False |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5113 }) ['ID'] |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5114 |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5115 b = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % a) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5116 self.assertEqual(1, len(b)) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5117 self.assertTrue('Rows' in b[0]) |
2de1aec255ae
test_find_normalize
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
5118 self.assertEqual('512', b[0]['Rows']) |
237 | 5119 |
5120 a = DoPost(_REMOTE, '/modalities/self/query', { | |
5121 'Level' : 'Instance', | |
5122 'Query' : { 'Rows' : '' }, | |
5123 'Normalize' : False | |
5124 }) ['ID'] | |
5125 | |
5126 b = DoGet(_REMOTE, '/queries/%s/answers?expand&simplify' % a) | |
5127 self.assertEqual(1, len(b)) | |
5128 self.assertTrue('Rows' in b[0]) | |
5129 self.assertEqual('512', b[0]['Rows']) | |
5130 | |
5131 self.assertRaises(Exception, lambda: DoPost( | |
5132 _REMOTE, '/modalities/self/query', { | |
5133 'Level' : 'Instance', | |
5134 'Query' : { 'Rows' : '*' }, # Out-of-range value | |
5135 'Normalize' : False | |
5136 })) | |
243
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5137 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5138 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5139 def test_bitbucket_issue_141(self): |
319 | 5140 # https://bugs.orthanc-server.com/show_bug.cgi?id=141 |
243
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5141 a = UploadInstance(_REMOTE, 'Issue141.dcm') ['ID'] |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5142 study = '494c8037-b237f263-d8f15075-c8cb2280-daf39bd1' |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5143 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5144 with open(GetDatabasePath('HelloWorld.pdf'), 'rb') as f: |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5145 pdf = f.read() |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5146 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5147 b = DoPost(_REMOTE, '/tools/create-dicom', { |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5148 'Parent' : study, |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5149 'Tags' : {}, |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5150 'Content' : 'data:application/pdf;base64,' + base64.b64encode(pdf) |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5151 }) ['ID'] |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5152 |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5153 tagsA = DoGet(_REMOTE, '/instances/%s/tags?short' % a) |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5154 tagsB = DoGet(_REMOTE, '/instances/%s/tags?short' % b) |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5155 self.assertEqual(tagsA['0008,0005'], tagsB['0008,0005']) |
cccf697a4e13
test_bitbucket_issue_141
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
5156 self.assertEqual(tagsA['0008,1030'], tagsB['0008,1030']) |
247
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
5157 |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
5158 |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
5159 def test_modifying_missing_patientid(self): |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
5160 # https://groups.google.com/d/msg/orthanc-users/aphG_h1AHVg/rfOTtTPTAgAJ |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
5161 UploadInstance(_REMOTE, '2019-06-17-VedranZdesic.dcm') |
1abdab0ba0e6
test_modifying_missing_patientid
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
243
diff
changeset
|
5162 DoPost(_REMOTE, '/studies/0c4aca1d-c107a241-6659d6aa-594c674a-a468b94a/modify', {}) |
262 | 5163 |
5164 | |
5165 def test_log_level(self): | |
319 | 5166 # https://bugs.orthanc-server.com/show_bug.cgi?id=65 |
262 | 5167 original = DoGet(_REMOTE, '/tools/log-level') |
5168 | |
5169 DoPut(_REMOTE, '/tools/log-level', 'default') | |
5170 self.assertEqual('default', DoGet(_REMOTE, '/tools/log-level')) | |
5171 DoGet(_REMOTE, '/system') | |
5172 | |
5173 DoPut(_REMOTE, '/tools/log-level', 'verbose') | |
5174 self.assertEqual('verbose', DoGet(_REMOTE, '/tools/log-level')) | |
5175 DoGet(_REMOTE, '/system') | |
5176 | |
5177 DoPut(_REMOTE, '/tools/log-level', 'trace') | |
5178 self.assertEqual('trace', DoGet(_REMOTE, '/tools/log-level')) | |
5179 DoGet(_REMOTE, '/system') | |
5180 | |
5181 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/tools/log-level', 'nope')) | |
5182 | |
5183 # Switch back to the original log level | |
5184 DoPut(_REMOTE, '/tools/log-level', original) | |
264
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
5185 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
5186 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
5187 def test_upload_compressed(self): |
265 | 5188 # New in Orthanc 1.6.0 |
264
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
5189 with open(GetDatabasePath('DummyCT.dcm.gz'), 'rb') as f: |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
5190 d = f.read() |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
5191 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
5192 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/instances', d, 'application/dicom')) |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
5193 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
5194 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/instances', d, 'application/dicom', |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
5195 headers = { 'Content-Encoding' : 'nope' })) |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
5196 |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
5197 a = DoPost(_REMOTE, '/instances', d, 'application/dicom', |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
5198 headers = { 'Content-Encoding' : 'gzip' }) |
445f498bc1d4
test_upload_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
5199 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', a['ID']) |
262 | 5200 |
5201 | |
263
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5202 def test_study_series_find_inconsistency(self): |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5203 # https://groups.google.com/forum/#!topic/orthanc-users/bLv6Z11COy0 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5204 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5205 def CountAnswers(query): |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5206 a = DoPost(_REMOTE, 'modalities/self/query', query) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5207 return len(DoGet(_REMOTE, '%s/answers' % a['Path'])) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5208 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5209 # This instance has "SeriesDescription" (0008,103e) tag, but no |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5210 # "ProtocolName" (0018,1030). Both of those tags are part of |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5211 # the "main DICOM tags" of Orthanc. |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5212 UploadInstance(_REMOTE, 'Issue137.dcm') |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5213 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5214 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5215 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5216 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5217 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5218 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5219 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5220 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5221 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5222 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5223 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5224 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5225 ## "SeriesDescription" is present, and has VR "CS" => wildcard is allowed |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5226 ## http://dicom.nema.org/medical/dicom/2019e/output/chtml/part04/sect_C.2.2.2.4.html |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5227 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5228 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5229 # At the study level, the "SeriesDescription" tag is not allowed, but |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5230 # is wiped out by the normalization |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5231 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5232 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5233 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5234 'SeriesDescription' : 'NOPE' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5235 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5236 'Normalize' : False |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5237 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5238 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5239 # This test fails on Orthanc <= 1.5.8 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5240 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5241 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5242 'SeriesDescription' : '*' # Wildcard matching => no match, as the tag is absent |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5243 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5244 'Normalize' : False |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5245 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5246 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5247 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5248 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5249 'SeriesDescription' : 'THIS^VALUE^IS^WIPED^OUT' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5250 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5251 'Normalize' : True |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5252 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5253 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5254 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5255 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5256 'SeriesDescription' : '*' # Matches, as wiped out by the normalization |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5257 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5258 'Normalize' : True |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5259 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5260 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5261 for normalize in [ True, False ]: |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5262 # At the series level, the "SeriesDescription" tag is allowed, and |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5263 # normalization has no effect |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5264 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5265 # "Universal matching" will match all entities, including |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5266 # those with the missing tag |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5267 # http://dicom.nema.org/medical/dicom/2019e/output/chtml/part04/sect_C.2.2.2.3.html |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5268 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5269 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5270 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5271 'SeriesDescription' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5272 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5273 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5274 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5275 # "Universal matching" will match all entities, including |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5276 # those with the missing tag |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5277 # http://dicom.nema.org/medical/dicom/2019e/output/chtml/part04/sect_C.2.2.2.3.html |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5278 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5279 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5280 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5281 'SeriesDescription' : '*' # Wildcard matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5282 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5283 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5284 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5285 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5286 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5287 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5288 'SeriesDescription' : '*model*' # The actual value is "STL model: intraop Report" |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5289 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5290 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5291 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5292 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5293 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5294 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5295 'SeriesDescription' : '*MISMATCHED^VALUE*' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5296 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5297 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5298 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5299 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5300 # Universal matching matches any instance, even if the |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5301 # query is at the study-level, and thus if "SeriesDescription" |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5302 # makes no sense |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5303 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5304 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5305 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5306 'SeriesDescription' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5307 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5308 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5309 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5310 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5311 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5312 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5313 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5314 ## "ProtocolName" is absent, and has VR "CS" => wildcard is allowed |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5315 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5316 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5317 # At the study level, the "ProtocolName" tag is not allowed, but |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5318 # is wiped out by the normalization |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5319 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5320 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5321 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5322 'ProtocolName' : 'NOPE' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5323 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5324 'Normalize' : False |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5325 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5326 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5327 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5328 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5329 'ProtocolName' : '*' # Wildcard matching => no match, as the tag is absent |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5330 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5331 'Normalize' : False |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5332 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5333 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5334 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5335 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5336 'ProtocolName' : 'THIS^VALUE^IS^WIPED^OUT' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5337 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5338 'Normalize' : True |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5339 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5340 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5341 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5342 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5343 'ProtocolName' : '*' # Matches, as wiped out by the normalization |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5344 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5345 'Normalize' : True |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5346 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5347 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5348 for normalize in [ True, False ]: |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5349 # At the series level, the "ProtocolName" tag is allowed, and |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5350 # normalization has no effect |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5351 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5352 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5353 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5354 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5355 'ProtocolName' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5356 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5357 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5358 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5359 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5360 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5361 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5362 'ProtocolName' : '*' # Wildcard matching => no match, as the tag is absent |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5363 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5364 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5365 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5366 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5367 'Level' : 'Series', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5368 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5369 'ProtocolName' : '*MISMATCHED^VALUE*' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5370 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5371 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5372 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5373 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5374 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5375 'Level' : 'Study', |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5376 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5377 'ProtocolName' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5378 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5379 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5380 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5381 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5382 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5383 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5384 ## "StudyInstanceUID" is present, and has VR "UI" => wildcard is not allowed |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5385 ## |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5386 |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5387 for level in [ 'Study', 'Series' ] : |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5388 for normalize in [ True, False ]: |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5389 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5390 'Level' : level, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5391 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5392 'StudyInstanceUID' : '' # Universal matching |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5393 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5394 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5395 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5396 self.assertEqual(0, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5397 'Level' : level, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5398 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5399 'StudyInstanceUID' : 'MISMATCHED^VALUE' |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5400 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5401 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5402 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5403 self.assertEqual(1, CountAnswers({ |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5404 'Level' : level, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5405 'Query' : { |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5406 'StudyInstanceUID' : '4.5.6' # This is the actual value |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5407 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5408 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5409 })) |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5410 |
269 | 5411 # Wildcard matching is not allowed for this VR |
263
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5412 # This test fails on Orthanc <= 1.5.8 |
269 | 5413 self.assertRaises(Exception, lambda: CountAnswers({ |
263
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5414 'Level' : level, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5415 'Query' : { |
269 | 5416 'StudyInstanceUID' : '*' |
263
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5417 }, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5418 'Normalize' : normalize, |
a2719263fd04
test_study_series_find_inconsistency
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
5419 })) |
265 | 5420 |
5421 | |
5422 def test_rendered(self): | |
5423 # New in Orthanc 1.6.0 | |
5424 i = UploadInstance(_REMOTE, 'ColorTestMalaterre.dcm')['ID'] | |
5425 im = GetImage(_REMOTE, '/instances/%s/rendered' % i) | |
5426 self.assertEqual("RGB", im.mode) | |
5427 self.assertEqual(41, im.size[0]) | |
5428 self.assertEqual(41, im.size[1]) | |
5429 | |
5430 # http://effbot.org/zone/pil-comparing-images.htm | |
5431 truth = Image.open(GetDatabasePath('ColorTestMalaterre.png')) | |
5432 self.assertTrue(ImageChops.difference(im, truth).getbbox() is None) | |
5433 | |
5434 im = GetImage(_REMOTE, '/instances/%s/rendered?width=10' % i) | |
5435 self.assertEqual("RGB", im.mode) | |
5436 self.assertEqual(10, im.size[0]) | |
5437 self.assertEqual(10, im.size[1]) | |
5438 | |
5439 im = GetImage(_REMOTE, '/instances/%s/rendered?height=10' % i) | |
5440 self.assertEqual("RGB", im.mode) | |
5441 self.assertEqual(10, im.size[0]) | |
5442 self.assertEqual(10, im.size[1]) | |
5443 | |
5444 im = GetImage(_REMOTE, '/instances/%s/rendered?height=128' % i) | |
5445 self.assertEqual("RGB", im.mode) | |
5446 self.assertEqual(128, im.size[0]) | |
5447 self.assertEqual(128, im.size[1]) | |
5448 | |
5449 im = GetImage(_REMOTE, '/instances/%s/rendered?height=10&smooth=0' % i) | |
5450 self.assertEqual("RGB", im.mode) | |
5451 self.assertEqual(10, im.size[0]) | |
5452 self.assertEqual(10, im.size[1]) | |
5453 | |
5454 im = GetImage(_REMOTE, '/instances/%s/rendered?height=10&smooth=1' % i) | |
5455 self.assertEqual("RGB", im.mode) | |
5456 self.assertEqual(10, im.size[0]) | |
5457 self.assertEqual(10, im.size[1]) | |
5458 | |
5459 im = GetImage(_REMOTE, '/instances/%s/rendered?height=5&width=10' % i) | |
5460 self.assertEqual("RGB", im.mode) | |
5461 self.assertEqual(5, im.size[0]) | |
5462 self.assertEqual(5, im.size[1]) | |
5463 | |
5464 | |
5465 # Grayscale image | |
5466 i = UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] | |
5467 im = GetImage(_REMOTE, '/instances/%s/rendered' % i) | |
5468 self.assertEqual("L", im.mode) | |
5469 self.assertEqual(288, im.size[0]) | |
5470 self.assertEqual(288, im.size[1]) | |
5471 self.assertEqual(0, im.getpixel((0, 0))) | |
5472 | |
5473 # Those are the original windowing parameters that are written | |
5474 # inside the DICOM file | |
5475 im2 = GetImage(_REMOTE, '/instances/%s/rendered?window-center=248.009544468547&window-width=431.351843817788' % i) | |
5476 self.assertEqual("L", im2.mode) | |
5477 self.assertEqual(288, im2.size[0]) | |
5478 self.assertEqual(288, im2.size[1]) | |
5479 self.assertTrue(ImageChops.difference(im, im2).getbbox() is None) | |
5480 | |
5481 im = GetImage(_REMOTE, '/instances/%s/rendered?width=512&smooth=0' % i) | |
5482 self.assertEqual("L", im.mode) | |
5483 self.assertEqual(512, im.size[0]) | |
5484 self.assertEqual(512, im.size[1]) | |
5485 | |
5486 im = GetImage(_REMOTE, '/instances/%s/rendered?width=10&smooth=0' % i) | |
5487 self.assertEqual("L", im.mode) | |
5488 self.assertEqual(10, im.size[0]) | |
5489 self.assertEqual(10, im.size[1]) | |
5490 | |
5491 im = GetImage(_REMOTE, '/instances/%s/rendered?width=10&smooth=1' % i) | |
5492 self.assertEqual("L", im.mode) | |
5493 self.assertEqual(10, im.size[0]) | |
5494 self.assertEqual(10, im.size[1]) | |
5495 | |
5496 im = GetImage(_REMOTE, '/instances/%s/rendered?width=1&window-center=-1000' % i) | |
5497 self.assertEqual("L", im.mode) | |
5498 self.assertEqual(1, im.size[0]) | |
5499 self.assertEqual(1, im.size[1]) | |
5500 self.assertEqual(255, im.getpixel((0, 0))) | |
5501 | |
5502 im = GetImage(_REMOTE, '/instances/%s/rendered?width=1&window-center=1000' % i) | |
5503 self.assertEqual("L", im.mode) | |
5504 self.assertEqual(1, im.size[0]) | |
5505 self.assertEqual(1, im.size[1]) | |
5506 self.assertEqual(0, im.getpixel((0, 0))) | |
5507 | |
5508 | |
5509 # Test monochrome 1 | |
5510 i = UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm')['ID'] | |
5511 im = GetImage(_REMOTE, '/instances/%s/rendered' % i) | |
5512 self.assertEqual("L", im.mode) | |
5513 self.assertEqual(2010, im.size[0]) | |
5514 self.assertEqual(2446, im.size[1]) | |
5515 self.assertEqual(0, im.getpixel((0, 0))) | |
5516 im = GetImage(_REMOTE, '/instances/%s/rendered?width=20' % i) | |
5517 self.assertEqual("L", im.mode) | |
5518 self.assertEqual(20, im.size[0]) | |
5519 self.assertEqual(24, im.size[1]) | |
5520 im = GetImage(_REMOTE, '/instances/%s/rendered?height=24' % i) | |
5521 self.assertEqual("L", im.mode) | |
5522 self.assertEqual(20, im.size[0]) | |
5523 self.assertEqual(24, im.size[1]) | |
5524 im = GetImage(_REMOTE, '/instances/%s/rendered?width=10&height=24' % i) | |
5525 self.assertEqual("L", im.mode) | |
5526 self.assertEqual(10, im.size[0]) | |
5527 self.assertEqual(12, im.size[1]) | |
5528 im = GetImage(_REMOTE, '/instances/%s/rendered?width=40&height=24' % i) | |
5529 self.assertEqual("L", im.mode) | |
5530 self.assertEqual(20, im.size[0]) | |
5531 self.assertEqual(24, im.size[1]) | |
268
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5532 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5533 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5534 def test_bitbucket_issue_154(self): |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5535 # "Matching against list of UID-s by C-MOVE" |
319 | 5536 # https://bugs.orthanc-server.com/show_bug.cgi?id=154 |
268
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5537 a = UploadInstance(_REMOTE, 'Issue154-d1.dcm') ['ID'] |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5538 b = UploadInstance(_REMOTE, 'Issue154-d2.dcm') ['ID'] |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5539 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5540 study = '1.2.826.0.1.3680043.8.498.35214236271657363033644818354280454731' |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5541 series1 = '1.2.826.0.1.3680043.8.498.12243321927795467590791662266352305113' |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5542 series2 = '1.2.826.0.1.3680043.8.498.43769499931624584079690260699536473555' |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5543 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5544 # C-FIND is working on list of UIDs |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5545 i = CallFindScu([ '-k', 'QueryRetrieveLevel=SERIES', |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5546 '-k', 'StudyInstanceUID=%s' % study, |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5547 '-k', 'SeriesInstanceUID=%s\\%s' % (series1, series2) ]) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5548 series = re.findall('\(0020,000e\).*?\[(.*?)\]', i) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5549 self.assertEqual(2, len(series)) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5550 self.assertTrue(series1 in series) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5551 self.assertTrue(series2 in series) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5552 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5553 # Individual retrieval is working in Orthanc < 1.6.0 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5554 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5555 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5556 '--study', '-k', 'QueryRetrieveLevel=SERIES', |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5557 '-k', 'StudyInstanceUID=%s' % study, |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5558 '-k', 'SeriesInstanceUID=%s' % series1, |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5559 ]))) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5560 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5561 '--study', '-k', 'QueryRetrieveLevel=SERIES', |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5562 '-k', 'StudyInstanceUID=%s' % study, |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5563 '-k', 'SeriesInstanceUID=%s' % series2, |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5564 ]))) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5565 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5566 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5567 DropOrthanc(_LOCAL) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5568 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5569 # But list matching is working only in Orthanc >= 1.6.0 |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5570 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5571 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5572 '--study', '-k', 'QueryRetrieveLevel=SERIES', |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5573 '-k', 'StudyInstanceUID=%s' % study, |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5574 '-k', 'SeriesInstanceUID=%s\\%s' % (series1, series2), |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5575 ]))) |
c8d79d8258cd
test_bitbucket_issue_154
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
267
diff
changeset
|
5576 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
279
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5577 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5578 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5579 def test_storage_commitment_api(self): |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5580 # Storage commitment is available since Orthanc 1.6.0 |
280
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5581 |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5582 def WaitTransaction(uid): |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5583 while True: |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5584 s = DoGet(_REMOTE, '/storage-commitment/%s' % uid) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5585 if s['Status'] != 'Pending': |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5586 return s |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5587 else: |
342
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
5588 time.sleep(0.01) |
280
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5589 |
281 | 5590 instance = UploadInstance(_REMOTE, 'DummyCT.dcm') |
279
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5591 sopClassUid = '1.2.840.10008.5.1.4.1.1.4' |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5592 sopInstanceUid = '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5593 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5594 # Against self |
281 | 5595 transaction = DoPost(_REMOTE, '/modalities/self/storage-commitment', { |
5596 "DicomInstances" : [ [ sopClassUid, sopInstanceUid ] ], | |
5597 }) ['ID'] | |
279
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5598 self.assertTrue(transaction.startswith('2.25.')) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5599 |
280
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5600 result = WaitTransaction(transaction) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5601 self.assertEqual('ORTHANC', result['RemoteAET']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5602 self.assertEqual('Success', result['Status']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5603 self.assertEqual(1, len(result['Success'])) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5604 self.assertEqual(0, len(result['Failures'])) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5605 self.assertEqual(sopClassUid, result['Success'][0]['SOPClassUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5606 self.assertEqual(sopInstanceUid, result['Success'][0]['SOPInstanceUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5607 |
281 | 5608 tmp = DoPost(_REMOTE, '/modalities/self/storage-commitment', { |
5609 "DicomInstances" : [ | |
5610 { 'SOPClassUID' : sopClassUid, | |
5611 'SOPInstanceUID' : sopInstanceUid }, | |
5612 ], | |
5613 }) | |
5614 self.assertEqual(tmp['Path'], '/storage-commitment/%s' % tmp['ID']) | |
5615 self.assertEqual(result, WaitTransaction(transaction)) | |
5616 | |
5617 tmp = DoPost(_REMOTE, '/modalities/self/storage-commitment', { | |
5618 "Resources" : [ | |
5619 instance['ID'], | |
5620 instance['ParentSeries'], | |
5621 instance['ParentStudy'], | |
5622 instance['ParentPatient'], | |
5623 ] | |
5624 }) | |
280
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5625 self.assertEqual(tmp['Path'], '/storage-commitment/%s' % tmp['ID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5626 self.assertEqual(result, WaitTransaction(transaction)) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5627 |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5628 |
281 | 5629 transaction = DoPost(_REMOTE, '/modalities/self/storage-commitment', { |
5630 "DicomInstances" : [ | |
5631 [ 'nope', 'nope2' ], | |
5632 [ sopClassUid, sopInstanceUid ], | |
5633 ], | |
5634 }) ['ID'] | |
279
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5635 self.assertTrue(transaction.startswith('2.25.')) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5636 |
280
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5637 result = WaitTransaction(transaction) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5638 self.assertEqual('ORTHANC', result['RemoteAET']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5639 self.assertEqual('Failure', result['Status']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5640 self.assertEqual(1, len(result['Success'])) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5641 self.assertEqual(1, len(result['Failures'])) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5642 self.assertEqual(sopClassUid, result['Success'][0]['SOPClassUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5643 self.assertEqual(sopInstanceUid, result['Success'][0]['SOPInstanceUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5644 self.assertEqual('nope', result['Failures'][0]['SOPClassUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5645 self.assertEqual('nope2', result['Failures'][0]['SOPInstanceUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5646 self.assertEqual(274, result['Failures'][0]['FailureReason']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5647 |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5648 # Cannot remove items from a failed storage commitment transaction |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5649 self.assertRaises(Exception, lambda: |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5650 DoPost(_REMOTE, '/storage-commitment/%s/remove' % transaction)) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5651 |
279
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5652 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5653 # Against Orthanc 0.8.6, that does not support storage commitment |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5654 self.assertRaises(Exception, lambda: |
281 | 5655 DoPost(_REMOTE, '/modalities/orthanctest/storage-commitment', { |
5656 "DicomInstances" : [ | |
5657 [ sopClassUid, sopInstanceUid ], | |
5658 ] | |
5659 })) | |
279
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5660 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5661 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5662 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5663 def test_storage_commitment_store(self): |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5664 # Storage commitment is available since Orthanc 1.6.0 |
280
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5665 |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5666 def WaitTransaction(uid): |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5667 while True: |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5668 s = DoGet(_REMOTE, '/storage-commitment/%s' % uid) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5669 if s['Status'] != 'Pending': |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5670 return s |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5671 else: |
342
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
5672 time.sleep(0.01) |
280
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5673 |
279
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5674 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5675 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5676 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5677 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5678 # The Orthanc 0.8.6 from "_LOCAL" does not support storage commitment |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5679 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/modalities/orthanctest/store', { |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5680 'Resources' : [ i ], |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5681 'StorageCommitment' : True, |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5682 })) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5683 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5684 j = DoPost(_REMOTE, '/modalities/orthanctest/store', { |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5685 'Resources' : [ i ], |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5686 'StorageCommitment' : False, |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5687 }) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5688 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5689 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5690 j = DoPost(_REMOTE, '/modalities/self/store', { |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5691 'Resources' : [ i ], |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5692 'StorageCommitment' : True, |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5693 }) |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5694 |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5695 transaction = j['StorageCommitmentTransactionUID'] |
31e1e49df380
starting tests for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
5696 self.assertTrue(transaction.startswith('2.25.')) |
280
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5697 |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5698 result = WaitTransaction(transaction) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5699 self.assertEqual('ORTHANC', result['RemoteAET']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5700 self.assertEqual('Success', result['Status']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5701 self.assertEqual(1, len(result['Success'])) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5702 self.assertEqual(0, len(result['Failures'])) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5703 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', result['Success'][0]['SOPClassUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5704 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5705 result['Success'][0]['SOPInstanceUID']) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5706 |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5707 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5708 DoPost(_REMOTE, '/storage-commitment/%s/remove' % transaction) |
5daa3896981c
testing storage commitment reports
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
279
diff
changeset
|
5709 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
285
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5710 |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5711 |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5712 def test_store_straight(self): # New in Orthanc 1.6.1 |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5713 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5714 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5715 |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5716 with open(GetDatabasePath('DummyCT.dcm'), 'rb') as f: |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5717 dicom = f.read() |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5718 |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5719 self.assertRaises(Exception, lambda: DoPost( |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5720 _REMOTE, '/modalities/orthanctest/store-straight', 'nope', 'nope')) |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5721 |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5722 answer = DoPost(_REMOTE, '/modalities/orthanctest/store-straight', dicom, 'nope') |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5723 |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5724 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5725 answer['SOPClassUID']) |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5726 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5727 answer['SOPInstanceUID']) |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5728 |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5729 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
281a32ecc5c1
test_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
281
diff
changeset
|
5730 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
289
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5731 |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5732 |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5733 def test_storescu_transcoding(self): # New in Orthanc 1.7.0 |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5734 # Add a RLE-encoded DICOM file |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5735 i = UploadInstance(_REMOTE, 'TransferSyntaxes/1.2.840.10008.1.2.5.dcm')['ID'] |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5736 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5737 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5738 rleSize = len(DoGet(_REMOTE, '/instances/%s/file' % i)) |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5739 |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5740 # Export the instance, with transcoding: "_REMOTE" is the |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5741 # Orthanc server being tested |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5742 try: |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5743 DoDelete(_REMOTE, '/modalities/toto') |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5744 except: |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5745 pass |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5746 |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5747 params = DoGet(_REMOTE, '/modalities?expand') ['orthanctest'] |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5748 DoPut(_REMOTE, '/modalities/toto', params) |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5749 DoPost(_REMOTE, '/modalities/toto/store', str(i), 'text/plain') |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5750 j = DoGet(_LOCAL, '/instances') |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5751 self.assertEqual(1, len(j)) |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5752 uncompressedSize = len(DoGet(_LOCAL, '/instances/%s/file' % j[0])) |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5753 self.assertTrue(uncompressedSize > rleSize / 2) |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5754 |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5755 # Export, with transcoding disabled => this fails |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5756 params['AllowTranscoding'] = False |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5757 DoPut(_REMOTE, '/modalities/toto', params) |
4a70411ac9ad
test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
5758 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/modalities/toto/store', str(i), 'text/plain')) |
378
a4b8450a1158
fix test_storescu_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
5759 DoDelete(_REMOTE, '/modalities/toto') |
290
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5760 |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5761 |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5762 def test_bitbucket_issue_169(self): |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5763 with open(GetDatabasePath('Issue169.dcm.bz2'), 'rb') as f: |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5764 dicom = bz2.decompress(f.read()) |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5765 |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5766 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(dicom)) |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5767 |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5768 self.assertEqual(44350560, len(dicom)) |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5769 i = DoPost(_REMOTE, '/instances', dicom, 'application/dicom') ['ID'] |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5770 |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5771 tags = DoGet(_REMOTE, '/instances/%s/tags' % i) |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5772 self.assertEqual('NORMAL', tags['1337,1001']['Value']) |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5773 |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5774 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5775 DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain') |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5776 j = DoGet(_LOCAL, '/instances') |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5777 self.assertEqual(1, len(j)) |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5778 |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5779 # In Orthanc <= 1.6.1, transfer syntax changed from "Explicit |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5780 # VR Little Endian" (1.2.840.10008.1.2.1) to "Implicit VR |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5781 # Little Endian" (1.2.840.10008.1.2) |
291
cfa785074c64
test_modify_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
290
diff
changeset
|
5782 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax( |
cfa785074c64
test_modify_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
290
diff
changeset
|
5783 DoGet(_LOCAL, '/instances/%s/file' % j[0]))) |
290
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5784 |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5785 # In Orthanc <= 1.6.1, the value of the private tags was lost |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5786 # because of this transcoding |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5787 tags = DoGet(_LOCAL, '/instances/%s/tags' % j[0]) |
b5333f87065b
test_bitbucket_issue_169
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
289
diff
changeset
|
5788 self.assertEqual('NORMAL', tags['1337,1001']['Value']) |
291
cfa785074c64
test_modify_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
290
diff
changeset
|
5789 |
cfa785074c64
test_modify_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
290
diff
changeset
|
5790 |
302
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5791 def test_modify_transcode_instance(self): |
291
cfa785074c64
test_modify_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
290
diff
changeset
|
5792 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] |
cfa785074c64
test_modify_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
290
diff
changeset
|
5793 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax( |
cfa785074c64
test_modify_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
290
diff
changeset
|
5794 DoGet(_REMOTE, '/instances/%s/file' % i))) |
cfa785074c64
test_modify_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
290
diff
changeset
|
5795 |
299
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5796 a = ExtractDicomTags(DoGet(_REMOTE, '/instances/%s/file' % i), [ 'SOPInstanceUID' ]) [0] |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5797 self.assertTrue(len(a) > 20) |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5798 |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5799 SYNTAXES = [ |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5800 '1.2.840.10008.1.2', |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5801 '1.2.840.10008.1.2.1', |
300
d6c2eb5a2603
disabling test on Deflated Explicit VR Little Endian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
5802 #'1.2.840.10008.1.2.1.99', # Deflated Explicit VR Little Endian (cannot be decoded in debug mode if Orthanc is statically linked against DCMTK 3.6.5) |
299
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5803 '1.2.840.10008.1.2.2', |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5804 '1.2.840.10008.1.2.4.50', |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5805 '1.2.840.10008.1.2.4.51', |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5806 '1.2.840.10008.1.2.4.57', |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5807 '1.2.840.10008.1.2.4.70', |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5808 ] |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5809 |
304 | 5810 if HasGdcmPlugin(_REMOTE): |
299
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5811 SYNTAXES = SYNTAXES + [ |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5812 '1.2.840.10008.1.2.4.80', # This makes DCMTK 3.6.2 crash |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5813 '1.2.840.10008.1.2.4.81', # This makes DCMTK 3.6.2 crash |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5814 '1.2.840.10008.1.2.4.90', # JPEG2k, unavailable without GDCM |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5815 '1.2.840.10008.1.2.4.91', # JPEG2k, unavailable without GDCM |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5816 ] |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5817 |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5818 for syntax in SYNTAXES: |
291
cfa785074c64
test_modify_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
290
diff
changeset
|
5819 transcoded = DoPost(_REMOTE, '/instances/%s/modify' % i, { |
cfa785074c64
test_modify_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
290
diff
changeset
|
5820 'Transcode' : syntax, |
299
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5821 'Keep' : [ 'SOPInstanceUID' ], |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5822 'Force' : True, |
291
cfa785074c64
test_modify_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
290
diff
changeset
|
5823 }) |
cfa785074c64
test_modify_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
290
diff
changeset
|
5824 |
cfa785074c64
test_modify_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
290
diff
changeset
|
5825 self.assertEqual(syntax, GetTransferSyntax(transcoded)) |
292
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5826 |
299
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5827 b = ExtractDicomTags(transcoded, [ 'SOPInstanceUID' ]) [0] |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5828 self.assertTrue(len(b) > 20) |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5829 if syntax in [ '1.2.840.10008.1.2.4.50', |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5830 '1.2.840.10008.1.2.4.51', |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5831 '1.2.840.10008.1.2.4.81', |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5832 '1.2.840.10008.1.2.4.91' ]: |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5833 # Lossy transcoding: The SOP instance UID must have changed |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5834 self.assertNotEqual(a, b) |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5835 else: |
c2144cf4bd83
HasGdcmPlugin() test
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
293
diff
changeset
|
5836 self.assertEqual(a, b) |
292
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5837 |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5838 def test_archive_transcode(self): |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5839 info = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm') |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5840 |
293
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5841 # GET on "/media" |
292
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5842 z = GetArchive(_REMOTE, '/patients/%s/media' % info['ParentPatient']) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5843 self.assertEqual(2, len(z.namelist())) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5844 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(z.read('IMAGES/IM0'))) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5845 |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5846 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/patients/%s/media?transcode=nope' % info['ParentPatient'])) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5847 |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5848 z = GetArchive(_REMOTE, '/patients/%s/media?transcode=1.2.840.10008.1.2.4.50' % info['ParentPatient']) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5849 self.assertEqual('1.2.840.10008.1.2.4.50', GetTransferSyntax(z.read('IMAGES/IM0'))) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5850 |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5851 z = GetArchive(_REMOTE, '/studies/%s/media?transcode=1.2.840.10008.1.2.4.51' % info['ParentStudy']) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5852 self.assertEqual('1.2.840.10008.1.2.4.51', GetTransferSyntax(z.read('IMAGES/IM0'))) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5853 |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5854 z = GetArchive(_REMOTE, '/series/%s/media?transcode=1.2.840.10008.1.2.4.57' % info['ParentSeries']) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5855 self.assertEqual('1.2.840.10008.1.2.4.57', GetTransferSyntax(z.read('IMAGES/IM0'))) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5856 |
293
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5857 |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5858 # POST on "/media" |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5859 self.assertRaises(Exception, lambda: PostArchive( |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5860 _REMOTE, '/patients/%s/media' % info['ParentPatient'], { 'Transcode' : 'nope' })) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5861 |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5862 z = PostArchive(_REMOTE, '/patients/%s/media' % info['ParentPatient'], { |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5863 'Transcode' : '1.2.840.10008.1.2.4.50', |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5864 }) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5865 self.assertEqual('1.2.840.10008.1.2.4.50', GetTransferSyntax(z.read('IMAGES/IM0'))) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5866 |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5867 z = PostArchive(_REMOTE, '/studies/%s/media' % info['ParentStudy'], { |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5868 'Transcode' : '1.2.840.10008.1.2.4.51', |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5869 }) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5870 self.assertEqual('1.2.840.10008.1.2.4.51', GetTransferSyntax(z.read('IMAGES/IM0'))) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5871 |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5872 z = PostArchive(_REMOTE, '/series/%s/media' % info['ParentSeries'], { |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5873 'Transcode' : '1.2.840.10008.1.2.4.57', |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5874 }) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5875 self.assertEqual('1.2.840.10008.1.2.4.57', GetTransferSyntax(z.read('IMAGES/IM0'))) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5876 |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5877 |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5878 # GET on "/archive" |
292
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5879 z = GetArchive(_REMOTE, '/patients/%s/archive' % info['ParentPatient']) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5880 self.assertEqual(1, len(z.namelist())) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5881 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(z.read(z.namelist()[0]))) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5882 |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5883 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/patients/%s/archive?transcode=nope' % info['ParentPatient'])) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5884 |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5885 z = GetArchive(_REMOTE, '/patients/%s/archive?transcode=1.2.840.10008.1.2' % info['ParentPatient']) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5886 self.assertEqual('1.2.840.10008.1.2', GetTransferSyntax(z.read(z.namelist()[0]))) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5887 |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5888 z = GetArchive(_REMOTE, '/studies/%s/archive?transcode=1.2.840.10008.1.2.2' % info['ParentStudy']) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5889 self.assertEqual('1.2.840.10008.1.2.2', GetTransferSyntax(z.read(z.namelist()[0]))) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5890 |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5891 z = GetArchive(_REMOTE, '/series/%s/archive?transcode=1.2.840.10008.1.2.4.70' % info['ParentSeries']) |
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5892 self.assertEqual('1.2.840.10008.1.2.4.70', GetTransferSyntax(z.read(z.namelist()[0]))) |
293
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5893 |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5894 |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5895 # POST on "/archive" |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5896 self.assertRaises(Exception, lambda: PostArchive( |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5897 _REMOTE, '/patients/%s/archive' % info['ParentPatient'], { 'Transcode' : 'nope' })) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5898 |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5899 z = PostArchive(_REMOTE, '/patients/%s/archive' % info['ParentPatient'], { |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5900 'Transcode' : '1.2.840.10008.1.2.4.50', |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5901 }) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5902 self.assertEqual('1.2.840.10008.1.2.4.50', GetTransferSyntax(z.read(z.namelist()[0]))) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5903 |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5904 z = PostArchive(_REMOTE, '/studies/%s/archive' % info['ParentStudy'], { |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5905 'Transcode' : '1.2.840.10008.1.2.4.51', |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5906 }) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5907 self.assertEqual('1.2.840.10008.1.2.4.51', GetTransferSyntax(z.read(z.namelist()[0]))) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5908 |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5909 z = PostArchive(_REMOTE, '/series/%s/archive' % info['ParentSeries'], { |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5910 'Transcode' : '1.2.840.10008.1.2.4.57', |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5911 }) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5912 self.assertEqual('1.2.840.10008.1.2.4.57', GetTransferSyntax(z.read(z.namelist()[0]))) |
292
e1827a4f5d3b
test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
5913 |
293
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5914 |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5915 # "/tools/create-*" |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5916 z = PostArchive(_REMOTE, '/tools/create-archive', { |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5917 'Resources' : [ info['ParentStudy'] ], |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5918 'Transcode' : '1.2.840.10008.1.2.4.50', |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5919 }) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5920 self.assertEqual(1, len(z.namelist())) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5921 self.assertEqual('1.2.840.10008.1.2.4.50', GetTransferSyntax(z.read(z.namelist()[0]))) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5922 |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5923 z = PostArchive(_REMOTE, '/tools/create-media', { |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5924 'Resources' : [ info['ParentStudy'] ], |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5925 'Transcode' : '1.2.840.10008.1.2.4.51', |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5926 }) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5927 self.assertEqual(2, len(z.namelist())) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5928 self.assertEqual('1.2.840.10008.1.2.4.51', GetTransferSyntax(z.read('IMAGES/IM0'))) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5929 |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5930 z = PostArchive(_REMOTE, '/tools/create-media-extended', { |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5931 'Resources' : [ info['ParentStudy'] ], |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5932 'Transcode' : '1.2.840.10008.1.2.4.57', |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5933 }) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5934 self.assertEqual(2, len(z.namelist())) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5935 self.assertEqual('1.2.840.10008.1.2.4.57', GetTransferSyntax(z.read('IMAGES/IM0'))) |
032722c3e919
extended test_archive_transcode
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
292
diff
changeset
|
5936 |
308 | 5937 |
301
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5938 def test_modify_keep_source(self): |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5939 # https://groups.google.com/d/msg/orthanc-users/CgU-Wg8vDio/BY5ZWcDEAgAJ |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5940 i = UploadInstance(_REMOTE, 'DummyCT.dcm') |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5941 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5942 |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5943 j = DoPost(_REMOTE, '/studies/%s/modify' % i['ParentStudy'], { |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5944 'Replace' : { |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5945 'StationName' : 'TEST', |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5946 }, |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5947 'KeepSource' : True, |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5948 }) |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5949 |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5950 s = DoGet(_REMOTE, '/studies') |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5951 self.assertEqual(2, len(s)) |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5952 self.assertTrue(i['ParentStudy'] in s) |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5953 self.assertTrue(j['ID'] in s) |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5954 |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5955 DoDelete(_REMOTE, '/studies/%s' % j['ID']) |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5956 self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5957 |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5958 j = DoPost(_REMOTE, '/studies/%s/modify' % i['ParentStudy'], { |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5959 'Replace' : { |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5960 'StationName' : 'TEST', |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5961 }, |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5962 'KeepSource' : False, |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5963 }) |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5964 |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5965 s = DoGet(_REMOTE, '/studies') |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5966 self.assertEqual(1, len(s)) |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5967 self.assertFalse(i['ParentStudy'] in s) |
6652d5720a45
test_modify_keep_source
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
300
diff
changeset
|
5968 self.assertTrue(j['ID'] in s) |
302
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5969 |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5970 |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5971 def test_modify_transcode_study(self): |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5972 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm') |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5973 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax( |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5974 DoGet(_REMOTE, '/instances/%s/file' % i['ID']))) |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5975 |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5976 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5977 j = DoPost(_REMOTE, '/studies/%s/modify' % i['ParentStudy'], { |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5978 'Transcode' : '1.2.840.10008.1.2.4.50', |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5979 'KeepSource' : False |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5980 }) |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5981 |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5982 k = DoGet(_REMOTE, '/instances') |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5983 self.assertEqual(1, len(k)) |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5984 self.assertEqual(i['ID'], DoGet(_REMOTE, '/instances/%s/metadata?expand' % k[0]) ['ModifiedFrom']) |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5985 self.assertEqual('1.2.840.10008.1.2.4.50', GetTransferSyntax( |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5986 DoGet(_REMOTE, '/instances/%s/file' % k[0]))) |
22b6dd0f8c84
test_modify_transcode_study
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
5987 |
305
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
5988 |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
5989 def test_store_peer_transcoding(self): |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
5990 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
5991 |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
5992 SYNTAXES = [ |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
5993 '1.2.840.10008.1.2', |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
5994 '1.2.840.10008.1.2.1', |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
5995 #'1.2.840.10008.1.2.1.99', # Deflated Explicit VR Little Endian (cannot be decoded in debug mode if Orthanc is statically linked against DCMTK 3.6.5) |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
5996 '1.2.840.10008.1.2.2', |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
5997 '1.2.840.10008.1.2.4.50', |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
5998 '1.2.840.10008.1.2.4.51', |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
5999 '1.2.840.10008.1.2.4.57', |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6000 '1.2.840.10008.1.2.4.70', |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6001 ] |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6002 |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6003 if HasGdcmPlugin(_REMOTE): |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6004 SYNTAXES = SYNTAXES + [ |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6005 '1.2.840.10008.1.2.4.80', # This makes DCMTK 3.6.2 crash |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6006 '1.2.840.10008.1.2.4.81', # This makes DCMTK 3.6.2 crash |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6007 '1.2.840.10008.1.2.4.90', # JPEG2k, unavailable without GDCM |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6008 '1.2.840.10008.1.2.4.91', # JPEG2k, unavailable without GDCM |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6009 ] |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6010 |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6011 for syntax in SYNTAXES: |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6012 body = { |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6013 'Resources' : [ i ], |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6014 } |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6015 |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6016 if syntax != '1.2.840.10008.1.2.1': |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6017 body['Transcode'] = syntax |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6018 |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6019 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6020 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6021 DoPost(_REMOTE, '/peers/peer/store', body, 'text/plain') |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6022 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6023 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6024 self.assertEqual(syntax, GetTransferSyntax( |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6025 DoGet(_LOCAL, '/instances/%s/file' % DoGet(_LOCAL, '/instances') [0]))) |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6026 |
ed20ead1a8b6
test_store_peer_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
6027 DropOrthanc(_LOCAL) |
308 | 6028 |
6029 | |
295 | 6030 def test_getscu(self): |
307 | 6031 def CleanTarget(): |
6032 if os.path.isdir('/tmp/GETSCU'): | |
6033 shutil.rmtree('/tmp/GETSCU') | |
6034 os.makedirs('/tmp/GETSCU') | |
6035 | |
306
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6036 env = {} |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6037 if _DOCKER: |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6038 # This is "getscu" from DCMTK 3.6.5 compiled using LSB, |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6039 # and running in a GNU/Linux distribution running DCMTK |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6040 # 3.6.0. Tell "getscu" where it can find the DICOM dictionary. |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6041 env['DCMDICTPATH'] = '/usr/share/libdcmtk2/dicom.dic' |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6042 |
295 | 6043 # no transcoding required |
307 | 6044 UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')['ID'] |
6045 | |
6046 CleanTarget() | |
295 | 6047 |
306
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6048 subprocess.check_call([ |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6049 FindExecutable('getscu'), |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6050 _REMOTE['Server'], |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6051 str(_REMOTE['DicomPort']), |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6052 '-aec', 'ORTHANC', |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6053 '-aet', 'ORTHANCTEST', # pretend to be the other orthanc |
307 | 6054 '-k', '0020,000d=2.16.840.1.113669.632.20.1211.10000357775', |
306
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6055 '-k', '0008,0052=STUDY', |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6056 '--output-directory', '/tmp/GETSCU/' |
da2be3ff2db5
fix getscu binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
296
diff
changeset
|
6057 ], env = env) |
295 | 6058 |
311 | 6059 f1 = '/tmp/GETSCU/MR.1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549' |
6060 self.assertTrue(os.path.isfile(f1)) | |
6061 with open(f1, 'rb') as f: | |
6062 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(f.read())) | |
6063 | |
307 | 6064 CleanTarget() |
295 | 6065 |
6066 # transcoding required | |
311 | 6067 UploadInstance(_REMOTE, 'TransferSyntaxes/1.2.840.10008.1.2.4.50.dcm') |
307 | 6068 |
6069 subprocess.check_call([ | |
6070 FindExecutable('getscu'), | |
6071 _REMOTE['Server'], | |
6072 str(_REMOTE['DicomPort']), | |
6073 '-aec', 'ORTHANC', | |
6074 '-aet', 'ORTHANCTEST', # pretend to be the other orthanc | |
311 | 6075 '-k', '0020,000d=2.16.840.1.113669.632.20.1211.10000357775\\1.2.840.113663.1298.6234813.1.298.20000329.1115122', |
307 | 6076 '-k', '0008,0052=STUDY', |
6077 '--output-directory', '/tmp/GETSCU/' | |
6078 ], env = env) | |
6079 | |
311 | 6080 self.assertTrue(os.path.isfile(f1)) |
6081 with open(f1, 'rb') as f: | |
6082 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(f.read())) | |
6083 | |
6084 # This file is transcoded from "1.2.840.10008.1.2.4.50" to "1.2.840.10008.1.2.1" | |
6085 # (LittleEndianExplicit is proposed by default by "getscu") | |
6086 f2 = '/tmp/GETSCU/US.1.2.840.113663.1298.1.3.715.20000329.1115326' | |
6087 self.assertTrue(os.path.isfile(f2)) | |
6088 with open(f2, 'rb') as f: | |
6089 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(f.read())) | |
324
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6090 |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6091 |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6092 def test_findscu_truncation(self): |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6093 # https://groups.google.com/forum/#!msg/orthanc-users/FkckWAHvso8/UbRBAhQ5CwAJ |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6094 # Fixed by: https://hg.orthanc-server.com/orthanc/rev/2724977419fb |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6095 UploadInstance(_REMOTE, 'Multiframe.dcm') |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6096 UploadInstance(_REMOTE, 'ColorTestImageJ.dcm') |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6097 |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6098 study = '1.3.46.670589.7.5.8.80001255161.20000323.151537.1' |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6099 |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6100 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', 'StudyInstanceUID' ]) |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6101 result = re.findall('\(0020,000d\).*?\[(.*?)\]', i) |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6102 self.assertEqual(2, len(result)) |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6103 |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6104 # The "StudyInstanceUID" is set as a list of 5 times the same |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6105 # study, leading to a string of 249 characters |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6106 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6107 'StudyInstanceUID=%s\\%s\\%s\\%s\\%s' % (( study, ) * 5) ]) |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6108 result = re.findall('\(0020,000d\).*?\[(.*?)\]', i) |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6109 self.assertEqual(1, len(result)) |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6110 |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6111 # The "StudyInstanceUID" is set as a list of 6 times the same |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6112 # study, leading to a string of 299 characters. In Orthanc <= |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6113 # 1.7.2, this is above the value of ORTHANC_MAXIMUM_TAG_LENGTH |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6114 # == 256, and is thus wiped out by C-FIND SCP. As a |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6115 # consequence, Orthanc <= 1.7.2 doesn't apply the filter on |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6116 # "StudyInstanceUID" and returns all the available |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6117 # studies (i.e. 2). This issue was fixed in Orthanc 1.7.3. |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6118 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6119 'StudyInstanceUID=%s\\%s\\%s\\%s\\%s\\%s' % (( study, ) * 6) ]) |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6120 result = re.findall('\(0020,000d\).*?\[(.*?)\]', i) |
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6121 self.assertEqual(1, len(result)) |
328
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6122 |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6123 |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6124 def test_store_compressed(self): |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6125 with open(GetDatabasePath('DummyCT.dcm'), 'rb') as f: |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6126 dicom = f.read() |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6127 i = DoPost(_REMOTE, '/instances', dicom) ['ID'] |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6128 sourceSize = len(dicom) |
324
6164d39399ad
test_findscu_truncation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
323
diff
changeset
|
6129 |
328
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6130 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6131 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6132 |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6133 # Sending to the local Orthanc 0.8.6 server, without compression: OK |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6134 jobId = MonitorJob2(_REMOTE, lambda: DoPost( |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6135 _REMOTE, '/peers/peer/store', { |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6136 'Resources' : [ i ], |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6137 'Synchronous' : False, |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6138 })) |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6139 |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6140 job = DoGet(_REMOTE, '/jobs/%s' % jobId) |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6141 self.assertFalse(job['Content']['Compress']) |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6142 self.assertEqual('', job['Content']['Peer'][2]) # Password must not be reported |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6143 self.assertEqual(str(sourceSize), job['Content']['Size']) |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6144 |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6145 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6146 DropOrthanc(_LOCAL) |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6147 |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6148 # Sending to the local Orthanc 0.8.6 server, with compression: |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6149 # Not supported by Orthanc 0.8.6 => failure |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6150 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/peers/peer/store', { |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6151 'Resources' : [ i ], |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6152 'Compress' : True, |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6153 })) |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6154 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6155 |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6156 # Sending to the tested remote server, with compression: OK |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6157 jobId = MonitorJob2(_REMOTE, lambda: DoPost( |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6158 _REMOTE, '/peers/self/store', { |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6159 'Resources' : [ i ], |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6160 'Compress' : True, |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6161 'Synchronous' : False, |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6162 })) |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6163 |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6164 job = DoGet(_REMOTE, '/jobs/%s' % jobId) |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6165 self.assertTrue(job['Content']['Compress']) |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6166 |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6167 # Compression must have divided the size of the sent data at least twice |
8a462f9c5a97
test_store_compressed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
327
diff
changeset
|
6168 self.assertLess(int(job['Content']['Size']), sourceSize / 2) |
332 | 6169 |
6170 | |
6171 def test_move_ambra(self): | |
6172 # "Orthanc + Ambra: Query/Retrieve" (2020-08-25) | |
6173 # https://groups.google.com/g/orthanc-users/c/yIUnZ9v9-Zs/m/GQPXiAOiCQAJ | |
6174 | |
6175 UploadInstance(_REMOTE, '2019-06-17-VedranZdesic.dcm') | |
6176 | |
6177 self.assertFalse(MonitorJob(_REMOTE, lambda: CallMoveScu([ | |
6178 '--study', | |
6179 '-k', 'StudyInstanceUID=' | |
6180 ]))) | |
6181 | |
6182 self.assertFalse(MonitorJob(_REMOTE, lambda: CallMoveScu([ | |
6183 '--study', | |
6184 '-k', 'AccessionNumber=', | |
6185 ]))) | |
6186 | |
6187 self.assertFalse(MonitorJob(_REMOTE, lambda: CallMoveScu([ | |
6188 '--study', | |
6189 '-k', 'AccessionNumber=', | |
6190 '-k', 'StudyInstanceUID=' | |
6191 ]))) | |
6192 | |
6193 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
6194 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ | |
6195 '--study', | |
6196 '-k', 'AccessionNumber=CT16000988', | |
6197 '-k', 'StudyInstanceUID=', | |
6198 ]))) | |
6199 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
6200 DropOrthanc(_LOCAL) | |
6201 | |
6202 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
6203 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ | |
6204 '--study', | |
6205 '-k', 'AccessionNumber=CT16000988', | |
6206 '-k', 'StudyInstanceUID=1.2.840.113619.2.278.3.4194965761.659.1468842739.39', | |
6207 ]))) | |
6208 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
6209 DropOrthanc(_LOCAL) | |
6210 | |
6211 # This fails on Orthanc <= 1.7.3 | |
6212 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | |
6213 self.assertTrue(MonitorJob(_REMOTE, lambda: CallMoveScu([ | |
6214 '--study', | |
6215 '-k', 'AccessionNumber=', | |
6216 '-k', 'StudyInstanceUID=1.2.840.113619.2.278.3.4194965761.659.1468842739.39' | |
6217 ]))) | |
6218 self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) | |
6219 DropOrthanc(_LOCAL) | |
333
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6220 |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6221 |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6222 def test_decode_elscint(self): |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6223 # https://groups.google.com/g/orthanc-users/c/d9anAx6lSis/m/qEzm1x3PAAAJ |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6224 a = UploadInstance(_REMOTE, '2020-09-12-ELSCINT1-PMSCT_RLE1.dcm')['ID'] |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6225 b = UploadInstance(_REMOTE, '2020-09-11-Christopher-ELSCINT1-Raw.dcm')['ID'] |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6226 |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6227 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % a) |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6228 self.assertEqual("L", im.mode) |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6229 self.assertEqual(512, im.size[0]) |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6230 self.assertEqual(512, im.size[1]) |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6231 |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6232 im = GetImage(_REMOTE, '/instances/%s/frames/0/preview' % b) |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6233 self.assertEqual("L", im.mode) |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6234 self.assertEqual(512, im.size[0]) |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6235 self.assertEqual(512, im.size[1]) |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6236 |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6237 # The two tests below fail on Orthanc <= 1.7.3 |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6238 raw = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % a) |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6239 self.assertEqual(512 * 512 * 2, len(raw)) |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6240 |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6241 raw = DoGet(_REMOTE, '/instances/%s/frames/0/raw' % b) |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6242 self.assertEqual(512 * 512 * 2, len(raw)) |
695be643b0f4
test_decode_elscint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
332
diff
changeset
|
6243 |
334
971ff285302b
test_rest_modalities_in_study_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
333
diff
changeset
|
6244 |
971ff285302b
test_rest_modalities_in_study_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
333
diff
changeset
|
6245 def test_rest_modalities_in_study_2(self): |
971ff285302b
test_rest_modalities_in_study_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
333
diff
changeset
|
6246 # Problem reported by Alain Mazy on 2020-09-15 |
971ff285302b
test_rest_modalities_in_study_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
333
diff
changeset
|
6247 UploadInstance(_REMOTE, 'Comunix/Ct/IM-0001-0001.dcm') |
971ff285302b
test_rest_modalities_in_study_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
333
diff
changeset
|
6248 UploadInstance(_REMOTE, 'Comunix/Pet/IM-0001-0001.dcm') |
971ff285302b
test_rest_modalities_in_study_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
333
diff
changeset
|
6249 |
335
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6250 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', '0020,000d=', '-k', '0008,0061=' ]) |
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6251 modalitiesInStudy = re.findall('\(0008,0061\).*?\[(.*?)\]', i) |
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6252 self.assertEqual(1, len(modalitiesInStudy)) |
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6253 self.assertEqual('CT\\PT ', modalitiesInStudy[0]) |
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6254 |
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6255 for i in [ '', 'CT', 'PT', 'UX', 'UX\\MR', 'CT\\PT', 'UX\\PT', 'CT\\PT', 'UX\\CT\\PT' ]: |
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6256 # The empty string '' corresponds to universal matching. |
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6257 # The case where "i == 'CT'" failed in Orthanc <= 1.7.3. |
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6258 |
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6259 if i in [ 'UX', 'UX\\MR' ]: |
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6260 expected = 0 |
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6261 else: |
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6262 expected = 1 |
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6263 |
334
971ff285302b
test_rest_modalities_in_study_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
333
diff
changeset
|
6264 a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study', |
971ff285302b
test_rest_modalities_in_study_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
333
diff
changeset
|
6265 'Query' : { 'ModalitiesInStudy' : i }}) |
335
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6266 self.assertEqual(expected, len(a)) |
334
971ff285302b
test_rest_modalities_in_study_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
333
diff
changeset
|
6267 |
971ff285302b
test_rest_modalities_in_study_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
333
diff
changeset
|
6268 i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', '0020,000d=', '-k', '0008,0061=%s' % i ]) |
971ff285302b
test_rest_modalities_in_study_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
333
diff
changeset
|
6269 studyInstanceUid = re.findall('\(0020,000d\).*?\[(.*?)\]', i) |
335
96718de2f29c
simplification and fix of test_incoming_findscu
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
6270 self.assertEqual(expected, len(studyInstanceUid)) |
337
ec13ace43bde
trying webdav tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
335
diff
changeset
|
6271 |
ec13ace43bde
trying webdav tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
335
diff
changeset
|
6272 |
ec13ace43bde
trying webdav tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
335
diff
changeset
|
6273 def test_webdav(self): |
ec13ace43bde
trying webdav tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
335
diff
changeset
|
6274 self.assertRaises(Exception, lambda: DoPropFind(_REMOTE, '/webdav/', 2)) |
ec13ace43bde
trying webdav tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
335
diff
changeset
|
6275 |
342
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6276 for suffix in [ '', '/' ]: |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6277 f = DoPropFind(_REMOTE, '/webdav' + suffix, 0) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6278 self.assertEqual(1, len(f)) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6279 self.assertTrue('/webdav/' in f.keys()) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6280 self.assertTrue(f['/webdav/']['folder']) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6281 self.assertEqual('webdav', f['/webdav/']['displayname']) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6282 |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6283 f = DoPropFind(_REMOTE, '/webdav' + suffix, 1) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6284 self.assertEqual(6, len(f)) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6285 self.assertTrue(f['/webdav/']['folder']) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6286 self.assertEqual('webdav', f['/webdav/']['displayname']) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6287 |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6288 for i in [ 'by-dates', 'by-patients', 'by-studies', 'by-uids', 'uploads' ]: |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6289 self.assertTrue(f['/webdav/%s' % i]['folder']) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6290 self.assertEqual(i, f['/webdav/%s' % i]['displayname']) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6291 |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6292 for depth in [ 0, 1 ]: |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6293 for suffix2 in [ '', '/' ]: |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6294 g = DoPropFind(_REMOTE, '/webdav/%s%s' % (i, suffix2), depth) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6295 |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6296 if i == 'uploads': |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6297 # Empty folders might still exist in "/uploads/" |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6298 self.assertTrue('/webdav/uploads/' in g) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6299 self.assertEqual('uploads', g['/webdav/uploads/']['displayname']) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6300 for j in g.items(): |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6301 self.assertTrue(g.items()[0][1]['folder']) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6302 else: |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6303 self.assertEqual(1, len(g)) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6304 self.assertEqual('/webdav/%s/' % i, g.items()[0][0]) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6305 self.assertTrue(g.items()[0][1]['folder']) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6306 self.assertEqual(i, g.items()[0][1]['displayname']) |
341
66a36befb208
extending Toolbox.DoPropFind()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
337
diff
changeset
|
6307 |
342
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6308 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6309 with open(GetDatabasePath('DummyCT.dcm'), 'rb') as f: |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6310 DoPut(_REMOTE, '/webdav/uploads/dummy', f.read(), 'text/plain') |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6311 |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6312 while len(DoGet(_REMOTE, '/patients')) == 0: |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6313 time.sleep(0.01) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
341
diff
changeset
|
6314 self.assertEqual(1, len(DoGet(_REMOTE, '/patients'))) |
337
ec13ace43bde
trying webdav tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
335
diff
changeset
|
6315 |
349
698898a93a10
test_log_categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
6316 |
698898a93a10
test_log_categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
6317 def test_log_categories(self): |
350 | 6318 original = DoGet(_REMOTE, '/tools/log-level-http') |
349
698898a93a10
test_log_categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
6319 |
350 | 6320 DoPut(_REMOTE, '/tools/log-level-http', 'default') |
6321 self.assertEqual('default', DoGet(_REMOTE, '/tools/log-level-http')) | |
349
698898a93a10
test_log_categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
6322 DoGet(_REMOTE, '/system') |
698898a93a10
test_log_categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
6323 |
350 | 6324 DoPut(_REMOTE, '/tools/log-level-http', 'verbose') |
6325 self.assertEqual('verbose', DoGet(_REMOTE, '/tools/log-level-http')) | |
349
698898a93a10
test_log_categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
6326 DoGet(_REMOTE, '/system') |
698898a93a10
test_log_categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
6327 |
350 | 6328 DoPut(_REMOTE, '/tools/log-level-http', 'trace') |
6329 self.assertEqual('trace', DoGet(_REMOTE, '/tools/log-level-http')) | |
349
698898a93a10
test_log_categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
6330 DoGet(_REMOTE, '/system') |
698898a93a10
test_log_categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
6331 |
350 | 6332 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/tools/log-level-http', 'nope')) |
349
698898a93a10
test_log_categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
6333 |
698898a93a10
test_log_categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
6334 # Switch back to the original log level |
350 | 6335 DoPut(_REMOTE, '/tools/log-level-http', original) |
6336 | |
6337 for c in [ 'generic', 'http', 'dicom', 'plugins', 'sqlite', 'lua', 'jobs' ]: | |
349
698898a93a10
test_log_categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
6338 DoPut(_REMOTE, '/tools/log-level-%s' % c, DoGet(_REMOTE, '/tools/log-level-%s' % c)) |
698898a93a10
test_log_categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
6339 |
698898a93a10
test_log_categories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
6340 self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/tools/log-level-nope', 'default')) |
357 | 6341 |
6342 | |
6343 def test_upload_zip(self): | |
6344 f = StringIO() | |
6345 with zipfile.ZipFile(f, 'w') as z: | |
6346 z.writestr('hello/world/invalid.txt', 'Hello world') | |
6347 with open(GetDatabasePath('DummyCT.dcm'), 'rb') as g: | |
6348 c = g.read() | |
6349 z.writestr('hello/world/dicom1.dcm', c) | |
6350 z.writestr('hello/world/dicom2.dcm', c) | |
6351 | |
6352 f.seek(0) | |
6353 i = DoPost(_REMOTE, '/instances', f.read()) | |
6354 | |
6355 self.assertEqual(2, len(i)) | |
6356 self.assertEqual(i[0], i[1]) | |
6357 self.assertEqual(6, len(i[0])) | |
6358 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', i[0]['ID']) | |
6359 self.assertEqual('f2635388-f01d497a-15f7c06b-ad7dba06-c4c599fe', i[0]['ParentSeries']) | |
6360 self.assertEqual('b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0', i[0]['ParentStudy']) | |
6361 self.assertEqual('6816cb19-844d5aee-85245eba-28e841e6-2414fae2', i[0]['ParentPatient']) | |
6362 self.assertEqual('/instances/66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', i[0]['Path']) | |
6363 | |
6364 # Both are "Success" (instead of one "AlreadyStored"), because "OverwriteInstance" is true | |
6365 self.assertEqual('Success', i[0]['Status']) | |
361
6cf5cc4d0a99
test_transfer_syntax_no_metaheader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
6366 |
6cf5cc4d0a99
test_transfer_syntax_no_metaheader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
6367 |
6cf5cc4d0a99
test_transfer_syntax_no_metaheader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
6368 def test_transfer_syntax_no_metaheader(self): |
6cf5cc4d0a99
test_transfer_syntax_no_metaheader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
6369 a = UploadInstance(_REMOTE, 'TransferSyntaxes/1.2.840.10008.1.2.dcm')['ID'] |
6cf5cc4d0a99
test_transfer_syntax_no_metaheader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
6370 m = DoGet(_REMOTE, '/instances/%s/metadata?expand' % a) |
6cf5cc4d0a99
test_transfer_syntax_no_metaheader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
6371 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', m['SopClassUid']) |
6cf5cc4d0a99
test_transfer_syntax_no_metaheader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
6372 |
6cf5cc4d0a99
test_transfer_syntax_no_metaheader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
6373 # This fails on Orthanc <= 1.8.1 |
6cf5cc4d0a99
test_transfer_syntax_no_metaheader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
6374 self.assertTrue('TransferSyntax' in m) |
6cf5cc4d0a99
test_transfer_syntax_no_metaheader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
6375 self.assertEqual('1.2.840.10008.1.2', m['TransferSyntax']) |
368
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6376 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6377 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6378 def test_upload_multipart_1(self): |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6379 # This tests the "Upload" button in Orthanc Explorer |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6380 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6381 def EncodeChunk(data, boundary, filename): |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6382 return (('--%s\r\n' + |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6383 'Content-Disposition : form-data ; name ="files[]" ; filename = "%s" \r\n' + |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6384 '\r\n%s\r\n') % (boundary, filename, data)) |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6385 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6386 with open(GetDatabasePath('DummyCT.dcm'), 'rb') as f: |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6387 dcm1 = f.read() |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6388 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6389 with open(GetDatabasePath('ColorTestMalaterre.dcm'), 'rb') as f: |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6390 dcm2 = f.read() |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6391 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6392 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6393 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6394 boundary = '----WebKitFormBoundarypJDNQqJPoXiorRmQ' |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6395 m = DoPost(_REMOTE, '/instances', (EncodeChunk(dcm1, boundary, 'DummyCT.dcm') + |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6396 EncodeChunk(dcm2, boundary, 'ColorTestMalaterre.dcm') + |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6397 '--' + boundary + '--'), headers = { |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6398 'Content-Type' : 'multipart/form-data ; boundary = %s ' % boundary, |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6399 'X-Requested-With' : 'XMLHttpRequest', |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6400 }) |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6401 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6402 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6403 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6404 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6405 def test_upload_multipart_2(self): |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6406 # This tests the "maxChunkSize" option of "jQuery File Upload |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6407 # 5.12", whose source code can be found in: |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6408 # "OrthancServer/OrthancExplorer/libs/jquery-file-upload/" |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6409 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6410 def EncodeBody(data, boundary, filename): |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6411 return (('--%s\r\n' + |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6412 'Content-Disposition: form-data; name="files[]"; filename="%s"\r\n' + |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6413 '\r\n%s\r\n--%s') % (boundary, filename, data, boundary)) |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6414 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6415 with open(GetDatabasePath('DummyCT.dcm'), 'rb') as f: |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6416 dcm = f.read() |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6417 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6418 with open(GetDatabasePath('ColorTestMalaterre.dcm'), 'rb') as f: |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6419 dcm2 = f.read() |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6420 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6421 boundary = '----WebKitFormBoundarypJDNQqJPoXiorRmQ' |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6422 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6423 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6424 m = DoPost(_REMOTE, '/instances', |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6425 EncodeBody(dcm[0:1000], boundary, 'DummyCT.dcm'), |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6426 headers = { |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6427 'Content-Type' : 'multipart/form-data; boundary=%s' % boundary, |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6428 'X-Requested-With' : 'XMLHttpRequest', |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6429 'X-File-Name' : 'DummyCT.dcm', |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6430 'X-File-Size' : str(len(dcm)), |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6431 }) |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6432 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6433 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6434 m = DoPost(_REMOTE, '/instances', |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6435 EncodeBody(dcm[1000:2000], boundary, 'DummyCT.dcm'), |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6436 headers = { |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6437 'Content-Type' : 'multipart/form-data; boundary=%s' % boundary, |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6438 'X-Requested-With' : 'XMLHttpRequest', |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6439 'X-File-Name' : 'DummyCT.dcm', |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6440 'X-File-Size' : str(len(dcm)), |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6441 }) |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6442 self.assertEqual(0, len(DoGet(_REMOTE, '/instances'))) |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6443 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6444 m = DoPost(_REMOTE, '/instances', |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6445 EncodeBody(dcm2, boundary, 'ColorTestMalaterre.dcm'), |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6446 headers = { |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6447 'Content-Type' : 'multipart/form-data; boundary=%s' % boundary, |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6448 'X-Requested-With' : 'XMLHttpRequest', |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6449 'X-File-Name' : 'ColorTestMalaterre.dcm', |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6450 'X-File-Size' : str(len(dcm2)), |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6451 }) |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6452 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6453 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6454 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6455 # Upload the last chunk => the file is now entirely available |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6456 m = DoPost(_REMOTE, '/instances', |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6457 EncodeBody(dcm[2000:len(dcm)], boundary, 'DummyCT.dcm'), |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6458 headers = { |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6459 'Content-Type' : 'multipart/form-data; boundary=%s' % boundary, |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6460 'X-Requested-With' : 'XMLHttpRequest', |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6461 'X-File-Name' : 'DummyCT.dcm', |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6462 'X-File-Size' : str(len(dcm)), |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6463 }) |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6464 |
2cc40121c3a8
test_upload_multipart_1 and test_upload_multipart_2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
363
diff
changeset
|
6465 self.assertEqual(2, len(DoGet(_REMOTE, '/instances'))) |
377
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6466 |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6467 |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6468 def test_pixel_data_offset(self): |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6469 # New in Orthanc 1.9.1 |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6470 def Check(path, offset): |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6471 i = UploadInstance(_REMOTE, path) ['ID'] |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6472 metadata = DoGetRaw(_REMOTE, '/instances/%s/metadata/PixelDataOffset' % i) [1] |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6473 self.assertEqual(offset, metadata) |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6474 |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6475 Check('ColorTestMalaterre.dcm', str(0x03a0)) |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6476 Check('TransferSyntaxes/1.2.840.10008.1.2.1.dcm', str(0x037c)) |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6477 Check('TransferSyntaxes/1.2.840.10008.1.2.2.dcm', str(0x03e8)) # Big endian |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6478 Check('TransferSyntaxes/1.2.840.10008.1.2.4.50.dcm', str(0x04ac)) |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6479 Check('TransferSyntaxes/1.2.840.10008.1.2.4.51.dcm', str(0x072c)) |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6480 Check('TransferSyntaxes/1.2.840.10008.1.2.4.57.dcm', str(0x0620)) |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6481 Check('TransferSyntaxes/1.2.840.10008.1.2.4.70.dcm', str(0x065a)) |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6482 Check('TransferSyntaxes/1.2.840.10008.1.2.4.80.dcm', str(0x0b46)) |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6483 Check('TransferSyntaxes/1.2.840.10008.1.2.4.81.dcm', str(0x073e)) |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6484 Check('TransferSyntaxes/1.2.840.10008.1.2.4.90.dcm', str(0x0b66)) |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6485 Check('TransferSyntaxes/1.2.840.10008.1.2.4.91.dcm', str(0x19b8)) |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6486 Check('TransferSyntaxes/1.2.840.10008.1.2.5.dcm', str(0x0b0a)) |
cc79fa4945da
test_pixel_data_offset
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
6487 Check('TransferSyntaxes/1.2.840.10008.1.2.dcm', '') # No valid DICOM preamble |
382
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6488 |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6489 |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6490 def test_peer_store_straight(self): |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6491 self.assertEqual(0, len(DoGet(_LOCAL, '/exports')['Exports'])) |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6492 self.assertEqual(0, len(DoGet(_REMOTE, '/exports')['Exports'])) |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6493 |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6494 peer = DoGet(_REMOTE, '/peers/peer/system') |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6495 self.assertEqual(3, len(peer)) |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6496 self.assertEqual(5, peer['DatabaseVersion']) |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6497 self.assertEqual('MyOrthanc', peer['Name']) |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6498 self.assertEqual('0.8.6', peer['Version']) |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6499 |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6500 with open(GetDatabasePath('DummyCT.dcm'), 'rb') as f: |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6501 j = DoPost(_REMOTE, '/peers/peer/store-straight', f.read(), 'application/dicom') |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6502 |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6503 # Remote server is Orthanc 0.8.6, thus "ParentPatient", |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6504 # "ParentStudy", "ParentSeries" are not reported |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6505 self.assertEqual(3, len(j)) |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6506 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', j['ID']) |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6507 self.assertEqual('/instances/66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', j['Path']) |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6508 self.assertEqual('Success', j['Status']) |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6509 |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6510 self.assertEqual(1, len(DoGet(_LOCAL, '/patients'))) |
a8dd562943a7
added test_peer_store_straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
6511 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
383 | 6512 |
6513 | |
6514 def test_cp246(self): | |
6515 # This fails on Orthanc <= 1.9.0 | |
6516 a = UploadInstance(_REMOTE, '2021-02-19-MalaterreCP246.dcm')['ID'] | |
6517 self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) | |
6518 | |
6519 tags = DoGet(_REMOTE, '/instances/%s/tags?short' % a) | |
6520 self.assertEqual('1.2.840.10008.5.1.4.1.1.128', tags['0008,0016']) | |
6521 self.assertEqual('1.3.12.2.1107.5.1.4.36085.2.0.517715415141633', tags['0008,0018']) | |
6522 self.assertEqual('1.2.840.113745.101000.1008000.38179.6792.6324567', tags['0020,000d']) | |
6523 self.assertEqual('1.3.12.2.1107.5.1.4.36085.2.0.517714246252254', tags['0020,000e']) | |
6524 | |
6525 study = DoGet(_REMOTE, '/instances/%s/study' % a) | |
6526 self.assertEqual(tags['0020,000d'], study['MainDicomTags']['StudyInstanceUID']) | |
6527 | |
6528 series = DoGet(_REMOTE, '/instances/%s/series' % a) | |
6529 self.assertEqual(tags['0020,000e'], series['MainDicomTags']['SeriesInstanceUID']) | |
6530 | |
6531 instance = DoGet(_REMOTE, '/instances/%s' % a) | |
6532 self.assertEqual(tags['0008,0018'], instance['MainDicomTags']['SOPInstanceUID']) | |
6533 |