# HG changeset patch # User Sebastien Jodogne # Date 1588842726 -7200 # Node ID 4a70411ac9ad1fdf04327aaf69e1d12178e9b857 # Parent 7419c10e9eddf3922e0393871a0081468a4469ec test_storescu_transcoding diff -r 7419c10e9edd -r 4a70411ac9ad Tests/Run.py --- 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) diff -r 7419c10e9edd -r 4a70411ac9ad Tests/Tests.py --- 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'))