annotate Plugins/DicomWeb/Run.py @ 381:fd6d805eae37

new option "Timeout" in DICOMweb
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 23 Feb 2021 14:11:21 +0100
parents 9d2a63afdb73
children 344dafb7c9ff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #!/usr/bin/python
224
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
2 # -*- coding: utf-8 -*-
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
3
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # Orthanc - A Lightweight, RESTful DICOM Store
73
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 33
diff changeset
6 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 # Department, University Hospital of Liege, Belgium
363
79ce0f7a9714 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
8 # Copyright (C) 2017-2021 Osimis S.A., Belgium
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 #
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 # This program is free software: you can redistribute it and/or
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 # modify it under the terms of the GNU General Public License as
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 # published by the Free Software Foundation, either version 3 of the
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 # License, or (at your option) any later version.
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 #
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 # This program is distributed in the hope that it will be useful, but
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 # General Public License for more details.
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 #
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 # You should have received a copy of the GNU General Public License
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
24
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
25 # You must add the following to the configuration file:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
26 #
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
27 # "DicomWeb" : {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
28 # "Servers" : {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
29 # "sample" : [ "http://localhost:8042/dicom-web/", "alice", "orthanctest" ]
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
30 # }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
31 # }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
32
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
33
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
34
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
35 import copy
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 import os
33
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
37 import pprint
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 import sys
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 import argparse
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 import unittest
83
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
41 import re
304
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
42 from PIL import ImageChops
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
43
33
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
44 from DicomWeb import *
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'Tests'))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 from Toolbox import *
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 ##
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 ## Parse the command-line arguments
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 ##
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 parser = argparse.ArgumentParser(description = 'Run the integration tests for the DICOMweb plugin.')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 parser.add_argument('--server',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 default = 'localhost',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 help = 'Address of the Orthanc server to test')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 parser.add_argument('--rest',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 type = int,
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 default = 8042,
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 help = 'Port to the REST API')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 parser.add_argument('--username',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 default = 'alice',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 help = 'Username to the REST API')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 parser.add_argument('--password',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 default = 'orthanctest',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 help = 'Password to the REST API')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 parser.add_argument('--wado',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 default = '/wado',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 help = 'Path to the WADO API')
33
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
72 parser.add_argument('--dicomweb',
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 default = '/dicom-web/',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 help = 'Path to the DICOMweb API')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 parser.add_argument('--force', help = 'Do not warn the user',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 action = 'store_true')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 parser.add_argument('options', metavar = 'N', nargs = '*',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 help='Arguments to Python unittest')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 args = parser.parse_args()
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 ##
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 ## Configure the testing context
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 ##
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 if not args.force:
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 print("""
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 WARNING: This test will remove all the content of your
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 Orthanc instance running on %s!
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 Are you sure ["yes" to go on]?""" % args.server)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 if sys.stdin.readline().strip() != 'yes':
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 print('Aborting...')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 exit(0)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 ORTHANC = DefineOrthanc(server = args.server,
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 username = args.username,
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 password = args.password,
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 restPort = args.rest)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 ##
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 ## The tests
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 ##
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
249
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
109
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
110 def UploadAndGetWadoPath(dicom):
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
111 i = UploadInstance(ORTHANC, dicom) ['ID']
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
112 study = DoGet(ORTHANC, '/instances/%s/tags?simplify' % i) ['StudyInstanceUID']
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
113 series = DoGet(ORTHANC, '/instances/%s/tags?simplify' % i) ['SeriesInstanceUID']
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
114 instance = DoGet(ORTHANC, '/instances/%s/tags?simplify' % i) ['SOPInstanceUID']
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
115 return '/studies/%s/series/%s/instances/%s' % (study, series, instance)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
116
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
117
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
118
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 class Orthanc(unittest.TestCase):
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 def setUp(self):
83
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
121 if (sys.version_info >= (3, 0)):
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
122 # Remove annoying warnings about unclosed socket in Python 3
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
123 import warnings
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
124 warnings.simplefilter("ignore", ResourceWarning)
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
125
270
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
126 #print("In test: ", self._testMethodName)
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
127
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 DropOrthanc(ORTHANC)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 def test_wado_dicom(self):
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 UploadInstance(ORTHANC, 'Brainix/Flair/IM-0001-0001.dcm')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 SIZE = 169478
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 INSTANCE = '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549'
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 SERIES = '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497'
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 STUDY = '2.16.840.1.113669.632.20.1211.10000357775'
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado + '?requestType=WADO'))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado + '?objectUID=%s' % INSTANCE))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 dicom = DoGet(ORTHANC, args.wado + '?contentType=application/dicom&requestType=WADO&objectUID=%s' % INSTANCE)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 self.assertEqual(SIZE, len(dicom))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 dicom = DoGet(ORTHANC, args.wado + '?contentType=application/dicom&requestType=WADO&objectUID=%s&seriesUID=%s' % (INSTANCE, SERIES))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 self.assertEqual(SIZE, len(dicom))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 dicom = DoGet(ORTHANC, args.wado + '?contentType=application/dicom&requestType=WADO&objectUID=%s&seriesUID=%s&studyUID=%s' % (INSTANCE, SERIES, STUDY))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 self.assertEqual(SIZE, len(dicom))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 dicom = DoGet(ORTHANC, args.wado + '?contentType=application/dicom&requestType=WADO&objectUID=%s&seriesUID=%s' % (INSTANCE, SERIES))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 self.assertEqual(SIZE, len(dicom))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 dicom = DoGet(ORTHANC, args.wado + '?contentType=application/dicom&requestType=WADO&objectUID=%s&studyUID=%s' % (INSTANCE, STUDY))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 self.assertEqual(SIZE, len(dicom))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado + '?requestType=WADO&objectUID=%s&seriesUID=nope' % INSTANCE))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado + '?requestType=WADO&objectUID=%s&studyUID=nope' % INSTANCE))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado + '?requestType=WADO&objectUID=%s&seriesUID=nope&studyUID=nope' % INSTANCE))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 def test_wado_image(self):
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 UploadInstance(ORTHANC, 'Phenix/IM-0001-0001.dcm')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 INSTANCE = '1.2.840.113704.7.1.1.6632.1127829031.2'
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 im = GetImage(ORTHANC, args.wado + '?requestType=WADO&objectUID=%s' % INSTANCE)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 self.assertEqual('JPEG', im.format)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 self.assertEqual('L', im.mode)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 self.assertEqual(512, im.size[0])
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 self.assertEqual(358, im.size[1])
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 im = GetImage(ORTHANC, args.wado + '?contentType=image/jpg&requestType=WADO&objectUID=%s' % INSTANCE)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 self.assertEqual('JPEG', im.format)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 im = GetImage(ORTHANC, args.wado + '?contentType=image/png&requestType=WADO&objectUID=%s' % INSTANCE)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 self.assertEqual('PNG', im.format)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 self.assertEqual('L', im.mode)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 self.assertEqual(512, im.size[0])
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 self.assertEqual(358, im.size[1])
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179
33
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
180 def test_stow(self):
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
181 self.assertEqual(0, len(DoGet(ORTHANC, '/instances')))
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
182 SendStow(ORTHANC, args.dicomweb + '/studies', GetDatabasePath('Phenix/IM-0001-0001.dcm'))
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
183 self.assertEqual(1, len(DoGet(ORTHANC, '/instances')))
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
184 a = SendStow(ORTHANC, args.dicomweb + '/studies', GetDatabasePath('Phenix/IM-0001-0001.dcm'))
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
185 self.assertEqual(1, len(DoGet(ORTHANC, '/instances')))
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
186
227
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
187 self.assertEqual(4, len(a))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
188
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
189 # Specific character set
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
190 self.assertTrue('00080005' in a)
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
191 self.assertEqual('CS', a['00080005']['vr'])
33
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
192
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
193 self.assertTrue(a['00081190']['Value'][0].endswith('studies/2.16.840.1.113669.632.20.1211.10000098591'))
227
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
194 self.assertEqual('UR', a['00081190']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
195
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
196 self.assertFalse('Value' in a['00081198']) # No error => empty sequence
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
197 self.assertEqual('SQ', a['00081198']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
198
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
199 self.assertEqual(1, len(a['00081199']['Value'])) # 1 success
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
200 self.assertEqual('SQ', a['00081199']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
201
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
202 b = a['00081199']['Value'][0]
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
203
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
204 # Referenced SOP class UID
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
205 self.assertEqual('UI', b['00081150']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
206 self.assertEqual(1, len(b['00081150']['Value']))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
207 self.assertEqual('1.2.840.10008.5.1.4.1.1.2', b['00081150']['Value'][0])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
208
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
209 # Referenced SOP instance UID
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
210 self.assertEqual('UI', b['00081155']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
211 self.assertEqual(1, len(b['00081155']['Value']))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
212 self.assertEqual('1.2.840.113704.7.1.1.6632.1127829031.2', b['00081155']['Value'][0])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
213
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
214 # Retrieve URL
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
215 self.assertEqual('UR', b['00081190']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
216 self.assertEqual(1, len(b['00081190']['Value']))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
217 self.assertTrue(b['00081190']['Value'][0].
33
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
218 endswith('series/1.2.840.113704.1.111.5692.1127828999.2/instances/1.2.840.113704.7.1.1.6632.1127829031.2'))
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
219
83
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
220 # Remove the "http://localhost:8042" prefix
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
221 url = a['00081190']['Value'][0]
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
222 url = re.sub(r'(http|https)://[^/]+(/.*)', r'\2', url)
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
223
367
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
224 # Get the content-length of all the multiparts of this WADO-RS
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
225 # request (prevent transcoding by setting transfer-syntax to
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
226 # "*", necessary since release 1.5 of the DICOMweb plugin)
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
227 b = DoGet(ORTHANC, url, headers = {
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
228 'Accept' : 'multipart/related;type=application/dicom;transfer-syntax=*'
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
229 }).decode('utf-8', 'ignore')
83
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
230 parts = re.findall(r'^Content-Length:\s*(\d+)\s*', b, re.IGNORECASE | re.MULTILINE)
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
231 self.assertEqual(1, len(parts))
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
232 self.assertEqual(os.path.getsize(GetDatabasePath('Phenix/IM-0001-0001.dcm')), int(parts[0]))
33
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
233
227
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
234
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
235 def test_server_get(self):
277
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 276
diff changeset
236 try:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 276
diff changeset
237 DoDelete(ORTHANC, '/dicom-web/servers/google') # If "AllWindowsStart.sh" is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 276
diff changeset
238 except:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 276
diff changeset
239 pass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 276
diff changeset
240
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
241 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0001.dcm')
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
242
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
243 self.assertEqual(1, len(DoGet(ORTHANC, '/dicom-web/servers')))
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
244 self.assertTrue('sample' in DoGet(ORTHANC, '/dicom-web/servers'))
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
245
129
53d522dd4a38 added tests for ?expand in /dicom-web/servers route
amazy
parents: 114
diff changeset
246 serversReadback = DoGet(ORTHANC, '/dicom-web/servers?expand')
53d522dd4a38 added tests for ?expand in /dicom-web/servers route
amazy
parents: 114
diff changeset
247 self.assertEqual('http://localhost:8042/dicom-web/', serversReadback['sample']['Url'])
53d522dd4a38 added tests for ?expand in /dicom-web/servers route
amazy
parents: 114
diff changeset
248 self.assertEqual('alice', serversReadback['sample']['Username'])
53d522dd4a38 added tests for ?expand in /dicom-web/servers route
amazy
parents: 114
diff changeset
249
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
250 sample = DoGet(ORTHANC, '/dicom-web/servers/sample')
244
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
251 self.assertEqual(5, len(sample))
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
252 self.assertTrue('stow' in sample)
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
253 self.assertTrue('retrieve' in sample)
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
254 self.assertTrue('get' in sample)
244
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
255 self.assertTrue('wado' in sample) # New in 0.7
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
256 self.assertTrue('qido' in sample) # New in 0.7
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
257
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
258 # application/dicom+xml
131
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
259 self.assertEqual(2, len(re.findall('^--', DoGet(ORTHANC, '/dicom-web/studies',
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
260 headers = { 'Accept' : 'application/dicom+xml' }),
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
261 re.MULTILINE)))
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
262 self.assertEqual(2, len(re.findall('^--', DoPost
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
263 (ORTHANC, '/dicom-web/servers/sample/get',
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
264 { 'Uri' : '/studies',
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
265 'HttpHeaders' : { 'Accept' : 'application/dicom+xml' }
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
266 }), re.MULTILINE)))
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
267
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
268 # application/dicom+json
131
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
269 self.assertEqual(1, len(DoGet(ORTHANC, '/dicom-web/studies',
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
270 headers = { 'Accept' : 'application/dicom+json' })))
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
271 self.assertEqual(1, len(DoPost(ORTHANC, '/dicom-web/servers/sample/get',
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
272 { 'Uri' : '/studies',
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
273 'HttpHeaders' : { 'Accept' : 'application/dicom+json' }})))
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
274
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
275 # application/json
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
276 self.assertEqual(1, len(DoGet(ORTHANC, '/dicom-web/studies',
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
277 headers = { 'Accept' : 'application/json' })))
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
278 self.assertEqual(1, len(DoPost(ORTHANC, '/dicom-web/servers/sample/get',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
279 { 'Uri' : '/studies',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
280 'HttpHeaders' : { 'Accept' : 'application/json' }})))
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
281
131
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
282 # application/dicom+json is the default as of OrthancDicomWeb-0.5
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
283 self.assertEqual(1, len(DoGet(ORTHANC, '/dicom-web/studies')))
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
284 self.assertEqual(1, len(DoPost(ORTHANC, '/dicom-web/servers/sample/get',
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
285 { 'Uri' : '/studies' })))
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
286
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
287
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
288 def test_server_stow(self):
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
289 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0001.dcm')
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
290
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
291 self.assertRaises(Exception, lambda:
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
292 DoPost(ORTHANC, '/dicom-web/servers/sample/stow',
246
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
293 { 'Resources' : [ 'nope' ],
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
294 'Synchronous' : True })) # inexisting resource
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
295
246
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
296 l = 2 # For >= 0.7
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
297 #l = 0 # For <= 0.6
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
298
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
299 self.assertEqual(l, len(DoPost(ORTHANC, '/dicom-web/servers/sample/stow',
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
300 { 'Resources' : [ '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' ],
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
301 'Synchronous' : True }))) # study
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
302
246
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
303 self.assertEqual(l, len(DoPost(ORTHANC, '/dicom-web/servers/sample/stow',
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
304 { 'Resources' : [ '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' ],
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
305 'Synchronous' : True }))) # series
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
306
246
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
307 self.assertEqual(l, len(DoPost(ORTHANC, '/dicom-web/servers/sample/stow',
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
308 { 'Resources' : [ 'c8df6478-d7794217-0f11c293-a41237c9-31d98357' ],
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
309 'Synchronous' : True }))) # instance
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
310
246
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
311 self.assertEqual(l, len(DoPost(ORTHANC, '/dicom-web/servers/sample/stow',
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
312 { 'Resources' : [
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
313 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
314 '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
315 '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285',
246
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
316 'c8df6478-d7794217-0f11c293-a41237c9-31d98357' ],
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
317 'Synchronous' : True }))) # altogether
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
318
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
319
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
320 def test_server_retrieve(self):
244
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
321 COUNT = 'ReceivedInstancesCount'
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
322 #COUNT = 'Instances' # In version <= 0.6
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
323
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
324 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0001.dcm')
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
325 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0002.dcm')
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
326 UploadInstance(ORTHANC, 'Knee/T2/IM-0001-0001.dcm')
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
327
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
328 self.assertRaises(Exception, lambda:
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
329 DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
330 { 'Resources' : [ { 'Study' : 'nope' } ]})) # inexisting resource
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
331
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
332 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
333 { 'Resources' : [ { 'Study' : '2.16.840.1.113669.632.20.121711.10000160881' } ] })
244
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
334 self.assertEqual(3, int(t[COUNT]))
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
335
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
336 # Missing "Study" field
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
337 self.assertRaises(Exception, lambda:
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
338 DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
339 { 'Resources' : [ { 'Series' : '1.3.46.670589.11.17521.5.0.3124.2008081908564160709' } ]}))
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
340
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
341 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
342 { 'Resources' : [ { 'Study' : '2.16.840.1.113669.632.20.121711.10000160881',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
343 'Series' : '1.3.46.670589.11.17521.5.0.3124.2008081908564160709' } ] })
244
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
344 self.assertEqual(2, int(t[COUNT]))
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
345
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
346 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
347 { 'Resources' : [ { 'Study' : '2.16.840.1.113669.632.20.121711.10000160881',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
348 'Series' : '1.3.46.670589.11.17521.5.0.3124.2008081909090037350' } ] })
244
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
349 self.assertEqual(1, int(t[COUNT]))
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
350
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
351 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
352 { 'Resources' : [ { 'Study' : '2.16.840.1.113669.632.20.121711.10000160881',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
353 'Series' : '1.3.46.670589.11.17521.5.0.3124.2008081909090037350' },
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
354 { 'Study' : '2.16.840.1.113669.632.20.121711.10000160881',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
355 'Series' : '1.3.46.670589.11.17521.5.0.3124.2008081908564160709' } ] })
244
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
356 self.assertEqual(3, int(t[COUNT]))
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
357
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
358 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
359 { 'Resources' : [ { 'Study' : '2.16.840.1.113669.632.20.121711.10000160881',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
360 'Series' : '1.3.46.670589.11.17521.5.0.3124.2008081909090037350',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
361 'Instance' : '1.3.46.670589.11.17521.5.0.3124.2008081909113806560' } ] })
244
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 242
diff changeset
362 self.assertEqual(1, int(t[COUNT]))
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
363
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
364
114
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
365 def test_bitbucket_issue_53(self):
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
366 # DICOMWeb plugin support for "limit" and "offset" parameters in QIDO-RS
319
de6e73e4df60 leaving bitbucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 318
diff changeset
367 # https://bugs.orthanc-server.com/show_bug.cgi?id=53
114
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
368
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
369 UploadInstance(ORTHANC, 'Brainix/Flair/IM-0001-0001.dcm')
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
370 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0001.dcm')
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
371
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
372 brainix = '2.16.840.1.113669.632.20.1211.10000357775'
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
373 knee = '2.16.840.1.113669.632.20.121711.10000160881'
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
374
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
375 a = DoGet(ORTHANC, '/dicom-web/studies',
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
376 headers = { 'accept' : 'application/json' })
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
377 self.assertEqual(2, len(a))
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
378
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
379 b = []
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
380 a = DoGet(ORTHANC, '/dicom-web/studies?limit=1',
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
381 headers = { 'accept' : 'application/json' })
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
382 self.assertEqual(1, len(a))
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
383 b.append(a[0]['0020000D']['Value'][0])
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
384
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
385 a = DoGet(ORTHANC, '/dicom-web/studies?limit=1&offset=1',
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
386 headers = { 'accept' : 'application/json' })
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
387 self.assertEqual(1, len(a))
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
388 b.append(a[0]['0020000D']['Value'][0])
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
389
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
390 self.assertTrue(brainix in b)
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
391 self.assertTrue(knee in b)
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393
184
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
394 def test_bitbucket_issue_111(self):
223
f5aca0917d60 DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
395 # Wrong serialization of empty values
319
de6e73e4df60 leaving bitbucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 318
diff changeset
396 # https://bugs.orthanc-server.com/show_bug.cgi?id=111
de6e73e4df60 leaving bitbucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 318
diff changeset
397 # https://bitbucket.org/sjodogne/orthanc-dicomweb/issues/3
223
f5aca0917d60 DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
398
184
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
399 # According to the standard, section F.2.5
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
400 # (http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.2.5.html),
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
401 # null values behave as follows: If an attribute is present in
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
402 # DICOM but empty (i.e., Value Length is 0), it shall be
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
403 # preserved in the DICOM JSON attribute object containing no
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
404 # "Value", "BulkDataURI" or "InlineBinary".
319
de6e73e4df60 leaving bitbucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 318
diff changeset
405 # https://bugs.orthanc-server.com/show_bug.cgi?id=111
184
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
406
223
f5aca0917d60 DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
407 UploadInstance(ORTHANC, 'Issue111.dcm')
184
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
408
223
f5aca0917d60 DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
409 # Test WADO-RS
f5aca0917d60 DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
410 a = DoGet(ORTHANC, '/dicom-web/studies/1.2.276.0.7230010.3.1.2.8323329.30185.1551199973.371589/metadata')
f5aca0917d60 DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
411 self.assertEqual(1, len(a))
f5aca0917d60 DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
412 self.assertTrue('00080050' in a[0]) # AccessionNumber is null
f5aca0917d60 DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
413 self.assertEqual(1, len(a[0]['00080050'])) # 'vr' is the only field to be present
f5aca0917d60 DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
414 self.assertEqual('SH', a[0]['00080050']['vr'])
184
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
415
223
f5aca0917d60 DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
416 # Test QIDO-RS
f5aca0917d60 DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
417 a = DoGet(ORTHANC, '/dicom-web/studies')
184
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
418 self.assertEqual(1, len(a))
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
419 self.assertTrue('00080050' in a[0]) # AccessionNumber is null
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
420 self.assertEqual(1, len(a[0]['00080050'])) # 'vr' is the only field to be present
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
421 self.assertEqual('SH', a[0]['00080050']['vr'])
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
422
222
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
423
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
424 def test_wado_hierarchy(self):
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
425 def CheckJson(uri, headers = {}):
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
426 with open(GetDatabasePath('DummyCT.json'), 'r') as f:
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
427 expected = json.loads(f.read())
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
428 actual = DoGet(ORTHANC, uri, headers)
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
429 self.assertEqual(1, len(actual))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
430 AssertAlmostEqualRecursive(self, expected, actual[0])
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
431
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
432 UploadInstance(ORTHANC, 'DummyCT.dcm')
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
433 study = '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390'
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
434 series = '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394'
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
435 instance = '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109'
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
436
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
437 URI = '/dicom-web/studies/%s/series/%s/instances/%s/metadata'
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
438 self.assertRaises(Exception, lambda: DoGet(ORTHANC, URI % (study, series, instance),
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
439 headers = { 'accept' : 'application/nope' }))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
440
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
441 CheckJson(URI % (study, series, instance), headers = { 'accept' : 'application/dicom+json' })
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
442 CheckJson('/dicom-web/studies/%s/series/%s/metadata' % (study, series))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
443 CheckJson('/dicom-web/studies/%s/metadata' % study)
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
444
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
445 self.assertRaises(Exception, lambda: DoGet(ORTHANC, URI % ('nope', series, instance)))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
446 self.assertRaises(Exception, lambda: DoGet(ORTHANC, URI % (study, 'nope', instance)))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
447 self.assertRaises(Exception, lambda: DoGet(ORTHANC, URI % (study, series, 'nope')))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
448 self.assertRaises(Exception, lambda: DoGet(ORTHANC, '/dicom-web/studies/%s/series/%s/metadata' % ('nope', series)))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
449 self.assertRaises(Exception, lambda: DoGet(ORTHANC, '/dicom-web/studies/%s/series/%s/metadata' % (study, 'nope')))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
450 self.assertRaises(Exception, lambda: DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % 'nope'))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
451
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
452
228
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
453 def test_wado_pixel_data(self):
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
454 orthanc = UploadInstance(ORTHANC, 'Issue29.dcm') ['ID']
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
455 a = DoGet(ORTHANC, '/dicom-web/instances')
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
456 self.assertEqual(1, len(a))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
457 url = a[0]['00081190']['Value'][0]
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
458
278
514785dacd6d fix dicomweb tests with debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 277
diff changeset
459 prefix = 'http://%s:%s' % (args.server, args.rest)
228
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
460 self.assertTrue(url.startswith(prefix))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
461
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
462 b = DoGet(ORTHANC, url[len(prefix):] + '/metadata')
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
463 self.assertEqual('OB', b[0]['7FE00010']['vr'])
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
464 self.assertEqual(2, len(b[0]['7FE00010']))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
465 self.assertTrue('BulkDataURI' in b[0]['7FE00010'])
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
466
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
467 url = b[0]['7FE00010']['BulkDataURI']
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
468 self.assertTrue(url.startswith(prefix))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
469
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
470 p = DoGetMultipart(ORTHANC, url[len(prefix):])
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
471
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
472 self.assertEqual(2, len(p)) # There are 2 fragments in this image
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
473 self.assertEqual(4, len(p[0]))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
474 self.assertEqual(114486, len(p[1]))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
475
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
476
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
477 def test_wado_hierarchy_bulk(self):
222
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
478 def CheckBulk(value, bulk):
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
479 self.assertEqual(2, len(value))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
480 self.assertTrue('BulkDataURI' in value)
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
481 self.assertTrue('vr' in value)
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
482 self.assertEqual(value['BulkDataURI'], bulk)
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
483
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
484 orthanc = UploadInstance(ORTHANC, 'PrivateTags.dcm') ['ID']
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
485 study = '1.2.840.113619.2.115.147416.1094281639.0.29'
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
486 series = '1.2.840.113619.2.115.147416.1094281639.0.30'
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
487 sop = '1.2.840.113619.2.115.147416.1094281639.0.38'
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
488
228
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
489 # WARNING: This test will fail on Orthanc <= 1.5.5, because
319
de6e73e4df60 leaving bitbucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 318
diff changeset
490 # the following fix was not included yet:
de6e73e4df60 leaving bitbucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 318
diff changeset
491 # https://hg.orthanc-server.com/orthanc/rev/b88937ef597b
228
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
492
222
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
493 a = DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study)
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
494 self.assertEqual(1, len(a))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
495
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
496 BASE_URI = '/dicom-web/studies/%s/series/%s/instances/%s/bulk' % (study, series, sop)
278
514785dacd6d fix dicomweb tests with debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 277
diff changeset
497 BASE_URL = 'http://%s:%s%s' % (args.server, args.rest, BASE_URI)
222
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
498
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
499 self.assertEqual(2, len(a[0]['60031010']['Value']))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
500 CheckBulk(a[0]['60031010']['Value'][0]['60031011'], '%s/60031010/1/60031011' % BASE_URL)
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
501 CheckBulk(a[0]['60031010']['Value'][1]['60031011'], '%s/60031010/2/60031011' % BASE_URL)
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
502 CheckBulk(a[0]['7FE00010'], '%s/7fe00010' % BASE_URL)
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
503
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
504 b = DoGetRaw(ORTHANC, '/instances/%s/content/6003-1010/0/6003-1011' % orthanc) [1]
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
505 c = DoGetMultipart(ORTHANC, '%s/60031010/1/60031011' % BASE_URI)
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
506
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
507 self.assertEqual(12288, len(b))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
508 self.assertEqual(1, len(c))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
509 self.assertEqual(b, c[0])
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
510
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
511
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
512 def test_bitbucket_issue_112(self):
223
f5aca0917d60 DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
513 # Wrong serialization of number values
319
de6e73e4df60 leaving bitbucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 318
diff changeset
514 # https://bugs.orthanc-server.com/show_bug.cgi?id=112
222
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
515 # https://bitbucket.org/sjodogne/orthanc-dicomweb/issues/4/
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
516
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
517 UploadInstance(ORTHANC, 'DummyCT.dcm')
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
518 study = '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390'
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
519
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
520 # This is the WADO-RS testing
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
521 a = DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study)
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
522 self.assertEqual(1, len(a))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
523 self.assertEqual('IS', a[0]['00180091']['vr']) # EchoTrainLength
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
524
226
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
525 if (sys.version_info >= (3, 0)):
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
526 types = (int)
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
527 else:
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
528 types = (int, long)
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
529
222
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
530 b = a[0]['00180091']['Value'][0]
226
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
531 self.assertTrue(isinstance(b, types))
222
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
532 self.assertEqual(10, b)
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
533
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
534 # This is the QIDO-RS testing
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
535 a = DoGet(ORTHANC, '/dicom-web/studies')
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
536 self.assertEqual(1, len(a))
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
537 self.assertEqual('IS', a[0]['00201208']['vr']) # Number of Study Related Instances
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
538
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
539 b = a[0]['00201208']['Value'][0]
226
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
540 self.assertTrue(isinstance(b, types))
222
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
541 self.assertEqual(1, b)
223
f5aca0917d60 DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
542
222
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
543
224
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
544 def test_bitbucket_issue_113(self):
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
545 # Wrong serialization of PN VR
319
de6e73e4df60 leaving bitbucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 318
diff changeset
546 # https://bugs.orthanc-server.com/show_bug.cgi?id=113
224
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
547 # https://bitbucket.org/sjodogne/orthanc-dicomweb/issues/2/
314
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
548
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
549 # Make sure UTF-8 encoding is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
550 self.assertEqual('Utf8', DoPut(ORTHANC, '/tools/default-encoding', 'Utf8'))
224
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
551
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
552 UploadInstance(ORTHANC, 'Encodings/DavidClunie/SCSX1')
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
553 study = '1.3.6.1.4.1.5962.1.2.0.1175775771.5711.0'
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
554
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
555 # This is the WADO-RS testing
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
556 a = DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study)
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
557 self.assertEqual(1, len(a))
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
558
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
559 pn = a[0]['00100010'] # Patient name
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
560 self.assertEqual('PN', pn['vr'])
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
561 self.assertEqual(1, len(pn['Value']))
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
562 self.assertEqual('Wang^XiaoDong', pn['Value'][0]['Alphabetic'])
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
563 self.assertEqual(u'王^小東', pn['Value'][0]['Ideographic'])
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
564
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
565 # This is the QIDO-RS testing
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
566 a = DoGet(ORTHANC, '/dicom-web/studies')
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
567 self.assertEqual(1, len(a))
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
568
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
569 pn = a[0]['00100010'] # Patient name
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
570 self.assertEqual('PN', pn['vr'])
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
571 self.assertEqual(1, len(pn['Value']))
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
572 self.assertEqual('Wang^XiaoDong', pn['Value'][0]['Alphabetic'])
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
573 self.assertEqual(u'王^小東', pn['Value'][0]['Ideographic'])
f5414254ccaa test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
574
222
0f03ee6ffa80 DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 195
diff changeset
575
225
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
576 def test_bitbucket_issue_96(self):
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
577 # WADO-RS RetrieveFrames rejects valid accept headers
319
de6e73e4df60 leaving bitbucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 318
diff changeset
578 # https://bugs.orthanc-server.com/show_bug.cgi?id=96
225
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
579 # https://bitbucket.org/sjodogne/orthanc-dicomweb/issues/5/
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
580
228
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
581 UploadInstance(ORTHANC, 'Brainix/Epi/IM-0001-0001.dcm')
225
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
582
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
583 a = DoGet(ORTHANC, '/dicom-web/instances')
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
584 self.assertEqual(1, len(a))
228
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
585 self.assertEqual(256, a[0]['00280010']['Value'][0]) # Rows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
586 self.assertEqual(256, a[0]['00280011']['Value'][0]) # Columns
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
587 self.assertEqual(16, a[0]['00280100']['Value'][0]) # Bits allocated
226
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
588
225
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
589 url = a[0]['00081190']['Value'][0]
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
590
278
514785dacd6d fix dicomweb tests with debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 277
diff changeset
591 prefix = 'http://%s:%s' % (args.server, args.rest)
225
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
592 self.assertTrue(url.startswith(prefix))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
593 uri = url[len(prefix):]
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
594
226
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
595 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 0)))
228
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
596 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 2)))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
597
226
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
598 b = DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 1))
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
599 self.assertEqual(1, len(b))
228
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
600 self.assertEqual(256 * 256 * 2, len(b[0]))
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
601 self.assertEqual('ce394eb4d4de4eeef348436108101f3b', ComputeMD5(b[0]))
225
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
602
228
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
603 c = DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 1),
226
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
604 headers = { 'Accept' : 'multipart/related; type=application/octet-stream' })
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
605 self.assertEqual(1, len(c))
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
606 self.assertEqual(b[0], c[0])
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
607 self.assertEqual('ce394eb4d4de4eeef348436108101f3b', ComputeMD5(c[0]))
226
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
608
228
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
609 c = DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 1),
226
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
610 headers = { 'Accept' : 'multipart/related; type="application/octet-stream"' })
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
611 self.assertEqual(1, len(c))
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
612 self.assertEqual(b[0], c[0])
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
613 self.assertEqual('ce394eb4d4de4eeef348436108101f3b', ComputeMD5(c[0]))
227
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
614
228
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
615 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 1),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
616 headers = { 'Accept' : 'multipart/related; type="nope"' }))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
617
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
618 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 1),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
619 headers = { 'Accept' : 'multipart/related; type=nope' }))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
620
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
621 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 1),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
622 headers = { 'Accept' : 'nope' }))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 227
diff changeset
623
227
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
624
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
625 def test_qido_fields(self):
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
626 UploadInstance(ORTHANC, 'DummyCT.dcm')
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
627
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
628 a = DoGet(ORTHANC, '/dicom-web/studies')
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
629 self.assertEqual(1, len(a))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
630 self.assertFalse('00280010' in a[0]) # Rows
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
631
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
632 a = DoGet(ORTHANC, '/dicom-web/studies?includefield=Rows')
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
633 self.assertEqual(1, len(a))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
634 self.assertTrue('00280010' in a[0])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
635 self.assertEqual(512, a[0]['00280010']['Value'][0])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
636
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
637 a = DoGet(ORTHANC, '/dicom-web/studies?Rows=128')
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
638 self.assertEqual(0, len(a))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
639
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
640 a = DoGet(ORTHANC, '/dicom-web/studies?Rows=512')
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
641 self.assertEqual(1, len(a))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
642 self.assertTrue('00280010' in a[0])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
643 self.assertEqual(512, a[0]['00280010']['Value'][0])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
644
226
230aede7f8d5 test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 225
diff changeset
645
227
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
646 def test_stow_errors(self):
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
647 # Pushing an instance to a study that is not its parent
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
648 a = SendStow(ORTHANC, args.dicomweb + '/studies/nope', GetDatabasePath('Phenix/IM-0001-0001.dcm'))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
649 self.assertEqual(3, len(a))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
650 self.assertTrue('00080005' in a)
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
651 self.assertEqual('CS', a['00080005']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
652 self.assertTrue('00081198' in a)
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
653 self.assertEqual('SQ', a['00081198']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
654 self.assertEqual(1, len(['00081198']))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
655 self.assertTrue('00081199' in a)
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
656 self.assertEqual('SQ', a['00081199']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
657 self.assertEqual(1, len(['00081199']))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
658
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
659 # Pushing an instance with missing tags
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
660 a = SendStow(ORTHANC, args.dicomweb + '/studies', GetDatabasePath('Issue111.dcm'))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
661 self.assertEqual(3, len(a))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
662 self.assertTrue('00080005' in a)
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
663 self.assertEqual('CS', a['00080005']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
664 self.assertTrue('00081198' in a)
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
665 self.assertEqual('SQ', a['00081198']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
666 self.assertEqual(1, len(['00081198']))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
667 self.assertTrue('00081199' in a)
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
668 self.assertEqual('SQ', a['00081199']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
669 self.assertEqual(1, len(['00081199']))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
670
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
671 # Pushing a file that is not in the DICOM format
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
672 a = SendStow(ORTHANC, args.dicomweb + '/studies', GetDatabasePath('Issue111.dump'))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
673 self.assertEqual(3, len(a))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
674 self.assertTrue('00080005' in a)
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
675 self.assertEqual('CS', a['00080005']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
676 self.assertTrue('00081198' in a)
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
677 self.assertEqual('SQ', a['00081198']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
678 self.assertEqual(1, len(['00081198']))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
679 self.assertTrue('00081199' in a)
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
680 self.assertEqual('SQ', a['00081199']['vr'])
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
681 self.assertEqual(1, len(['00081199']))
875ff7460ae8 test_qido_fields, test_stow_errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
682
239
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
683
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
684 def test_allowed_methods(self):
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
685 self.assertEqual(0, len(DoGet(ORTHANC, '/dicom-web/studies')))
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
686
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
687 with self.assertRaises(Exception) as e:
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
688 DoPut(ORTHANC, '/dicom-web/studies')
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
689
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
690 self.assertEqual(405, e.exception[0])
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
691 self.assertEqual("GET,POST", e.exception[1]['allow'])
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
692
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
693 with self.assertRaises(Exception) as e:
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
694 DoDelete(ORTHANC, '/dicom-web/studies')
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
695
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
696 self.assertEqual(405, e.exception[0])
8980bd19e31d dicomweb: test_allowed_methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 229
diff changeset
697 self.assertEqual("GET,POST", e.exception[1]['allow'])
241
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
698
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
699
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
700 def test_add_server(self):
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
701 try:
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
702 DoDelete(ORTHANC, '/dicom-web/servers/hello')
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
703 except:
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
704 pass
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
705
277
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 276
diff changeset
706 try:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 276
diff changeset
707 DoDelete(ORTHANC, '/dicom-web/servers/google') # If "AllWindowsStart.sh" is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 276
diff changeset
708 except:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 276
diff changeset
709 pass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 276
diff changeset
710
241
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
711 l = DoGet(ORTHANC, '/dicom-web/servers')
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
712 self.assertEqual(1, len(l))
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
713 self.assertTrue('sample' in l)
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
714
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
715 url = 'http://localhost:8042/dicom-web/'
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
716 DoPut(ORTHANC, '/dicom-web/servers/hello', {
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
717 'Url': url,
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
718 'HttpHeaders' : {
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
719 'Hello' : 'World'
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
720 },
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
721 'Username' : 'bob',
242
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 241
diff changeset
722 'Password' : 'password',
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 241
diff changeset
723 'UserProperty' : 'Test',
249
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
724 'HasDelete' : True,
381
fd6d805eae37 new option "Timeout" in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 367
diff changeset
725 'Timeout' : 66 # New in 1.6
241
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
726 })
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
727
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
728 l = DoGet(ORTHANC, '/dicom-web/servers')
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
729 self.assertEqual(2, len(l))
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
730 self.assertTrue('sample' in l)
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
731 self.assertTrue('hello' in l)
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
732
249
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
733 o = DoGet(ORTHANC, '/dicom-web/servers/sample')
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
734 self.assertEqual(5, len(o))
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
735 self.assertTrue('stow' in o)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
736 self.assertTrue('retrieve' in o)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
737 self.assertTrue('get' in o)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
738 self.assertTrue('wado' in o) # New in 0.7
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
739 self.assertTrue('qido' in o) # New in 0.7
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
740
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
741 o = DoGet(ORTHANC, '/dicom-web/servers/hello')
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
742 self.assertEqual(6, len(o))
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
743 self.assertTrue('stow' in o)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
744 self.assertTrue('retrieve' in o)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
745 self.assertTrue('get' in o)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
746 self.assertTrue('wado' in o) # New in 0.7
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
747 self.assertTrue('qido' in o) # New in 0.7
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
748 self.assertTrue('delete' in o) # New in 0.7
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
749
241
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
750 s = DoGet(ORTHANC, '/dicom-web/servers?expand')
381
fd6d805eae37 new option "Timeout" in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 367
diff changeset
751 self.assertEqual(8, len(s['hello']))
241
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
752 self.assertEqual(url, s['hello']['Url'])
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
753 self.assertEqual('bob', s['hello']['Username'])
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
754 self.assertEqual(None, s['hello']['Password'])
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
755 self.assertFalse(s['hello']['Pkcs11'])
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
756 self.assertEqual(1, len(s['hello']['HttpHeaders']))
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
757 self.assertTrue('Hello' in s['hello']['HttpHeaders'])
242
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 241
diff changeset
758 self.assertEqual('Test', s['hello']['UserProperty'])
249
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
759 self.assertEqual('1', s['hello']['HasDelete'])
381
fd6d805eae37 new option "Timeout" in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 367
diff changeset
760 self.assertEqual(66, s['hello']['Timeout']) # New in 1.6
241
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
761
adc6372b8820 dicomweb: test_add_server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 239
diff changeset
762 DoDelete(ORTHANC, '/dicom-web/servers/hello')
246
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
763
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
764
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
765 def test_bitbucket_issue_143(self):
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
766 # WADO-RS metadata request returns "500 Internal Server Error"
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
767 # instead of "404 Not Found" for missing instance
319
de6e73e4df60 leaving bitbucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 318
diff changeset
768 # https://bugs.orthanc-server.com/show_bug.cgi?id=143
246
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
769 UploadInstance(ORTHANC, 'Issue143.dcm')
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
770
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
771 try:
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
772 DoGet(ORTHANC, '/dicom-web/studies/1.2.840.113619.2.55.3.671756986.106.1316467036.460/series/1.2.840.113619.2.55.3.671756986.106.1316467036.465/instances/0.0.0.0.0/metadata')
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
773 self.assertFail()
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
774 except Exception as e:
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
775 self.assertEqual(404, e[0])
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
776
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
777 DoGet(ORTHANC, '/dicom-web/studies/1.3.6.1.4.1.34261.90254037371867.41912.1553085024.2/series/1.3.6.1.4.1.34261.90254037371867.41912.1553085024.3/instances/1.2.276.0.7230010.3.1.4.253549293.36648.1555586123.754/metadata')
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
778
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
779 try:
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
780 DoGet(ORTHANC, '/dicom-web/studies/0.0.0.0.0/series/1.3.6.1.4.1.34261.90254037371867.41912.1553085024.3/instances/1.2.276.0.7230010.3.1.4.253549293.36648.1555586123.754/metadata')
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
781 self.fail()
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
782 except Exception as e:
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
783 self.assertEqual(404, e[0])
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
784
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
785 try:
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
786 DoGet(ORTHANC, '/dicom-web/studies/1.3.6.1.4.1.34261.90254037371867.41912.1553085024.2/series/0.0.0.0.0/instances/1.2.276.0.7230010.3.1.4.253549293.36648.1555586123.754/metadata')
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
787 self.assertFail()
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
788 except Exception as e:
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
789 self.assertEqual(404, e[0])
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
790
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
791 try:
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
792 DoGet(ORTHANC, '/dicom-web/studies/0.0.0.0.0/series/0.0.0.0.0/instances/0.0.0.0.0/metadata')
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
793 self.assertFail()
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
794 except Exception as e:
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
795 self.assertEqual(404, e[0])
e4e0e2ff91ae test_bitbucket_issue_143
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 244
diff changeset
796
248
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
797
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
798 def test_encodings_qido(self):
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
799 # The "DefaultEncoding" condifuration option is set to "UTF8"
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
800 # in the integration tests, so all the QIDO-RS requests must
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
801 # lead to a "ISO_IR 192" specific character set
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
802 def GetPatientName(dicom, onlyAlphabetic):
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
803 i = UploadInstance(ORTHANC, dicom) ['ID']
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
804 j = DoGet(ORTHANC, '/instances/%s/tags?simplify' % i) ['StudyInstanceUID']
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
805 qido = DoGet(ORTHANC, '/dicom-web/studies?0020000D=%s' % j)
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
806 self.assertEqual(1, len(qido))
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
807 self.assertEqual('CS', qido[0]['00080005']['vr'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
808 self.assertEqual('ISO_IR 192', qido[0]['00080005']['Value'][0])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
809 if onlyAlphabetic:
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
810 self.assertEqual(1, len(qido[0]['00100010']['Value'][0]))
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
811 else:
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
812 self.assertEqual(3, len(qido[0]['00100010']['Value'][0]))
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
813 return qido[0]['00100010']['Value'][0]
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
814
314
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
815 # Make sure UTF-8 encoding is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
816 self.assertEqual('Utf8', DoPut(ORTHANC, '/tools/default-encoding', 'Utf8'))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 304
diff changeset
817
248
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
818 # Check out "test_issue_95_encodings" in "../../Tests/Tests.py"
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
819
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
820 self.assertEqual(u'Buc^Jérôme', GetPatientName('Encodings/DavidClunie/SCSFREN', True) ['Alphabetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
821 self.assertEqual(u'Äneas^Rüdiger', GetPatientName('Encodings/DavidClunie/SCSGERM', True)['Alphabetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
822 self.assertEqual(u'Διονυσιος', GetPatientName('Encodings/DavidClunie/SCSGREEK', True)['Alphabetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
823 self.assertEqual(u'Люкceмбypг', GetPatientName('Encodings/DavidClunie/SCSRUSS', True)['Alphabetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
824 self.assertEqual(u'שרון^דבורה', GetPatientName('Encodings/DavidClunie/SCSHBRW', True)['Alphabetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
825 self.assertEqual(u'قباني^لنزار', GetPatientName('Encodings/DavidClunie/SCSARAB', True)['Alphabetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
826
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
827 self.assertEqual(u'Hong^Gildong', GetPatientName('Encodings/DavidClunie/SCSI2', False)['Alphabetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
828 self.assertEqual(u'洪^吉洞', GetPatientName('Encodings/DavidClunie/SCSI2', False)['Ideographic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
829 self.assertEqual(u'홍^길동', GetPatientName('Encodings/DavidClunie/SCSI2', False)['Phonetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
830 self.assertEqual(u'Wang^XiaoDong', GetPatientName('Encodings/DavidClunie/SCSX2', False)['Alphabetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
831 self.assertEqual(u'王^小东', GetPatientName('Encodings/DavidClunie/SCSX2', False)['Ideographic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
832 self.assertEqual(u'', GetPatientName('Encodings/DavidClunie/SCSX2', False)['Phonetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
833 self.assertEqual(u'Wang^XiaoDong', GetPatientName('Encodings/DavidClunie/SCSX1', False)['Alphabetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
834 self.assertEqual(u'王^小東', GetPatientName('Encodings/DavidClunie/SCSX1', False)['Ideographic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
835 self.assertEqual(u'', GetPatientName('Encodings/DavidClunie/SCSX1', False)['Phonetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
836 self.assertEqual(u'Yamada^Tarou', GetPatientName('Encodings/DavidClunie/SCSH31', False)['Alphabetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
837 self.assertEqual(u'山田^太郎', GetPatientName('Encodings/DavidClunie/SCSH31', False)['Ideographic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
838 self.assertEqual(u'やまだ^たろう', GetPatientName('Encodings/DavidClunie/SCSH31', False)['Phonetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
839 self.assertEqual(u'ヤマダ^タロウ', GetPatientName('Encodings/DavidClunie/SCSH32', False)['Alphabetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
840
249
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
841 # TODO - Not supported yet by the Orthanc core as of 1.5.7
248
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
842 #self.assertEqual(u'山田^太郎', GetPatientName('Encodings/DavidClunie/SCSH32')['Ideographic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
843 #self.assertEqual(u'やまだ^たろう', GetPatientName('Encodings/DavidClunie/SCSH32')['Phonetic'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
844
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
845
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
846 def test_encodings_wado_metadata(self):
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
847 # If querying the instance metadata, the "DefaultEncoding"
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
848 # configuration is not used, but the actual encoding
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
849 def GetEncoding(dicom, length):
249
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
850 qido = DoGet(ORTHANC, '/dicom-web/%s/metadata' % UploadAndGetWadoPath(dicom))
248
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
851 self.assertEqual(1, len(qido))
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
852 self.assertEqual(length, len(qido[0]['00080005']['Value']))
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
853 self.assertEqual('CS', qido[0]['00080005']['vr'])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
854 return qido[0]['00080005']['Value']
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
855
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
856 self.assertEqual('ISO_IR 100', GetEncoding('Encodings/DavidClunie/SCSFREN', 1)[0])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
857 self.assertEqual('ISO_IR 100', GetEncoding('Encodings/DavidClunie/SCSGERM', 1)[0])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
858 self.assertEqual('ISO_IR 126', GetEncoding('Encodings/DavidClunie/SCSGREEK', 1)[0])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
859 self.assertEqual('ISO_IR 144', GetEncoding('Encodings/DavidClunie/SCSRUSS', 1)[0])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
860 self.assertEqual('ISO_IR 138', GetEncoding('Encodings/DavidClunie/SCSHBRW', 1)[0])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
861 self.assertEqual('ISO_IR 127', GetEncoding('Encodings/DavidClunie/SCSARAB', 1)[0])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
862 self.assertEqual('ISO 2022 IR 149', GetEncoding('Encodings/DavidClunie/SCSI2', 1)[0])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
863 self.assertEqual('GB18030', GetEncoding('Encodings/DavidClunie/SCSX2', 1)[0])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
864 self.assertEqual('ISO_IR 192', GetEncoding('Encodings/DavidClunie/SCSX1', 1)[0])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
865 self.assertEqual('ISO 2022 IR 87', GetEncoding('Encodings/DavidClunie/SCSH31', 1)[0])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
866 self.assertEqual('ISO 2022 IR 13', GetEncoding('Encodings/DavidClunie/SCSH32', 2)[0])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
867 self.assertEqual('ISO 2022 IR 87', GetEncoding('Encodings/DavidClunie/SCSH32', 2)[1])
26c3a1ed935a testing of encodings in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 246
diff changeset
868
249
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
869
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
870 def test_rendered(self):
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
871 def RenderFrame(path, i):
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
872 return DoPost(ORTHANC, '/dicom-web/servers/sample/get', {
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
873 'Uri' : '%s/frames/%d/rendered' % (path, i)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
874 })
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
875
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
876 # This image has 76 frames
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
877 path = UploadAndGetWadoPath('Multiframe.dcm')
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
878
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
879 self.assertRaises(Exception, lambda: RenderFrame(path, 0))
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
880
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
881 frame1 = RenderFrame(path, 1)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
882 im = UncompressImage(frame1)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
883 self.assertEqual("L", im.mode)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
884 self.assertEqual(512, im.size[0])
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
885 self.assertEqual(512, im.size[1])
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
886
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
887 im = UncompressImage(RenderFrame(path, 76))
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
888 self.assertEqual("L", im.mode)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
889 self.assertEqual(512, im.size[0])
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
890 self.assertEqual(512, im.size[1])
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
891
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
892 self.assertRaises(Exception, lambda: RenderFrame(path, 77))
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
893
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
894 defaultFrame = DoPost(ORTHANC, '/dicom-web/servers/sample/get', {
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
895 'Uri' : '%s/rendered' % path
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
896 })
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
897
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
898 self.assertEqual(len(frame1), len(defaultFrame))
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
899 self.assertEqual(frame1, defaultFrame)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
900
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
901
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
902 # This image has 1 frame
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
903 path = UploadAndGetWadoPath('Phenix/IM-0001-0001.dcm')
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
904
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
905 self.assertRaises(Exception, lambda: RenderFrame(path, 0))
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
906 self.assertRaises(Exception, lambda: RenderFrame(path, 2))
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
907
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
908 frame1 = RenderFrame(path, 1)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
909 im = UncompressImage(frame1)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
910 self.assertEqual("L", im.mode)
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
911 self.assertEqual(512, im.size[0])
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
912 self.assertEqual(358, im.size[1])
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
913
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
914 defaultFrame = DoPost(ORTHANC, '/dicom-web/servers/sample/get', {
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
915 'Uri' : '%s/rendered' % path
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
916 })
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
917
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
918 self.assertEqual(len(frame1), len(defaultFrame))
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
919 self.assertEqual(frame1, defaultFrame)
259
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
920
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
921
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
922 def test_qido_parent_attributes(self):
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
923 UploadInstance(ORTHANC, 'Brainix/Flair/IM-0001-0001.dcm')
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
924 study = '2.16.840.1.113669.632.20.1211.10000357775'
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
925 series = '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114285654497'
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
926 instance = '1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549'
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
927
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
928 a = DoGet(ORTHANC, '/dicom-web/studies')
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
929 self.assertEqual(1, len(a))
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
930 self.assertFalse('00080018' in a[0]) # SOPInstanceUID
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
931 self.assertFalse('0020000E' in a[0]) # SeriesInstanceUID
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
932 self.assertEqual(study, a[0]['0020000D']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
933 self.assertEqual('BRAINIX', a[0]['00100010']['Value'][0]['Alphabetic'])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
934
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
935 a = DoGet(ORTHANC, '/dicom-web/studies?0020000D=%s' % study)
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
936 self.assertEqual(1, len(a))
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
937 self.assertFalse('00080018' in a[0]) # SOPInstanceUID
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
938 self.assertFalse('0020000E' in a[0]) # SeriesInstanceUID
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
939 self.assertEqual(study, a[0]['0020000D']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
940 self.assertEqual('BRAINIX', a[0]['00100010']['Value'][0]['Alphabetic'])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
941
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
942 a = DoGet(ORTHANC, '/dicom-web/series')
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
943 self.assertEqual(1, len(a))
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
944 self.assertFalse('00080018' in a[0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
945 self.assertEqual(study, a[0]['0020000D']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
946 self.assertEqual(series, a[0]['0020000E']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
947 self.assertEqual('MR', a[0]['00080060']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
948 self.assertEqual('BRAINIX', a[0]['00100010']['Value'][0]['Alphabetic'])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
949
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
950 a = DoGet(ORTHANC, '/dicom-web/instances')
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
951 self.assertEqual(1, len(a))
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
952 self.assertEqual(study, a[0]['0020000D']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
953 self.assertEqual(series, a[0]['0020000E']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
954 self.assertEqual(instance, a[0]['00080018']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
955 self.assertEqual('MR', a[0]['00080060']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
956 self.assertEqual('BRAINIX', a[0]['00100010']['Value'][0]['Alphabetic'])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
957
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
958 a = DoGet(ORTHANC, '/dicom-web/studies/%s/series' % study)
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
959 self.assertEqual(1, len(a))
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
960 self.assertFalse('00080018' in a[0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
961 self.assertEqual(study, a[0]['0020000D']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
962 self.assertEqual(series, a[0]['0020000E']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
963 self.assertEqual('MR', a[0]['00080060']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
964 self.assertEqual('BRAINIX', a[0]['00100010']['Value'][0]['Alphabetic'])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
965
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
966 a = DoGet(ORTHANC, '/dicom-web/studies/%s/series/%s/instances' % (study, series))
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
967 self.assertEqual(1, len(a))
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
968 self.assertEqual(study, a[0]['0020000D']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
969 self.assertEqual(series, a[0]['0020000E']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
970 self.assertEqual(instance, a[0]['00080018']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
971 self.assertEqual('MR', a[0]['00080060']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
972 self.assertEqual('BRAINIX', a[0]['00100010']['Value'][0]['Alphabetic'])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
973
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
974 # "If {StudyInstanceUID} is not specified, all Study-level
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
975 # attributes specified in Table 6.7.1-2" => Here,
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
976 # {StudyInstanceUID} *is* specified, so we must *not* get the
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
977 # PatientName.
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
978 # http://dicom.nema.org/medical/dicom/2019a/output/html/part18.html#table_6.7.1-2a
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
979 a = DoGet(ORTHANC, '/dicom-web/series?0020000D=%s' % study)
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
980 self.assertEqual(1, len(a))
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
981 self.assertFalse('00100010' in a[0]) # PatientName
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
982 self.assertEqual(study, a[0]['0020000D']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
983 self.assertEqual(series, a[0]['0020000E']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
984 self.assertEqual('MR', a[0]['00080060']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
985
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
986 # http://dicom.nema.org/medical/dicom/2019a/output/html/part18.html#table_6.7.1-2b
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
987 a = DoGet(ORTHANC, '/dicom-web/instances?0020000D=%s' % study)
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
988 self.assertEqual(1, len(a))
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
989 self.assertFalse('00100010' in a[0]) # PatientName
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
990 self.assertEqual(study, a[0]['0020000D']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
991 self.assertEqual(series, a[0]['0020000E']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
992 self.assertEqual('MR', a[0]['00080060']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
993
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
994 a = DoGet(ORTHANC, '/dicom-web/instances?0020000E=%s' % series)
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
995 self.assertEqual(1, len(a))
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
996 self.assertFalse('00080060' in a[0]) # Modality
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
997 self.assertEqual(study, a[0]['0020000D']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
998 self.assertEqual(series, a[0]['0020000E']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
999 self.assertEqual('BRAINIX', a[0]['00100010']['Value'][0]['Alphabetic'])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
1000
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
1001 a = DoGet(ORTHANC, '/dicom-web/instances?0020000D=%s&0020000E=%s' % (study, series))
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
1002 self.assertEqual(1, len(a))
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
1003 self.assertFalse('00100010' in a[0]) # PatientName
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
1004 self.assertFalse('00080060' in a[0]) # Modality
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
1005 self.assertEqual(study, a[0]['0020000D']['Value'][0])
298f80c6ccc4 test_qido_parent_attributes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 249
diff changeset
1006 self.assertEqual(series, a[0]['0020000E']['Value'][0])
261
b8cdb0aef4b9 test_bitbucket_issue_164
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1007
b8cdb0aef4b9 test_bitbucket_issue_164
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1008
270
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1009 #@unittest.skip("Skip this test on GDCM 2.8.4")
261
b8cdb0aef4b9 test_bitbucket_issue_164
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1010 def test_bitbucket_issue_164(self):
270
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1011 # WARNING - This makes GDCM 2.8.4 crash
319
de6e73e4df60 leaving bitbucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 318
diff changeset
1012 # https://bugs.orthanc-server.com/show_bug.cgi?id=164
261
b8cdb0aef4b9 test_bitbucket_issue_164
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1013 UploadInstance(ORTHANC, 'Issue164.dcm')
b8cdb0aef4b9 test_bitbucket_issue_164
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1014
b8cdb0aef4b9 test_bitbucket_issue_164
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1015 p = DoGetMultipart(ORTHANC, 'dicom-web/studies/1.2.276.0.26.1.1.1.2.2020.45.52293.1506048/series/1.2.276.0.26.1.1.1.2.2020.45.52293.6384450/instances/1.2.276.0.26.1.1.1.2.2020.45.52366.2551599.179568640/frames/5')
b8cdb0aef4b9 test_bitbucket_issue_164
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1016 self.assertEqual(1, len(p))
b8cdb0aef4b9 test_bitbucket_issue_164
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1017 self.assertEqual(743 * 975 * 3, len(p[0]))
304
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1018
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1019 if HasGdcmPlugin(ORTHANC):
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1020 self.assertTrue(ComputeMD5(p[0]) in [
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1021 'b952d67da9ff004b0adae3982e89d620', # GDCM >= 3.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1022 'b3662c4bfa24a0c73abb08548c63319b' # Fallback to DCMTK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1023 ])
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1024 else:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1025 self.assertEqual('b3662c4bfa24a0c73abb08548c63319b', ComputeMD5(p[0])) # DCMTK
270
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1026
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1027
271
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 270
diff changeset
1028 def test_bitbucket_issue_168(self):
276
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 275
diff changeset
1029 # "Plugins can't read private tags from the configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 275
diff changeset
1030 # file" This test will fail if DCMTK <= 3.6.1 (e.g. on Ubuntu
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 275
diff changeset
1031 # 16.04), or if Orthanc <= 1.5.8
319
de6e73e4df60 leaving bitbucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 318
diff changeset
1032 # https://bugs.orthanc-server.com/show_bug.cgi?id=168
270
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1033
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1034 UploadInstance(ORTHANC, 'Issue168.dcm')
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1035
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1036 a = DoGet(ORTHANC, '/dicom-web/studies')
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1037 self.assertEqual(1, len(a))
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1038 self.assertFalse('00090010' in a[0])
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1039 self.assertFalse('00091001' in a[0])
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1040 self.assertEqual('20170404', a[0]['00080020']['Value'][0])
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1041
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1042 a = DoGet(ORTHANC, '/dicom-web/studies?includefield=00091001')
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1043 self.assertEqual(1, len(a))
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1044 self.assertFalse('00090010' in a[0])
325
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1045 self.assertTrue('00091001' in a[0]) # This fails if DCMTK <= 3.6.1
270
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1046 self.assertEqual('DS', a[0]['00091001']['vr'])
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1047 self.assertEqual(1, len(a[0]['00091001']['Value']))
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1048 self.assertAlmostEqual(98.41, a[0]['00091001']['Value'][0])
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1049
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1050 a = DoGet(ORTHANC, '/dicom-web/studies?00090010=Lunit&includefield=00091001')
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1051 self.assertEqual(1, len(a))
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1052 self.assertTrue('00090010' in a[0])
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1053 self.assertEqual('LO', a[0]['00090010']['vr'])
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1054 self.assertEqual(1, len(a[0]['00090010']['Value']))
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1055 self.assertEqual('Lunit', a[0]['00090010']['Value'][0])
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1056 self.assertTrue('00091001' in a[0])
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1057 self.assertEqual('DS', a[0]['00091001']['vr'])
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1058 self.assertEqual(1, len(a[0]['00091001']['Value']))
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1059 self.assertAlmostEqual(98.41, a[0]['00091001']['Value'][0])
249
24e5c8ca9440 DICOMweb: test_rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 248
diff changeset
1060
270
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1061 a = DoGet(ORTHANC, '/dicom-web/studies?00090010=Lunit2&includefield=00091001')
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1062 self.assertEqual(0, len(a))
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1063
082f35cb4459 test_bitbuck_issue_168
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1064
272
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1065 def test_rendered_studies_series(self):
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1066 i = UploadInstance(ORTHANC, 'Phenix/IM-0001-0001.dcm') ['ID']
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1067 study = DoGet(ORTHANC, '/instances/%s/tags?simplify' % i) ['StudyInstanceUID']
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1068 series = DoGet(ORTHANC, '/instances/%s/tags?simplify' % i) ['SeriesInstanceUID']
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1069 instance = DoGet(ORTHANC, '/instances/%s/tags?simplify' % i) ['SOPInstanceUID']
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1070
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1071 a = DoPost(ORTHANC, '/dicom-web/servers/sample/get', {
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1072 'Uri' : '/studies/%s/series/%s/instances/%s/rendered' % (study, series, instance)
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1073 })
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1074
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1075 im = UncompressImage(a)
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1076 self.assertEqual("L", im.mode)
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1077 self.assertEqual(512, im.size[0])
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1078 self.assertEqual(358, im.size[1])
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1079
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1080 b = DoPost(ORTHANC, '/dicom-web/servers/sample/get', {
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1081 'Uri' : '/studies/%s/series/%s/rendered' % (study, series)
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1082 })
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1083
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1084 self.assertEqual(len(a), len(b))
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1085 self.assertEqual(a, b)
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1086
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1087 c = DoPost(ORTHANC, '/dicom-web/servers/sample/get', {
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1088 'Uri' : '/studies/%s/rendered' % study
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1089 })
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1090
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1091 self.assertEqual(len(a), len(c))
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1092 self.assertEqual(a, c)
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1093
a94b0409fdac test_rendered_studies_series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 271
diff changeset
1094
273
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1095 def test_multiple_mime_accept_wado_rs(self):
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1096 # "Multiple MIME type Accept Headers for Wado-RS"
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1097 # https://groups.google.com/forum/#!msg/orthanc-users/P3B6J9abZpE/syn5dnW2AwAJ
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1098
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1099 UploadInstance(ORTHANC, 'DummyCT.dcm')
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1100 study = '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390'
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1101
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1102 self.assertEqual(1, len(DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study)))
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1103
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1104 self.assertEqual(1, len(DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study,
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1105 headers = { 'Accept' : 'application/json, application/dicom+json' })))
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1106
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1107 self.assertEqual(1, len(DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study,
274
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 273
diff changeset
1108 headers = { 'Accept' : 'application/json' })))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 273
diff changeset
1109
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 273
diff changeset
1110 self.assertEqual(1, len(DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 273
diff changeset
1111 headers = { 'Accept' : 'application/dicom+json' })))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 273
diff changeset
1112
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 273
diff changeset
1113 self.assertEqual(1, len(DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study,
273
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1114 headers = { 'Accept' : 'toto, application/dicom+json' })))
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1115
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1116 self.assertEqual(1, len(DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study,
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1117 headers = { 'Accept' : 'application/json, tata' })))
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1118
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1119 self.assertRaises(Exception, lambda: DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study,
274
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 273
diff changeset
1120 headers = { 'Accept' : 'toto' }))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 273
diff changeset
1121
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 273
diff changeset
1122 self.assertRaises(Exception, lambda: DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study,
273
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1123 headers = { 'Accept' : 'toto, tata' }))
275
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 274
diff changeset
1124
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 274
diff changeset
1125 # https://groups.google.com/d/msg/orthanc-users/9o5kItsMQI0/Og6B27YyBgAJ
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 274
diff changeset
1126 self.assertEqual(1, len(DoGetMultipart(ORTHANC, '/dicom-web/studies/%s/metadata' % study,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 274
diff changeset
1127 headers = { 'Accept' : 'multipart/related;type=application/dicom+xml' })))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 274
diff changeset
1128
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 274
diff changeset
1129 self.assertEqual(1, len(DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 274
diff changeset
1130 headers = { 'Accept' : 'application/json, application/dicom+xml' })))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 274
diff changeset
1131
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 274
diff changeset
1132 self.assertEqual(1, len(DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 274
diff changeset
1133 headers = { 'Accept' : 'application/dicom+xml, application/json' })))
284
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1134
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1135
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1136
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1137 def test_bitbucket_issue_56(self):
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1138 # "Case-insensitive matching over accents" => DICOMweb part
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1139 # from AlexanderM on 2020-03-20
319
de6e73e4df60 leaving bitbucket
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 318
diff changeset
1140 # https://bugs.orthanc-server.com/show_bug.cgi?id=56
284
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1141 UploadInstance(ORTHANC, 'Issue56-NoPixelData.dcm')
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1142
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1143 self.assertEqual(1, len(DoPost(ORTHANC, '/tools/find', {
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1144 'Level' : 'Patient',
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1145 'Query' : {
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1146 'PatientName' : 'Гусева*',
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1147 },
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1148 })))
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1149
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1150 self.assertEqual(1, len(DoPost(ORTHANC, '/tools/find', {
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1151 'Level' : 'Patient',
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1152 'Query' : {
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1153 'PatientName' : 'гусева*',
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1154 },
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1155 })))
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1156
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1157 self.assertEqual(1, len(DoGet(ORTHANC, u'/dicom-web/studies?PatientName=Гусева*',
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1158 headers = { 'accept' : 'application/json' })))
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1159
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1160 # This line is the issue
284
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1161 self.assertEqual(1, len(DoGet(ORTHANC, u'/dicom-web/studies?PatientName=гусева*',
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1162 headers = { 'accept' : 'application/json' })))
7fa5c7a03137 added test for issue 56
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 278
diff changeset
1163
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1164
318
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1165 def test_frames_transcoding(self):
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1166 ACCEPT = {
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1167 '1.2.840.10008.1.2' : 'multipart/related; type=application/octet-stream; transfer-syntax=1.2.840.10008.1.2',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1168 '1.2.840.10008.1.2.1' : 'multipart/related; type=application/octet-stream; transfer-syntax=1.2.840.10008.1.2.1',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1169 '1.2.840.10008.1.2.4.50' : 'multipart/related; type=image/jpeg; transfer-syntax=1.2.840.10008.1.2.4.50',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1170 '1.2.840.10008.1.2.4.51' : 'multipart/related; type=image/jpeg; transfer-syntax=1.2.840.10008.1.2.4.51',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1171 '1.2.840.10008.1.2.4.57' : 'multipart/related; type=image/jpeg; transfer-syntax=1.2.840.10008.1.2.4.57',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1172 '1.2.840.10008.1.2.4.70' : 'multipart/related; type=image/jpeg; transfer-syntax=1.2.840.10008.1.2.4.70',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1173 }
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1174
321
3c8c6b41eec4 dealing with Content-Location in test_frames_transcoding of DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 319
diff changeset
1175 uri = 'dicom-web%s' % UploadAndGetWadoPath('TransferSyntaxes/1.2.840.10008.1.2.4.50.dcm')
304
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1176 truth = Image.open(GetDatabasePath('TransferSyntaxes/1.2.840.10008.1.2.4.50.png'))
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1177
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1178 a = DoGetMultipart(ORTHANC, '%s/frames/1' % uri,
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1179 headers = { 'Accept' : ACCEPT['1.2.840.10008.1.2.4.50'] },
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1180 returnHeaders = True)
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1181 self.assertEqual(1, len(a))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1182 self.assertEqual(2, len(a[0]))
321
3c8c6b41eec4 dealing with Content-Location in test_frames_transcoding of DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 319
diff changeset
1183 self.assertEqual('%s%s/frames/1' % (ORTHANC['Url'], uri),
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1184 a[0][1]['Content-Location'])
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1185 self.assertEqual(ACCEPT['1.2.840.10008.1.2.4.50'],
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1186 'multipart/related; type=%s' % a[0][1]['Content-Type'])
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1187 self.assertEqual(53476, len(a[0][0]))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1188 self.assertEqual('142fdb8a1dc2aa7e6b8952aa294a6e22', ComputeMD5(a[0][0]))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1189
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1190 a = DoGetMultipart(ORTHANC, '%s/frames/1' % uri)
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1191 self.assertEqual(1, len(a))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1192 self.assertEqual(480 * 640 * 3, len(a[0]))
304
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1193
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1194 # http://effbot.org/zone/pil-comparing-images.htm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1195 img = Image.frombytes('RGB', [ 640, 480 ], a[0])
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1196 self.assertLessEqual(GetMaxImageDifference(img, truth), 2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1197
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1198 ACCEPT2 = copy.deepcopy(ACCEPT)
304
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1199 if HasGdcmPlugin(ORTHANC):
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1200 IS_GDCM = True
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1201 ACCEPT2['1.2.840.10008.1.2.1'] = 'multipart/related; type=application/octet-stream'
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1202 del ACCEPT2['1.2.840.10008.1.2']
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1203 else:
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1204 self.assertEqual('dfdc79f5070926bbb8ac079ee91f5b91', ComputeMD5(a[0]))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1205 IS_GDCM = False
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1206
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1207 a = DoGetMultipart(ORTHANC, '%s/frames/1' % uri,
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1208 headers = { 'Accept' : ACCEPT2['1.2.840.10008.1.2.1'] })
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1209 self.assertEqual(1, len(a))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1210 self.assertEqual(480 * 640 * 3, len(a[0]))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1211
304
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1212 img = Image.frombytes('RGB', [ 640, 480 ], a[0])
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1213 self.assertLessEqual(GetMaxImageDifference(img, truth), 2)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1214
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1215 if not IS_GDCM:
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1216 self.assertEqual('dfdc79f5070926bbb8ac079ee91f5b91', ComputeMD5(a[0]))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1217
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1218
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1219 # Test download using the same transfer syntax
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1220 RESULTS = {
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1221 '1.2.840.10008.1.2' : 'f54c7ea520ab3ec32b6303581ecd262f',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1222 '1.2.840.10008.1.2.1' : '4b350b9353a93c747917c7c3bf9b8f44',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1223 '1.2.840.10008.1.2.4.50' : '142fdb8a1dc2aa7e6b8952aa294a6e22',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1224 '1.2.840.10008.1.2.4.51' : '8b37945d75f9d2899ed868bdba429a0d',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1225 '1.2.840.10008.1.2.4.57' : '75c84823eddb560d127b1d24c9406f30',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1226 '1.2.840.10008.1.2.4.70' : '2c35726328f0200396e583a0038b0269',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1227 }
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1228
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1229 if IS_GDCM:
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1230 # This file was failing with GDCM, as it has 2 fragments,
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1231 # and only the first one was returned => the MD5 below is BAD
304
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1232 #RESULTS['1.2.840.10008.1.2.4.51'] = '901963a322a817946b074f9ed0afa060'
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1233 pass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 303
diff changeset
1234
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1235 for syntax in ACCEPT2:
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1236 uri = '/dicom-web%s' % UploadAndGetWadoPath('TransferSyntaxes/%s.dcm' % syntax)
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1237 a = DoGetMultipart(ORTHANC, '%s/frames/1' % uri,
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1238 headers = { 'Accept' : ACCEPT2[syntax] })
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1239 self.assertEqual(1, len(a))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1240 self.assertEqual(RESULTS[syntax], ComputeMD5(a[0]))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1241
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1242 # Test transcoding to all the possible transfer syntaxes
321
3c8c6b41eec4 dealing with Content-Location in test_frames_transcoding of DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 319
diff changeset
1243 uri = 'dicom-web%s' % UploadAndGetWadoPath('KarstenHilbertRF.dcm')
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1244 for syntax in ACCEPT2:
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1245 a = DoGetMultipart(ORTHANC, '%s/frames/1' % uri,
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1246 headers = { 'Accept' : ACCEPT2[syntax] },
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1247 returnHeaders = True)
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1248 self.assertEqual(1, len(a))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1249 self.assertEqual(2, len(a[0]))
321
3c8c6b41eec4 dealing with Content-Location in test_frames_transcoding of DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 319
diff changeset
1250 self.assertEqual('%s%s/frames/1' % (ORTHANC['Url'], uri),
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1251 a[0][1]['Content-Location'])
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1252 self.assertEqual(ACCEPT[syntax],
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1253 'multipart/related; type=%s' % a[0][1]['Content-Type'])
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1254 if IS_GDCM:
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1255 self.assertEqual({
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1256 '1.2.840.10008.1.2' : '1c8cebde0c74450ce4dfb75dd52ddad7',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1257 '1.2.840.10008.1.2.1' : '1c8cebde0c74450ce4dfb75dd52ddad7',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1258 '1.2.840.10008.1.2.4.50' : 'f4d145e5f33fbd39375ce0f91453d6cc',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1259 '1.2.840.10008.1.2.4.51' : 'f4d145e5f33fbd39375ce0f91453d6cc',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1260 '1.2.840.10008.1.2.4.57' : 'dc55800ce1a8ac556c266cdb26d75757',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1261 '1.2.840.10008.1.2.4.70' : 'dc55800ce1a8ac556c266cdb26d75757',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1262 } [syntax], ComputeMD5(a[0][0]))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1263 else:
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1264 self.assertEqual({
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1265 '1.2.840.10008.1.2' : '1c8cebde0c74450ce4dfb75dd52ddad7',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1266 '1.2.840.10008.1.2.1' : '1c8cebde0c74450ce4dfb75dd52ddad7',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1267 '1.2.840.10008.1.2.4.50' : '0a0ab74fe7c68529bdd416fc9e5e742a',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1268 '1.2.840.10008.1.2.4.51' : '33d1ab2fe169c5b5ba932a9bbc3c6306',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1269 '1.2.840.10008.1.2.4.57' : '3d21c969da846ca41e0498a0dcfad061',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1270 '1.2.840.10008.1.2.4.70' : '49d5353c8673208629847ad45a855557',
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1271 } [syntax], ComputeMD5(a[0][0]))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1272
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1273
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1274 # JPEG image with many fragments for 2 frames
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1275 uri = '/dicom-web%s' % UploadAndGetWadoPath('LenaTwiceWithFragments.dcm')
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1276
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1277 a = DoGetMultipart(ORTHANC, '%s/frames/1' % uri,
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1278 headers = { 'Accept' : ACCEPT['1.2.840.10008.1.2.4.50'] })
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1279 self.assertEqual(1, len(a))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1280 self.assertEqual(69214, len(a[0]))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1281 self.assertEqual('0eaf36d4881c513ca70b6684bfaa5b08', ComputeMD5(a[0]))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1282
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1283 b = DoGetMultipart(ORTHANC, '%s/frames/2' % uri,
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1284 headers = { 'Accept' : ACCEPT['1.2.840.10008.1.2.4.50'] })
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1285 self.assertEqual(1, len(b))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1286 self.assertEqual(a[0], b[0])
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1287
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1288 b = DoGetMultipart(ORTHANC, '%s/frames/1,2' % uri,
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1289 headers = { 'Accept' : ACCEPT['1.2.840.10008.1.2.4.50'] })
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1290 self.assertEqual(2, len(b))
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1291 self.assertEqual(a[0], b[0])
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1292 self.assertEqual(a[0], b[1])
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1293
318
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1294
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1295 def test_wado_transcoding(self):
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1296 uri = '/dicom-web%s' % UploadAndGetWadoPath('TransferSyntaxes/1.2.840.10008.1.2.4.50.dcm')
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1297
367
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1298 compressedSize = os.path.getsize(GetDatabasePath('TransferSyntaxes/1.2.840.10008.1.2.4.50.dcm'))
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1299
318
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1300 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s' % uri,
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1301 headers = { 'Accept' : 'nope' }))
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1302
367
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1303 # Up to release 1.5 of the DICOMweb plugin, if no
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1304 # transfer-syntax was specified, no transcoding occured. This
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1305 # was because of an undefined behavior up to DICOM
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1306 # 2016b. Starting with DICOM 2016c, the standard explicitly
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1307 # states that the image should be transcoded to Little Endian
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1308 # Explicit.
318
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1309 a = DoGetMultipart(ORTHANC, '%s' % uri,
367
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1310 headers = { })
318
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1311 self.assertEqual(1, len(a))
367
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1312 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(a[0]))
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1313 self.assertTrue(10 * compressedSize < len(a[0]))
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1314 uncompressedSize = len(a[0])
297
f95cd3af1c7a DICOMweb: test_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 284
diff changeset
1315
318
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1316 a = DoGetMultipart(ORTHANC, '%s' % uri,
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1317 headers = { 'Accept' : 'multipart/related' })
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1318 self.assertEqual(1, len(a))
367
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1319 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(a[0]))
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1320 self.assertEqual(uncompressedSize, len(a[0]))
318
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1321
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1322 a = DoGetMultipart(ORTHANC, '%s' % uri,
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1323 headers = { 'Accept' : 'multipart/related; type=application/dicom' })
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1324 self.assertEqual(1, len(a))
367
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1325 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(a[0]))
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1326 self.assertEqual(uncompressedSize, len(a[0]))
318
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1327
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1328 a = DoGetMultipart(ORTHANC, '%s' % uri,
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1329 headers = { 'Accept' : 'multipart/related; type=application/dicom; transfer-syntax=*' })
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1330 self.assertEqual(1, len(a))
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1331 self.assertEqual('1.2.840.10008.1.2.4.50', GetTransferSyntax(a[0]))
367
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1332 self.assertEqual(compressedSize, len(a[0]))
318
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1333
367
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1334 # Use source transfer syntax
318
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1335 a = DoGetMultipart(ORTHANC, '%s' % uri,
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1336 headers = { 'Accept' : 'multipart/related; type=application/dicom; transfer-syntax=1.2.840.10008.1.2.4.50' })
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1337 self.assertEqual(1, len(a))
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1338 self.assertEqual('1.2.840.10008.1.2.4.50', GetTransferSyntax(a[0]))
367
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1339 self.assertEqual(compressedSize, len(a[0]))
318
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1340
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1341 a = DoGetMultipart(ORTHANC, '%s' % uri,
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1342 headers = { 'Accept' : 'multipart/related; type=application/dicom; transfer-syntax=1.2.840.10008.1.2.1' })
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1343 self.assertEqual(1, len(a))
bac7cc80f240 dicomweb: test_wado_transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 314
diff changeset
1344 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(a[0]))
367
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1345 self.assertEqual(uncompressedSize, len(a[0]))
325
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1346
367
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1347 # Transcoding
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1348 a = DoGetMultipart(ORTHANC, '%s' % uri,
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1349 headers = { 'Accept' : 'multipart/related; type=application/dicom; transfer-syntax=1.2.840.10008.1.2.4.57' })
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1350 self.assertEqual(1, len(a))
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1351 self.assertEqual('1.2.840.10008.1.2.4.57', GetTransferSyntax(a[0]))
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1352 self.assertNotEqual(compressedSize, len(a[0]))
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1353 self.assertNotEqual(uncompressedSize, len(a[0]))
325
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1354
367
9d2a63afdb73 Test compliance with DICOM >= 2016c: WADO-RS Retrieve transcodes to Little Endian Explicit by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 363
diff changeset
1355
325
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1356 def test_compare_wado_uri_and_rs(self):
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1357 # https://groups.google.com/d/msg/orthanc-users/mKgr2QAKTCU/R7u4I1LvBAAJ
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1358
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1359 # Image "2020-08-12-Christopher.dcm" corresponds to the result of:
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1360 # $ gdcmconv --raw 1.2.840.113704.9.1000.16.2.20190613104005642000100010001.dcm 2020-08-12-Christopher.dcm
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1361 # Image "2020-08-12-Christopher.png" corresponds to "2.png"
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1362
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1363 i = UploadInstance(ORTHANC, '2020-08-12-Christopher.dcm') ['ID']
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1364 STUDY = '1.2.840.113704.9.1000.16.0.20190613103939444'
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1365 SERIES = '1.2.840.113704.9.1000.16.1.2019061310394289000010001'
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1366 INSTANCE = '1.2.840.113704.9.1000.16.2.20190613104005642000100010001'
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1367
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1368 with open(GetDatabasePath('2020-08-12-Christopher.png'), 'rb') as f:
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1369 truth = UncompressImage(f.read())
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1370
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1371 im1 = GetImage(ORTHANC, args.wado + '?requestType=WADO&objectUID=%s&contentType=image/jpg' % INSTANCE)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1372 self.assertEqual('JPEG', im1.format)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1373
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1374 im2 = GetImage(ORTHANC, args.wado + '?requestType=WADO&objectUID=%s&contentType=image/png' % INSTANCE)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1375 self.assertEqual('PNG', im2.format)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1376
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1377 im3 = GetImage(ORTHANC, '/dicom-web/studies/%s/series/%s/instances/%s/frames/1/rendered' % (STUDY, SERIES, INSTANCE))
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1378 self.assertEqual('JPEG', im3.format)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1379
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1380 im4 = GetImage(ORTHANC, '/dicom-web/studies/%s/series/%s/instances/%s/rendered' % (STUDY, SERIES, INSTANCE),
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1381 headers = { 'Accept' : 'image/png' })
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1382 self.assertEqual('PNG', im4.format)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1383
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1384 im5 = GetImage(ORTHANC, '/instances/%s/rendered' % i, { 'Accept' : 'image/jpeg' })
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1385 self.assertEqual('JPEG', im5.format)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1386
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1387 im6 = GetImage(ORTHANC, '/instances/%s/rendered' % i)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1388 self.assertEqual('PNG', im6.format)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1389
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1390 for im in [ truth, im1, im2, im3, im4, im5, im6 ]:
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1391 self.assertEqual('L', im.mode)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1392 self.assertEqual(512, im.size[0])
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1393 self.assertEqual(512, im.size[1])
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1394
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1395 im2.save('/tmp/a.png')
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1396 im4.save('/tmp/b.png')
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1397 im6.save('/tmp/c.png')
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1398
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1399 # The following fails in DICOMweb plugin <= 1.2, as "/rendered"
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1400 # was redirecting to the "/preview" route of Orthanc
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1401 # http://effbot.org/zone/pil-comparing-images.htm
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1402 self.assertTrue(ImageChops.difference(im1, im3).getbbox() is None)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1403 self.assertTrue(ImageChops.difference(im1, im5).getbbox() is None)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1404 self.assertTrue(ImageChops.difference(im2, im4).getbbox() is None)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1405 self.assertTrue(ImageChops.difference(im2, im6).getbbox() is None)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1406 self.assertTrue(ImageChops.difference(im3, im5).getbbox() is None)
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1407 self.assertTrue(ImageChops.difference(im4, im6).getbbox() is None)
345
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 325
diff changeset
1408
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 325
diff changeset
1409 bbox = ImageChops.difference(im2, truth).getbbox()
346
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
1410 if bbox != None:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
1411 # Tolerance of just 1 pixel of difference (needed on Windows)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
1412 #print(im2.getpixel((238,275))) # => 255
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
1413 #print(truth.getpixel((238,275))) # => 254
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
1414 self.assertLessEqual(abs(bbox[2] - bbox[0]), 1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
1415 self.assertLessEqual(abs(bbox[3] - bbox[1]), 1)
325
b7c2fb8e1b57 DICOMweb: test_compare_wado_uri_and_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 321
diff changeset
1416
273
afcd550a9216 test_multiple_mime_accept_wado_rs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
1417
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1418 try:
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1419 print('\nStarting the tests...')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1420 unittest.main(argv = [ sys.argv[0] ] + args.options)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1421
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1422 finally:
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1423 print('\nDone')