changeset 560:2db7a9041507

test bulk data negotiation
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 28 Jun 2023 11:43:44 +0200
parents 87fc87897e7e
children a6fb40c2b722
files Plugins/DicomWeb/Run.py
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/DicomWeb/Run.py	Wed Jun 28 11:18:45 2023 +0200
+++ b/Plugins/DicomWeb/Run.py	Wed Jun 28 11:43:44 2023 +0200
@@ -1765,6 +1765,18 @@
             self.assertEqual('application/dicom', response[0][1]['Content-Type'])
             pydicom.dcmread(BytesIO(response[0][0]), force=True)
 
+        def CheckIsBulk(uri, accept):
+            if accept != None:
+                response = DoGetMultipart(ORTHANC, uri, headers = {
+                    'accept': accept
+                }, returnHeaders = True)
+            else:
+                response = DoGetMultipart(ORTHANC, uri,  returnHeaders = True)
+            self.assertEqual(1, len(response))
+            self.assertEqual(2, len(response[0]))
+            self.assertEqual('application/octet-stream', response[0][1]['Content-Type'])
+            self.assertTrue(len(response[0][0]) > 1)
+
         study = UploadInstance(ORTHANC, 'ColorTestImageJ.dcm')['ParentStudy']
         studyUid = DoGet(ORTHANC, '/studies/%s' % study)['MainDicomTags']['StudyInstanceUID']
 
@@ -1789,6 +1801,18 @@
         CheckBadRequest('/dicom-web/studies/%s' % studyUid, 'multipart/related; transfer-syntax=nope')
         CheckIsDicom('/dicom-web/studies/%s' % studyUid, 'multipart/related; type=application/dicom; transfer-syntax=1.2.840.10008.1.2.1')
 
+        uri = '/dicom-web/studies/%s/series/%s/instances/%s/bulk/0010,0010' % (
+            studyUid, '1.3.12.2.1107.5.99.2.1255.30000007020811545343700000012',
+            '1.2.276.0.7230010.3.1.4.2455711835.6056.1170936079.1')
+        CheckIsBulk(uri, None)
+        CheckBadRequest(uri, 'multipart/nope')
+        CheckIsBulk(uri, 'multipart/related')
+        CheckIsBulk(uri, 'multipart/related;type=application/octet-stream')
+        CheckIsBulk(uri, 'multipart/related;   type =  "application/octet-stream"  ')
+        CheckBadRequest(uri, 'multipart/related;   type =  "  application/octet-stream"  ')
+        CheckBadRequest(uri, 'multipart/related;type=application/nope')
+        CheckBadRequest(uri, 'multipart/related;range=')
+
 
 try:
     print('\nStarting the tests...')