comparison Plugins/DicomWeb/Run.py @ 83:3f2170efa8d2

patches for python3
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 23 Jun 2016 18:04:59 +0200
parents 97acfdf0dbce
children dc90b87471a8
comparison
equal deleted inserted replaced
82:91e2ed032f96 83:3f2170efa8d2
21 import os 21 import os
22 import pprint 22 import pprint
23 import sys 23 import sys
24 import argparse 24 import argparse
25 import unittest 25 import unittest
26 import re
26 from DicomWeb import * 27 from DicomWeb import *
27 28
28 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'Tests')) 29 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'Tests'))
29 from Toolbox import * 30 from Toolbox import *
30 31
88 ## The tests 89 ## The tests
89 ## 90 ##
90 91
91 class Orthanc(unittest.TestCase): 92 class Orthanc(unittest.TestCase):
92 def setUp(self): 93 def setUp(self):
94 if (sys.version_info >= (3, 0)):
95 # Remove annoying warnings about unclosed socket in Python 3
96 import warnings
97 warnings.simplefilter("ignore", ResourceWarning)
98
93 DropOrthanc(ORTHANC) 99 DropOrthanc(ORTHANC)
94 100
95 def test_wado_dicom(self): 101 def test_wado_dicom(self):
96 UploadInstance(ORTHANC, 'Brainix/Flair/IM-0001-0001.dcm') 102 UploadInstance(ORTHANC, 'Brainix/Flair/IM-0001-0001.dcm')
97 103
154 160
155 self.assertTrue(a['00081190']['Value'][0].endswith('studies/2.16.840.1.113669.632.20.1211.10000098591')) 161 self.assertTrue(a['00081190']['Value'][0].endswith('studies/2.16.840.1.113669.632.20.1211.10000098591'))
156 self.assertTrue(a['00081199']['Value'][0]['00081190']['Value'][0]. 162 self.assertTrue(a['00081199']['Value'][0]['00081190']['Value'][0].
157 endswith('series/1.2.840.113704.1.111.5692.1127828999.2/instances/1.2.840.113704.7.1.1.6632.1127829031.2')) 163 endswith('series/1.2.840.113704.1.111.5692.1127828999.2/instances/1.2.840.113704.7.1.1.6632.1127829031.2'))
158 164
159 b = GetMultipart(a['00081190']['Value'][0]) 165 # Remove the "http://localhost:8042" prefix
160 self.assertEqual(1, len(b)) 166 url = a['00081190']['Value'][0]
161 self.assertEqual(368852, len(b[0])) 167 url = re.sub(r'(http|https)://[^/]+(/.*)', r'\2', url)
168
169 # Get the content-length of all the multiparts of this WADO-RS request
170 b = DoGet(ORTHANC, url).decode('utf-8', 'ignore')
171 parts = re.findall(r'^Content-Length:\s*(\d+)\s*', b, re.IGNORECASE | re.MULTILINE)
172 self.assertEqual(1, len(parts))
173 self.assertEqual(os.path.getsize(GetDatabasePath('Phenix/IM-0001-0001.dcm')), int(parts[0]))
162 174
163 175
164 176
165 try: 177 try:
166 print('\nStarting the tests...') 178 print('\nStarting the tests...')