changeset 289:4a70411ac9ad

test_storescu_transcoding
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 07 May 2020 11:12:06 +0200
parents 7419c10e9edd
children b5333f87065b
files Tests/Run.py Tests/Tests.py
diffstat 2 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Tests/Run.py	Tue Apr 21 14:47:13 2020 +0200
+++ b/Tests/Run.py	Thu May 07 11:12:06 2020 +0200
@@ -105,6 +105,10 @@
 config = re.sub(r'("DicomModalities"\s*:)\s*{', r'\1 { "orthanc" : [ "%s", "%s", %s ]' % 
                 (args.aet, args.server, args.dicom), config)
 
+# New to test transcoding over DICOM (1.7.0)
+config = re.sub(r'("RleTransferSyntaxAccepted"\s*:)\s*true', r'\1 false', config)
+
+
 with open(CONFIG, 'wt') as f:
     f.write(config)
 
--- a/Tests/Tests.py	Tue Apr 21 14:47:13 2020 +0200
+++ b/Tests/Tests.py	Thu May 07 11:12:06 2020 +0200
@@ -5449,3 +5449,31 @@
         
         self.assertEqual(1, len(DoGet(_LOCAL, '/instances')))
         self.assertEqual(0, len(DoGet(_REMOTE, '/instances')))
+
+
+    def test_storescu_transcoding(self):  # New in Orthanc 1.7.0       
+        # Add a RLE-encoded DICOM file
+        i = UploadInstance(_REMOTE, 'TransferSyntaxes/1.2.840.10008.1.2.5.dcm')['ID']
+        self.assertEqual(0, len(DoGet(_LOCAL, '/instances')))
+        self.assertEqual(1, len(DoGet(_REMOTE, '/instances')))
+        rleSize = len(DoGet(_REMOTE, '/instances/%s/file' % i))
+
+        # Export the instance, with transcoding: "_REMOTE" is the
+        # Orthanc server being tested
+        try:
+            DoDelete(_REMOTE, '/modalities/toto')
+        except:
+            pass
+
+        params = DoGet(_REMOTE, '/modalities?expand') ['orthanctest']
+        DoPut(_REMOTE, '/modalities/toto', params)
+        DoPost(_REMOTE, '/modalities/toto/store', str(i), 'text/plain')
+        j = DoGet(_LOCAL, '/instances')
+        self.assertEqual(1, len(j))
+        uncompressedSize = len(DoGet(_LOCAL, '/instances/%s/file' % j[0]))
+        self.assertTrue(uncompressedSize > rleSize / 2)
+
+        # Export, with transcoding disabled => this fails
+        params['AllowTranscoding'] = False
+        DoPut(_REMOTE, '/modalities/toto', params)
+        self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/modalities/toto/store', str(i), 'text/plain'))