annotate Plugins/DicomWeb/Run.py @ 184:e244312964d6

test_bitbucket_issue_111
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 13 Nov 2018 11:54:49 +0100
parents 90e5331ddee9
children af8e034f4262
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
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 # Orthanc - A Lightweight, RESTful DICOM Store
73
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 33
diff changeset
4 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # Department, University Hospital of Liege, Belgium
130
50cd127e5330 upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
6 # Copyright (C) 2017-2018 Osimis S.A., Belgium
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 #
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 # 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
9 # 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
10 # 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
11 # License, or (at your option) any later version.
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 #
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 # 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
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 # General Public License for more details.
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 #
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 # 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
19 # 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
20
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
22
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
23 # You must add the following to the configuration file:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
24 #
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
25 # "DicomWeb" : {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
26 # "Servers" : {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
27 # "sample" : [ "http://localhost:8042/dicom-web/", "alice", "orthanctest" ]
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
28 # }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
29 # }
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
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 import os
33
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
35 import pprint
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 import sys
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 import argparse
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 import unittest
83
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
39 import re
33
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
40 from DicomWeb import *
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 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
43 from Toolbox import *
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
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 ##
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 ## Parse the command-line arguments
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 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
51
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 parser.add_argument('--server',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 default = 'localhost',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 help = 'Address of the Orthanc server to test')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 parser.add_argument('--rest',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 type = int,
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 default = 8042,
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 help = 'Port to the REST API')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 parser.add_argument('--username',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 default = 'alice',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 help = 'Username to the REST API')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 parser.add_argument('--password',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 default = 'orthanctest',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 help = 'Password to the REST API')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 parser.add_argument('--wado',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 default = '/wado',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 help = 'Path to the WADO API')
33
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
68 parser.add_argument('--dicomweb',
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 default = '/dicom-web/',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 help = 'Path to the DICOMweb API')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 parser.add_argument('--force', help = 'Do not warn the user',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 action = 'store_true')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 parser.add_argument('options', metavar = 'N', nargs = '*',
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 help='Arguments to Python unittest')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 args = parser.parse_args()
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
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 ## Configure the testing context
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 if not args.force:
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 print("""
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 WARNING: This test will remove all the content of your
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 Orthanc instance running on %s!
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 Are you sure ["yes" to go on]?""" % args.server)
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 if sys.stdin.readline().strip() != 'yes':
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 print('Aborting...')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 exit(0)
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
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 ORTHANC = DefineOrthanc(server = args.server,
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 username = args.username,
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 password = args.password,
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 restPort = args.rest)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
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 ## The tests
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 class Orthanc(unittest.TestCase):
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 def setUp(self):
83
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
107 if (sys.version_info >= (3, 0)):
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
108 # Remove annoying warnings about unclosed socket in Python 3
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
109 import warnings
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
110 warnings.simplefilter("ignore", ResourceWarning)
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
111
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 DropOrthanc(ORTHANC)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 def test_wado_dicom(self):
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 UploadInstance(ORTHANC, 'Brainix/Flair/IM-0001-0001.dcm')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 SIZE = 169478
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 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
119 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
120 STUDY = '2.16.840.1.113669.632.20.1211.10000357775'
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 self.assertRaises(Exception, lambda: DoGet(ORTHANC, args.wado + '?requestType=WADO'))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 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
125
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 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
127 self.assertEqual(SIZE, len(dicom))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 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
130 self.assertEqual(SIZE, len(dicom))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 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
133 self.assertEqual(SIZE, len(dicom))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 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
136 self.assertEqual(SIZE, len(dicom))
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 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
139 self.assertEqual(SIZE, len(dicom))
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 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
142 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
143 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
144
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 def test_wado_image(self):
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 UploadInstance(ORTHANC, 'Phenix/IM-0001-0001.dcm')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 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
148
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 im = GetImage(ORTHANC, args.wado + '?requestType=WADO&objectUID=%s' % INSTANCE)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 self.assertEqual('JPEG', im.format)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 self.assertEqual('L', im.mode)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 self.assertEqual(512, im.size[0])
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 self.assertEqual(358, im.size[1])
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 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
156 self.assertEqual('JPEG', im.format)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 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
159 self.assertEqual('PNG', im.format)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 self.assertEqual('L', im.mode)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 self.assertEqual(512, im.size[0])
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 self.assertEqual(358, im.size[1])
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163
33
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
164 def test_stow(self):
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
165 self.assertEqual(0, len(DoGet(ORTHANC, '/instances')))
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
166 SendStow(ORTHANC, args.dicomweb + '/studies', GetDatabasePath('Phenix/IM-0001-0001.dcm'))
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
167 self.assertEqual(1, len(DoGet(ORTHANC, '/instances')))
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
168 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
169 self.assertEqual(1, len(DoGet(ORTHANC, '/instances')))
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
170
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
171 self.assertEqual(0, len(a['00081198']['Value'])) # No error
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
172 self.assertEqual(1, len(a['00081199']['Value'])) # 1 success
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
173
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
174 self.assertTrue(a['00081190']['Value'][0].endswith('studies/2.16.840.1.113669.632.20.1211.10000098591'))
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
175 self.assertTrue(a['00081199']['Value'][0]['00081190']['Value'][0].
eb6d219af210 test stow
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 32
diff changeset
176 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
177
83
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
178 # Remove the "http://localhost:8042" prefix
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
179 url = a['00081190']['Value'][0]
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
180 url = re.sub(r'(http|https)://[^/]+(/.*)', r'\2', url)
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
181
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
182 # Get the content-length of all the multiparts of this WADO-RS request
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
183 b = DoGet(ORTHANC, url).decode('utf-8', 'ignore')
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
184 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
185 self.assertEqual(1, len(parts))
3f2170efa8d2 patches for python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 73
diff changeset
186 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
187
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
188 def test_server_get(self):
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
189 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0001.dcm')
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
190
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
191 self.assertEqual(1, len(DoGet(ORTHANC, '/dicom-web/servers')))
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
192 self.assertTrue('sample' in DoGet(ORTHANC, '/dicom-web/servers'))
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
193
129
53d522dd4a38 added tests for ?expand in /dicom-web/servers route
amazy
parents: 114
diff changeset
194 serversReadback = DoGet(ORTHANC, '/dicom-web/servers?expand')
53d522dd4a38 added tests for ?expand in /dicom-web/servers route
amazy
parents: 114
diff changeset
195 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
196 self.assertEqual('alice', serversReadback['sample']['Username'])
53d522dd4a38 added tests for ?expand in /dicom-web/servers route
amazy
parents: 114
diff changeset
197
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
198 sample = DoGet(ORTHANC, '/dicom-web/servers/sample')
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
199 self.assertEqual(3, len(sample))
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
200 self.assertTrue('stow' in sample)
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
201 self.assertTrue('retrieve' in sample)
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
202 self.assertTrue('get' in sample)
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
203
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
204 # application/dicom+xml
131
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
205 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
206 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
207 re.MULTILINE)))
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
208 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
209 (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
210 { 'Uri' : '/studies',
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
211 '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
212 }), re.MULTILINE)))
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
213
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
214 # application/dicom+json
131
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
215 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
216 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
217 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
218 { 'Uri' : '/studies',
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
219 '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
220
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
221 # application/json
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
222 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
223 headers = { 'Accept' : 'application/json' })))
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
224 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
225 { 'Uri' : '/studies',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
226 'HttpHeaders' : { 'Accept' : 'application/json' }})))
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
227
131
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
228 # 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
229 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
230 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
231 { 'Uri' : '/studies' })))
90e5331ddee9 application/dicom+json is now the default in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 130
diff changeset
232
84
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
233
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
234 def test_server_stow(self):
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
235 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0001.dcm')
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
236
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
237 self.assertRaises(Exception, lambda:
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
238 DoPost(ORTHANC, '/dicom-web/servers/sample/stow',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
239 { 'Resources' : [ 'nope' ]})) # inexisting resource
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
240
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
241 self.assertEqual(0, len(DoPost(ORTHANC, '/dicom-web/servers/sample/stow',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
242 { 'Resources' : [ 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17' ]}))) # patient
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
243
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
244 self.assertEqual(0, len(DoPost(ORTHANC, '/dicom-web/servers/sample/stow',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
245 { 'Resources' : [ '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918' ]}))) # study
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
246
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
247 self.assertEqual(0, len(DoPost(ORTHANC, '/dicom-web/servers/sample/stow',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
248 { 'Resources' : [ '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285' ]}))) # series
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
249
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
250 self.assertEqual(0, len(DoPost(ORTHANC, '/dicom-web/servers/sample/stow',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
251 { 'Resources' : [ 'c8df6478-d7794217-0f11c293-a41237c9-31d98357' ]}))) # instance
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
252
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
253 self.assertEqual(0, len(DoPost(ORTHANC, '/dicom-web/servers/sample/stow',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
254 { 'Resources' : [
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
255 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
256 '0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
257 '6de73705-c4e65c1b-9d9ea1b5-cabcd8e7-f15e4285',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
258 'c8df6478-d7794217-0f11c293-a41237c9-31d98357' ]}))) # altogether
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
259
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
260
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
261 def test_server_retrieve(self):
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
262 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0001.dcm')
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
263 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0002.dcm')
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
264 UploadInstance(ORTHANC, 'Knee/T2/IM-0001-0001.dcm')
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
265
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
266 self.assertRaises(Exception, lambda:
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
267 DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
268 { 'Resources' : [ { 'Study' : 'nope' } ]})) # inexisting resource
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
269
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
270 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
271 { '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
272 self.assertEqual(3, len(t['Instances']))
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
273
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
274 # Missing "Study" field
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
275 self.assertRaises(Exception, lambda:
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
276 DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
277 { '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
278
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
279 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
280 { '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
281 '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
282 self.assertEqual(2, len(t['Instances']))
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
283
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
284 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
285 { '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
286 '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
287 self.assertEqual(1, len(t['Instances']))
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
288
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
289 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
290 { '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
291 '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
292 { 'Study' : '2.16.840.1.113669.632.20.121711.10000160881',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
293 '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
294 self.assertEqual(3, len(t['Instances']))
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
295
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
296 t = DoPost(ORTHANC, '/dicom-web/servers/sample/retrieve',
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
297 { '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
298 '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
299 'Instance' : '1.3.46.670589.11.17521.5.0.3124.2008081909113806560' } ] })
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
300 self.assertEqual(1, len(t['Instances']))
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
301
dc90b87471a8 tests for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
302
114
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
303 def test_bitbucket_issue_53(self):
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
304 # 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
305 # https://bitbucket.org/sjodogne/orthanc/issues/53
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
306
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
307 UploadInstance(ORTHANC, 'Brainix/Flair/IM-0001-0001.dcm')
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
308 UploadInstance(ORTHANC, 'Knee/T1/IM-0001-0001.dcm')
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
309
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
310 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
311 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
312
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
313 a = DoGet(ORTHANC, '/dicom-web/studies',
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
314 headers = { 'accept' : 'application/json' })
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
315 self.assertEqual(2, len(a))
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
316
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
317 b = []
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
318 a = DoGet(ORTHANC, '/dicom-web/studies?limit=1',
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
319 headers = { 'accept' : 'application/json' })
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
320 self.assertEqual(1, len(a))
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
321 b.append(a[0]['0020000D']['Value'][0])
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
322
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
323 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
324 headers = { 'accept' : 'application/json' })
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
325 self.assertEqual(1, len(a))
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
326 b.append(a[0]['0020000D']['Value'][0])
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
327
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
328 self.assertTrue(brainix in b)
a6019560272f test_bitbucket_issue_53
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
329 self.assertTrue(knee in b)
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331
184
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
332 def test_bitbucket_issue_111(self):
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
333 # According to the standard, section F.2.5
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
334 # (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
335 # 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
336 # 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
337 # preserved in the DICOM JSON attribute object containing no
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
338 # "Value", "BulkDataURI" or "InlineBinary".
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
339 # 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
340
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
341 UploadInstance(ORTHANC, 'ColorTestMalaterre.dcm')
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
342
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
343 a = DoGet(ORTHANC, '/dicom-web/studies',
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
344 headers = { 'accept' : 'application/json' })
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
345
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
346 pprint.pprint(a)
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
347
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
348 self.assertEqual(1, len(a))
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
349 self.assertTrue('00080050' in a[0]) # AccessionNumber is null
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
350 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
351 self.assertEqual('SH', a[0]['00080050']['vr'])
e244312964d6 test_bitbucket_issue_111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 131
diff changeset
352
32
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 try:
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 print('\nStarting the tests...')
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 unittest.main(argv = [ sys.argv[0] ] + args.options)
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 finally:
682c4e2a1162 integration tests for wado
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 print('\nDone')