Mercurial > hg > orthanc-tests
annotate Plugins/DicomWeb/Run.py @ 226:230aede7f8d5
test_bitbucket_issue_96
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 26 Feb 2019 20:32:31 +0100 |
parents | 4d5af1f49cb2 |
children | 875ff7460ae8 |
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 | 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 |
195 | 8 # Copyright (C) 2017-2019 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 | 24 |
25 # You must add the following to the configuration file: | |
26 # | |
27 # "DicomWeb" : { | |
28 # "Servers" : { | |
29 # "sample" : [ "http://localhost:8042/dicom-web/", "alice", "orthanctest" ] | |
30 # } | |
31 # } | |
32 | |
33 | |
34 | |
35 | |
32
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 import os |
33 | 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 | 41 import re |
33 | 42 from DicomWeb import * |
32
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 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
|
45 from Toolbox import * |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
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 ## Parse the command-line arguments |
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 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 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
|
53 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 parser.add_argument('--server', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 default = 'localhost', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 help = 'Address of the Orthanc server to test') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 parser.add_argument('--rest', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 type = int, |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 default = 8042, |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 help = 'Port to the REST API') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 parser.add_argument('--username', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 default = 'alice', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 help = 'Username to the REST API') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 parser.add_argument('--password', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 default = 'orthanctest', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 help = 'Password to the REST API') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 parser.add_argument('--wado', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 default = '/wado', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 help = 'Path to the WADO API') |
33 | 70 parser.add_argument('--dicomweb', |
32
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 default = '/dicom-web/', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 help = 'Path to the DICOMweb API') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 parser.add_argument('--force', help = 'Do not warn the user', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 action = 'store_true') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 parser.add_argument('options', metavar = 'N', nargs = '*', |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 help='Arguments to Python unittest') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 args = parser.parse_args() |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 ## |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 ## Configure the testing context |
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 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 if not args.force: |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 print(""" |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 WARNING: This test will remove all the content of your |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 Orthanc instance running on %s! |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 Are you sure ["yes" to go on]?""" % args.server) |
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 if sys.stdin.readline().strip() != 'yes': |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 print('Aborting...') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 exit(0) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 ORTHANC = DefineOrthanc(server = args.server, |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 username = args.username, |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 password = args.password, |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 restPort = args.rest) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 ## |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 ## The tests |
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 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 class Orthanc(unittest.TestCase): |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 def setUp(self): |
83 | 109 if (sys.version_info >= (3, 0)): |
110 # Remove annoying warnings about unclosed socket in Python 3 | |
111 import warnings | |
112 warnings.simplefilter("ignore", ResourceWarning) | |
113 | |
32
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 DropOrthanc(ORTHANC) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 def test_wado_dicom(self): |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 UploadInstance(ORTHANC, 'Brainix/Flair/IM-0001-0001.dcm') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 SIZE = 169478 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 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
|
121 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
|
122 STUDY = '2.16.840.1.113669.632.20.1211.10000357775' |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado + '?requestType=WADO')) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 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
|
127 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 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
|
129 self.assertEqual(SIZE, len(dicom)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 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
|
132 self.assertEqual(SIZE, len(dicom)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 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
|
135 self.assertEqual(SIZE, len(dicom)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 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
|
138 self.assertEqual(SIZE, len(dicom)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 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
|
141 self.assertEqual(SIZE, len(dicom)) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 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
|
144 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
|
145 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
|
146 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 def test_wado_image(self): |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 UploadInstance(ORTHANC, 'Phenix/IM-0001-0001.dcm') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 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
|
150 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 im = GetImage(ORTHANC, args.wado + '?requestType=WADO&objectUID=%s' % INSTANCE) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 self.assertEqual('JPEG', im.format) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 self.assertEqual('L', im.mode) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 self.assertEqual(512, im.size[0]) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 self.assertEqual(358, im.size[1]) |
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 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
|
158 self.assertEqual('JPEG', im.format) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 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
|
161 self.assertEqual('PNG', im.format) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 self.assertEqual('L', im.mode) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 self.assertEqual(512, im.size[0]) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 self.assertEqual(358, im.size[1]) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 |
33 | 166 def test_stow(self): |
167 self.assertEqual(0, len(DoGet(ORTHANC, '/instances'))) | |
168 SendStow(ORTHANC, args.dicomweb + '/studies', GetDatabasePath('Phenix/IM-0001-0001.dcm')) | |
169 self.assertEqual(1, len(DoGet(ORTHANC, '/instances'))) | |
170 a = SendStow(ORTHANC, args.dicomweb + '/studies', GetDatabasePath('Phenix/IM-0001-0001.dcm')) | |
171 self.assertEqual(1, len(DoGet(ORTHANC, '/instances'))) | |
172 | |
173 self.assertEqual(0, len(a['00081198']['Value'])) # No error | |
174 self.assertEqual(1, len(a['00081199']['Value'])) # 1 success | |
175 | |
176 self.assertTrue(a['00081190']['Value'][0].endswith('studies/2.16.840.1.113669.632.20.1211.10000098591')) | |
177 self.assertTrue(a['00081199']['Value'][0]['00081190']['Value'][0]. | |
178 endswith('series/1.2.840.113704.1.111.5692.1127828999.2/instances/1.2.840.113704.7.1.1.6632.1127829031.2')) | |
179 | |
83 | 180 # Remove the "http://localhost:8042" prefix |
181 url = a['00081190']['Value'][0] | |
182 url = re.sub(r'(http|https)://[^/]+(/.*)', r'\2', url) | |
183 | |
184 # Get the content-length of all the multiparts of this WADO-RS request | |
185 b = DoGet(ORTHANC, url).decode('utf-8', 'ignore') | |
186 parts = re.findall(r'^Content-Length:\s*(\d+)\s*', b, re.IGNORECASE | re.MULTILINE) | |
187 self.assertEqual(1, len(parts)) | |
188 self.assertEqual(os.path.getsize(GetDatabasePath('Phenix/IM-0001-0001.dcm')), int(parts[0])) | |
33 | 189 |
84 | 190 def test_server_get(self): |
191 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0001.dcm') | |
192 | |
193 self.assertEqual(1, len(DoGet(ORTHANC, '/dicom-web/servers'))) | |
194 self.assertTrue('sample' in DoGet(ORTHANC, '/dicom-web/servers')) | |
195 | |
129 | 196 serversReadback = DoGet(ORTHANC, '/dicom-web/servers?expand') |
197 self.assertEqual('http://localhost:8042/dicom-web/', serversReadback['sample']['Url']) | |
198 self.assertEqual('alice', serversReadback['sample']['Username']) | |
199 | |
84 | 200 sample = DoGet(ORTHANC, '/dicom-web/servers/sample') |
201 self.assertEqual(3, len(sample)) | |
202 self.assertTrue('stow' in sample) | |
203 self.assertTrue('retrieve' in sample) | |
204 self.assertTrue('get' in sample) | |
205 | |
206 # application/dicom+xml | |
131
90e5331ddee9
application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
207 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
|
208 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
|
209 re.MULTILINE))) |
90e5331ddee9
application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
210 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
|
211 (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
|
212 { 'Uri' : '/studies', |
90e5331ddee9
application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
213 '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
|
214 }), re.MULTILINE))) |
84 | 215 |
216 # application/dicom+json | |
131
90e5331ddee9
application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
217 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
|
218 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
|
219 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
|
220 { 'Uri' : '/studies', |
90e5331ddee9
application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
221 '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
|
222 |
90e5331ddee9
application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
223 # application/json |
90e5331ddee9
application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
224 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
|
225 headers = { 'Accept' : 'application/json' }))) |
84 | 226 self.assertEqual(1, len(DoPost(ORTHANC, '/dicom-web/servers/sample/get', |
227 { 'Uri' : '/studies', | |
228 'HttpHeaders' : { 'Accept' : 'application/json' }}))) | |
229 | |
131
90e5331ddee9
application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
230 # 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
|
231 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
|
232 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
|
233 { 'Uri' : '/studies' }))) |
90e5331ddee9
application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
130
diff
changeset
|
234 |
84 | 235 |
236 def test_server_stow(self): | |
237 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0001.dcm') | |
238 | |
239 self.assertRaises(Exception, lambda: | |
240 DoPost(ORTHANC, '/dicom-web/servers/sample/stow', | |
241 { 'Resources' : [ 'nope' ]})) # inexisting resource | |
242 | |
243 self.assertEqual(0, len(DoPost(ORTHANC, '/dicom-web/servers/sample/stow', | |
244 { 'Resources' : [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ]}))) # patient | |
245 | |
246 self.assertEqual(0, len(DoPost(ORTHANC, '/dicom-web/servers/sample/stow', | |
247 { 'Resources' : [ '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' ]}))) # study | |
248 | |
249 self.assertEqual(0, len(DoPost(ORTHANC, '/dicom-web/servers/sample/stow', | |
250 { 'Resources' : [ '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' ]}))) # series | |
251 | |
252 self.assertEqual(0, len(DoPost(ORTHANC, '/dicom-web/servers/sample/stow', | |
253 { 'Resources' : [ 'c8df6478-d7794217-0f11c293-a41237c9-31d98357' ]}))) # instance | |
254 | |
255 self.assertEqual(0, len(DoPost(ORTHANC, '/dicom-web/servers/sample/stow', | |
256 { 'Resources' : [ | |
257 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17', | |
258 '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918', | |
259 '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285', | |
260 'c8df6478-d7794217-0f11c293-a41237c9-31d98357' ]}))) # altogether | |
261 | |
262 | |
263 def test_server_retrieve(self): | |
264 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0001.dcm') | |
265 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0002.dcm') | |
266 UploadInstance(ORTHANC, 'Knee/T2/IM-0001-0001.dcm') | |
267 | |
268 self.assertRaises(Exception, lambda: | |
269 DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve', | |
270 { 'Resources' : [ { 'Study' : 'nope' } ]})) # inexisting resource | |
271 | |
272 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve', | |
273 { 'Resources' : [ { 'Study' : '2.16.840.1.113669.632.20.121711.10000160881' } ] }) | |
274 self.assertEqual(3, len(t['Instances'])) | |
275 | |
276 # Missing "Study" field | |
277 self.assertRaises(Exception, lambda: | |
278 DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve', | |
279 { 'Resources' : [ { 'Series' : '1.3.46.670589.11.17521.5.0.3124.2008081908564160709' } ]})) | |
280 | |
281 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve', | |
282 { 'Resources' : [ { 'Study' : '2.16.840.1.113669.632.20.121711.10000160881', | |
283 'Series' : '1.3.46.670589.11.17521.5.0.3124.2008081908564160709' } ] }) | |
284 self.assertEqual(2, len(t['Instances'])) | |
285 | |
286 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve', | |
287 { 'Resources' : [ { 'Study' : '2.16.840.1.113669.632.20.121711.10000160881', | |
288 'Series' : '1.3.46.670589.11.17521.5.0.3124.2008081909090037350' } ] }) | |
289 self.assertEqual(1, len(t['Instances'])) | |
290 | |
291 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve', | |
292 { 'Resources' : [ { 'Study' : '2.16.840.1.113669.632.20.121711.10000160881', | |
293 'Series' : '1.3.46.670589.11.17521.5.0.3124.2008081909090037350' }, | |
294 { 'Study' : '2.16.840.1.113669.632.20.121711.10000160881', | |
295 'Series' : '1.3.46.670589.11.17521.5.0.3124.2008081908564160709' } ] }) | |
296 self.assertEqual(3, len(t['Instances'])) | |
297 | |
298 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve', | |
299 { 'Resources' : [ { 'Study' : '2.16.840.1.113669.632.20.121711.10000160881', | |
300 'Series' : '1.3.46.670589.11.17521.5.0.3124.2008081909090037350', | |
301 'Instance' : '1.3.46.670589.11.17521.5.0.3124.2008081909113806560' } ] }) | |
302 self.assertEqual(1, len(t['Instances'])) | |
303 | |
304 | |
114
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
305 def test_bitbucket_issue_53(self): |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
306 # DICOMWeb plugin support for "limit" and "offset" parameters in QIDO-RS |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
307 # https://bitbucket.org/sjodogne/orthanc/issues/53 |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
308 |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
309 UploadInstance(ORTHANC, 'Brainix/Flair/IM-0001-0001.dcm') |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
310 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0001.dcm') |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
311 |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
312 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
|
313 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
|
314 |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
315 a = DoGet(ORTHANC, '/dicom-web/studies', |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
316 headers = { 'accept' : 'application/json' }) |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
317 self.assertEqual(2, len(a)) |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
318 |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
319 b = [] |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
320 a = DoGet(ORTHANC, '/dicom-web/studies?limit=1', |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
321 headers = { 'accept' : 'application/json' }) |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
322 self.assertEqual(1, len(a)) |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
323 b.append(a[0]['0020000D']['Value'][0]) |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
324 |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
325 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
|
326 headers = { 'accept' : 'application/json' }) |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
327 self.assertEqual(1, len(a)) |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
328 b.append(a[0]['0020000D']['Value'][0]) |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
329 |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
330 self.assertTrue(brainix in b) |
a6019560272f
test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
331 self.assertTrue(knee in b) |
32
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 |
184
e244312964d6
test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
334 def test_bitbucket_issue_111(self): |
223
f5aca0917d60
DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
335 # Wrong serialization of empty values |
f5aca0917d60
DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
336 # https://bitbucket.org/sjodogne/orthanc/issues/111 |
f5aca0917d60
DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
337 # https://bitbucket.org/sjodogne/orthanc-dicomweb/issues/3/ |
f5aca0917d60
DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
338 |
184
e244312964d6
test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
339 # According to the standard, section F.2.5 |
e244312964d6
test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
340 # (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
|
341 # 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
|
342 # 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
|
343 # preserved in the DICOM JSON attribute object containing no |
e244312964d6
test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
344 # "Value", "BulkDataURI" or "InlineBinary". |
e244312964d6
test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
345 # https://bitbucket.org/sjodogne/orthanc/issues/111/qido-rs-wrong-serialization-of-empty |
e244312964d6
test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
346 |
223
f5aca0917d60
DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
347 UploadInstance(ORTHANC, 'Issue111.dcm') |
184
e244312964d6
test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
348 |
223
f5aca0917d60
DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
349 # Test WADO-RS |
f5aca0917d60
DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
350 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
|
351 self.assertEqual(1, len(a)) |
f5aca0917d60
DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
352 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
|
353 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
|
354 self.assertEqual('SH', a[0]['00080050']['vr']) |
184
e244312964d6
test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
355 |
223
f5aca0917d60
DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
356 # Test QIDO-RS |
f5aca0917d60
DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
357 a = DoGet(ORTHANC, '/dicom-web/studies') |
184
e244312964d6
test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
358 self.assertEqual(1, len(a)) |
e244312964d6
test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
359 self.assertTrue('00080050' in a[0]) # AccessionNumber is null |
e244312964d6
test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
360 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
|
361 self.assertEqual('SH', a[0]['00080050']['vr']) |
e244312964d6
test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
131
diff
changeset
|
362 |
222
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
363 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
364 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
|
365 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
|
366 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
|
367 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
|
368 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
|
369 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
|
370 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
|
371 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
372 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
|
373 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
|
374 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
|
375 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
|
376 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
377 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
|
378 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
|
379 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
|
380 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
381 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
|
382 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
|
383 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
|
384 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
385 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
|
386 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
|
387 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
|
388 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
|
389 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
|
390 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
|
391 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
392 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
393 def test_wado_bulk(self): |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
394 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
|
395 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
|
396 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
|
397 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
|
398 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
|
399 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
400 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
|
401 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
|
402 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
|
403 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
|
404 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
405 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
|
406 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
|
407 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
408 BASE_URI = '/dicom-web/studies/%s/series/%s/instances/%s/bulk' % (study, series, sop) |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
409 BASE_URL = 'http://localhost:8042%s' % BASE_URI |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
410 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
411 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
|
412 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
|
413 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
|
414 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
|
415 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
416 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
|
417 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
|
418 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
419 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
|
420 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
|
421 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
|
422 |
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_bitbucket_issue_112(self): |
223
f5aca0917d60
DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
425 # Wrong serialization of number values |
222
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
426 # https://bitbucket.org/sjodogne/orthanc/issues/112 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
427 # 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
|
428 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
429 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
|
430 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
|
431 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
432 # 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
|
433 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
|
434 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
|
435 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
|
436 |
226
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
437 if (sys.version_info >= (3, 0)): |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
438 types = (int) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
439 else: |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
440 types = (int, long) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
441 |
222
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
442 b = a[0]['00180091']['Value'][0] |
226
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
443 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
|
444 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
|
445 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
446 # 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
|
447 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
|
448 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
|
449 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
|
450 |
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
451 b = a[0]['00201208']['Value'][0] |
226
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
452 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
|
453 self.assertEqual(1, b) |
223
f5aca0917d60
DICOMweb: test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
454 |
222
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
455 |
224
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
456 def test_bitbucket_issue_113(self): |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
457 # Wrong serialization of PN VR |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
458 # https://bitbucket.org/sjodogne/orthanc/issues/113 |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
459 # https://bitbucket.org/sjodogne/orthanc-dicomweb/issues/2/ |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
460 |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
461 UploadInstance(ORTHANC, 'Encodings/DavidClunie/SCSX1') |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
462 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
|
463 |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
464 # This is the WADO-RS testing |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
465 a = DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study) |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
466 self.assertEqual(1, len(a)) |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
467 |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
468 pn = a[0]['00100010'] # Patient name |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
469 self.assertEqual('PN', pn['vr']) |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
470 self.assertEqual(1, len(pn['Value'])) |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
471 self.assertEqual('Wang^XiaoDong', pn['Value'][0]['Alphabetic']) |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
472 self.assertEqual(u'王^小東', pn['Value'][0]['Ideographic']) |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
473 |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
474 # This is the QIDO-RS testing |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
475 a = DoGet(ORTHANC, '/dicom-web/studies') |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
476 self.assertEqual(1, len(a)) |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
477 |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
478 pn = a[0]['00100010'] # Patient name |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
479 self.assertEqual('PN', pn['vr']) |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
480 self.assertEqual(1, len(pn['Value'])) |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
481 self.assertEqual('Wang^XiaoDong', pn['Value'][0]['Alphabetic']) |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
482 self.assertEqual(u'王^小東', pn['Value'][0]['Ideographic']) |
f5414254ccaa
test_bitbucket_issue_113
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
483 |
222
0f03ee6ffa80
DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
195
diff
changeset
|
484 |
225 | 485 def test_bitbucket_issue_96(self): |
486 # WADO-RS RetrieveFrames rejects valid accept headers | |
487 # https://bitbucket.org/sjodogne/orthanc/issues/96 | |
488 # https://bitbucket.org/sjodogne/orthanc-dicomweb/issues/5/ | |
489 | |
490 UploadInstance(ORTHANC, 'LenaTwiceWithFragments.dcm') | |
491 | |
492 a = DoGet(ORTHANC, '/dicom-web/instances') | |
493 self.assertEqual(1, len(a)) | |
226
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
494 self.assertEqual(2, a[0]['00280008']['Value'][0]) # Number of frames |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
495 self.assertEqual(512, a[0]['00280010']['Value'][0]) # Rows |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
496 self.assertEqual(512, a[0]['00280011']['Value'][0]) # Columns |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
497 self.assertEqual(8, a[0]['00280100']['Value'][0]) # Bits allocated |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
498 |
225 | 499 url = a[0]['00081190']['Value'][0] |
500 | |
501 prefix = 'http://localhost:8042' | |
502 self.assertTrue(url.startswith(prefix)) | |
503 uri = url[len(prefix):] | |
504 | |
226
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
505 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 0))) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
506 self.assertRaises(Exception, lambda: DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 3))) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
507 |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
508 b = DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 1)) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
509 self.assertEqual(1, len(b)) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
510 self.assertEqual(512 * 512 * 3, len(b[0])) |
225 | 511 |
226
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
512 c = DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 2)) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
513 self.assertEqual(1, len(c)) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
514 self.assertEqual(512 * 512 * 3, len(c[0])) |
225 | 515 |
226
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
516 self.assertEqual(b[0], c[0]) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
517 |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
518 c = DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 2), |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
519 headers = { 'Accept' : 'multipart/related; type=application/octet-stream' }) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
520 self.assertEqual(1, len(c)) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
521 self.assertEqual(b[0], c[0]) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
522 |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
523 c = DoGetMultipart(ORTHANC, '%s/frames/%d' % (uri, 2), |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
524 headers = { 'Accept' : 'multipart/related; type="application/octet-stream"' }) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
525 self.assertEqual(1, len(c)) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
526 self.assertEqual(b[0], c[0]) |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
527 |
230aede7f8d5
test_bitbucket_issue_96
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
528 |
32
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
529 try: |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
530 print('\nStarting the tests...') |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
531 unittest.main(argv = [ sys.argv[0] ] + args.options) |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
532 |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 finally: |
682c4e2a1162
integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 print('\nDone') |