changeset 753:a144d6289b92 find-refactoring

integration default->find-refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 16 Dec 2024 11:09:13 +0100
parents 7dce2aa22bbb (current diff) 4a97afe7d8bc (diff)
children 6db94927eddb ca279bb9aea4
files NewTests/Concurrency/docker-compose-transfers-concurrency.yml NewTests/Concurrency/test_transfer.py NewTests/PostgresUpgrades/downgrade.sh Tests/Tests.py
diffstat 5 files changed, 115 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/NewTests/PostgresUpgrades/downgrade.sh	Mon Dec 16 11:06:05 2024 +0100
+++ b/NewTests/PostgresUpgrades/downgrade.sh	Mon Dec 16 11:09:13 2024 +0100
@@ -9,4 +9,4 @@
 
 # if you want to test a downgrade procedure, you may use this code ...
 # psql -U postgres -f downgrade.sql
-popd
\ No newline at end of file
+popd
--- a/Plugins/DicomWeb/Run.py	Mon Dec 16 11:06:05 2024 +0100
+++ b/Plugins/DicomWeb/Run.py	Mon Dec 16 11:09:13 2024 +0100
@@ -303,7 +303,7 @@
                                  { 'Resources' : [ 'nope' ],
                                    'Synchronous' : True }))  # inexisting resource
 
-        if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 18, 0):
+        if IsPluginVersionAtLeast(ORTHANC, "dicom-web", 1, 18, 0):
             l = 4   # "Server" has been added
         else:
             l = 3   # For >= 1.10.1
@@ -315,7 +315,7 @@
 
         self.assertEqual(l, len(r))
         self.assertEqual("0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918", r['Resources']['Studies'][0])
-        if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 18, 0):
+        if IsPluginVersionAtLeast(ORTHANC, "dicom-web", 1, 18, 0):
             self.assertEqual("sample", r['Server'])
 
         # series
@@ -607,7 +607,7 @@
         self.assertEqual(u'王^小東', pn['Value'][0]['Ideographic'])
 
         # new derivated test added later
-        if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 18, 0):
+        if IsPluginVersionAtLeast(ORTHANC, "dicom-web", 1, 18, 0):
             a = DoGet(ORTHANC, '/dicom-web/studies?StudyInstanceUID=1.3.6.1.4.1.5962.1.2.0.1175775771.5711.0')
             self.assertEqual(1, len(a))
             pn = a[0]['00100010']  # Patient name
@@ -670,7 +670,7 @@
         # WADO-RS RetrieveFrames shall transcode ExplicitBigEndian to ExplicitLittleEndian
         # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=219
         
-        if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 17, 0):
+        if IsPluginVersionAtLeast(ORTHANC, "dicom-web", 1, 17, 0):
 
             UploadInstance(ORTHANC, 'TransferSyntaxes/1.2.840.10008.1.2.2.dcm')
 
@@ -698,7 +698,7 @@
         self.assertTrue('00280010' in a[0])
         self.assertEqual(512, a[0]['00280010']['Value'][0])
 
-        if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 17, 0):
+        if IsPluginVersionAtLeast(ORTHANC, "dicom-web", 1, 17, 0):
             a = DoGet(ORTHANC, '/dicom-web/studies/1.2.840.113619.2.176.2025.1499492.7391.1171285944.390/series/1.2.840.113619.2.176.2025.1499492.7391.1171285944.394/instances?includefield=00081140')
             self.assertEqual(1, len(a))
             self.assertTrue('00081140' in a[0])
@@ -1729,7 +1729,7 @@
         })
         self.assertIn("https://my-domain/dicom-web", m[0][u'7FE00010']['BulkDataURI'])
 
-        if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 13, 1):
+        if IsPluginVersionAtLeast(ORTHANC, "dicom-web", 1, 13, 1):
             m = DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % studyId, headers= {
                 'X-Forwarded-Host': 'my-domain',
                 'X-Forwarded-Proto': 'https'
@@ -1764,7 +1764,7 @@
         self.assertEqual(1, len(m))
         self.assertEqual(studyUid, m[0]['0020000D']['Value'][0])
 
-        if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 13, 1) and IsOrthancVersionAbove(ORTHANC, 1, 12, 1):
+        if IsPluginVersionAtLeast(ORTHANC, "dicom-web", 1, 13, 1) and IsOrthancVersionAbove(ORTHANC, 1, 12, 1):
             # This fails on DICOMweb <= 1.13 because of the "; q=.2",
             # since multiple accepts were not supported
             # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=216
--- a/Plugins/WSI/Run.py	Mon Dec 16 11:06:05 2024 +0100
+++ b/Plugins/WSI/Run.py	Mon Dec 16 11:09:13 2024 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 # -*- coding: utf-8 -*-
 
 
@@ -461,7 +461,7 @@
 
         self.assertEqual(3, len(info['sizes']))
         
-        if IsPluginVersionAbove(ORTHANC, "wsi", 2, 1, 0):   # https://orthanc.uclouvain.be/hg/orthanc-wsi/rev/9dc7f1e8716d
+        if IsPluginVersionAtLeast(ORTHANC, "wsi", 2, 1, 0):   # https://orthanc.uclouvain.be/hg/orthanc-wsi/rev/9dc7f1e8716d
             self.assertEqual(512, info['sizes'][2]['width'])
             self.assertEqual(512, info['sizes'][2]['height'])
             self.assertEqual(256, info['sizes'][1]['width'])
--- a/Tests/Tests.py	Mon Dec 16 11:06:05 2024 +0100
+++ b/Tests/Tests.py	Mon Dec 16 11:09:13 2024 +0100
@@ -11476,3 +11476,106 @@
                                                     },
                                                     'Limit': 10
                                                     }))
+
+
+    def test_attachment_range(self):
+        def TestData(path):
+            (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/%s' % (i, path))
+            self.assertFalse('content-range' in resp)
+            self.assertEqual(200, resp.status)
+            self.assertEqual(2472, len(content))
+            self.assertEqual('2472', resp['content-length'])
+            self.assertEqual('application/dicom', resp['content-type'])
+
+            (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/%s' % (i, path), headers = { 'Range' : 'bytes=128-131' })
+            self.assertTrue('content-range' in resp)
+            self.assertEqual(206, resp.status)
+            self.assertEqual(4, len(content))
+            self.assertEqual('D', content[0])
+            self.assertEqual('I', content[1])
+            self.assertEqual('C', content[2])
+            self.assertEqual('M', content[3])
+            self.assertEqual('4', resp['content-length'])
+            self.assertEqual('application/octet-stream', resp['content-type'])
+            self.assertEqual('bytes 128-131/2472', resp['content-range'])
+
+            (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/%s' % (i, path), headers = { 'Range' : 'bytes=-' })
+            self.assertTrue('content-range' in resp)
+            self.assertEqual(206, resp.status)
+            self.assertEqual(2472, len(content))
+            self.assertEqual('2472', resp['content-length'])
+            self.assertEqual('application/octet-stream', resp['content-type'])
+            self.assertEqual('bytes 0-2471/2472', resp['content-range'])
+
+            (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/%s' % (i, path), headers = { 'Range' : 'bytes=128-' })
+            self.assertTrue('content-range' in resp)
+            self.assertEqual(206, resp.status)
+            self.assertEqual(2344, len(content))
+            self.assertEqual('D', content[0])
+            self.assertEqual('I', content[1])
+            self.assertEqual('C', content[2])
+            self.assertEqual('M', content[3])
+            self.assertEqual('2344', resp['content-length'])
+            self.assertEqual('application/octet-stream', resp['content-type'])
+            self.assertEqual('bytes 128-2471/2472', resp['content-range'])
+
+            (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/%s' % (i, path), headers = { 'Range' : 'bytes=-131' })
+            self.assertTrue('content-range' in resp)
+            self.assertEqual(206, resp.status)
+            self.assertEqual(132, len(content))
+            self.assertEqual('D', content[-4])
+            self.assertEqual('I', content[-3])
+            self.assertEqual('C', content[-2])
+            self.assertEqual('M', content[-1])
+            self.assertEqual('132', resp['content-length'])
+            self.assertEqual('application/octet-stream', resp['content-type'])
+            self.assertEqual('bytes 0-131/2472', resp['content-range'])
+
+        if IsOrthancVersionAbove(_REMOTE, 1, 12, 5):
+            i = UploadInstance(_REMOTE, 'DummyCT.dcm') ['ID']
+
+            DoPost(_REMOTE, '/instances/%s/attachments/dicom/uncompress' % i)
+            TestData('data')
+            TestData('compressed-data')
+
+            DoPost(_REMOTE, '/instances/%s/attachments/dicom/compress' % i)
+            TestData('data')
+
+            (resp, compressed) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i)
+            self.assertFalse('content-range' in resp)
+            self.assertEqual(200, resp.status)
+            self.assertTrue(len(compressed) < 2000)
+            self.assertEqual(len(compressed), int(resp['content-length']))
+            self.assertEqual('application/octet-stream', resp['content-type'])
+
+            (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i, headers = { 'Range' : 'bytes=-' })
+            self.assertTrue('content-range' in resp)
+            self.assertEqual(206, resp.status)
+            self.assertEqual(compressed, content)
+            self.assertEqual(len(compressed), int(resp['content-length']))
+            self.assertEqual('application/octet-stream', resp['content-type'])
+            self.assertEqual('bytes 0-%d/%d' % (len(compressed) - 1, len(compressed)), resp['content-range'])
+
+            (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i, headers = { 'Range' : 'bytes=10-' })
+            self.assertTrue('content-range' in resp)
+            self.assertEqual(206, resp.status)
+            self.assertEqual(compressed[10:], content)
+            self.assertEqual(len(compressed) - 10, int(resp['content-length']))
+            self.assertEqual('application/octet-stream', resp['content-type'])
+            self.assertEqual('bytes 10-%d/%d' % (len(compressed) - 1, len(compressed)), resp['content-range'])
+
+            (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i, headers = { 'Range' : 'bytes=-20' })
+            self.assertTrue('content-range' in resp)
+            self.assertEqual(206, resp.status)
+            self.assertEqual(compressed[0:21], content)
+            self.assertEqual(21, int(resp['content-length']))
+            self.assertEqual('application/octet-stream', resp['content-type'])
+            self.assertEqual('bytes 0-20/%d' % len(compressed), resp['content-range'])
+
+            (resp, content) = DoGetRaw(_REMOTE, '/instances/%s/attachments/dicom/compressed-data' % i, headers = { 'Range' : 'bytes=10-20' })
+            self.assertTrue('content-range' in resp)
+            self.assertEqual(206, resp.status)
+            self.assertEqual(compressed[10:21], content)
+            self.assertEqual(11, int(resp['content-length']))
+            self.assertEqual('application/octet-stream', resp['content-type'])
+            self.assertEqual('bytes 10-20/%d' % len(compressed), resp['content-range'])
--- a/Tests/Toolbox.py	Mon Dec 16 11:06:05 2024 +0100
+++ b/Tests/Toolbox.py	Mon Dec 16 11:09:13 2024 +0100
@@ -394,7 +394,7 @@
     return count
 
 
-def IsPluginVersionAbove(orthanc, plugin, major, minor, revision):
+def IsPluginVersionAtLeast(orthanc, plugin, major, minor, revision):
     v = DoGet(orthanc, '/plugins/%s' % plugin)['Version']
 
     if v.startswith('mainline'):
@@ -412,7 +412,7 @@
             a = int(tmp[0])
             b = int(tmp[1])
             return (a > major or
-                    (a == major and b > minor))
+                    (a == major and b >= minor))
         else:
             return False