Mercurial > hg > orthanc-tests
diff Tests/Tests.py @ 308:2565d39dd36c c-get
integration mainline->c-get
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 20 May 2020 16:35:06 +0200 |
parents | 5be63aef39b1 ed20ead1a8b6 |
children | 07e2adc4aead |
line wrap: on
line diff
--- a/Tests/Tests.py Wed May 20 16:31:54 2020 +0200 +++ b/Tests/Tests.py Wed May 20 16:35:06 2020 +0200 @@ -141,7 +141,6 @@ ] - class Orthanc(unittest.TestCase): def setUp(self): if (sys.version_info >= (3, 0)): @@ -1631,7 +1630,8 @@ # gdcmconv -i /home/jodogne/DICOM/GdcmDatabase/US_DataSet/HDI5000_US/3EAF5E01 -w -o Issue19.dcm a = UploadInstance(_REMOTE, 'Issue19.dcm')['ID'] - self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/941ad3c8-05d05b88-560459f9-0eae0e20-6cddd533/preview')) + if not HasGdcmPlugin(_REMOTE): + self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/941ad3c8-05d05b88-560459f9-0eae0e20-6cddd533/preview')) def test_googlecode_issue_37(self): @@ -3074,8 +3074,11 @@ Check('1.2.840.10008.1.2.4.81', '801579ae7cbf28e604ea74f2c99fa2ca') Check('1.2.840.10008.1.2.5', '6ff51ae525d362e0d04f550a64075a0e') # RLE, supported since Orthanc 1.0.1 Check('1.2.840.10008.1.2', 'd54aed9f67a100984b42942cc2e9939b') - Check('1.2.840.10008.1.2.4.90', None) # JPEG-2000 image, not supported - Check('1.2.840.10008.1.2.4.91', None) # JPEG-2000 image, not supported + + # JPEG2k image, not supported without GDCM plugin + if not HasGdcmPlugin(_REMOTE): + Check('1.2.840.10008.1.2.4.90', None) + Check('1.2.840.10008.1.2.4.91', None) def test_raw_frame(self): @@ -5511,29 +5514,52 @@ self.assertEqual('NORMAL', tags['1337,1001']['Value']) - def test_modify_transcode(self): + def test_modify_transcode_instance(self): i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax( DoGet(_REMOTE, '/instances/%s/file' % i))) - for syntax in [ - '1.2.840.10008.1.2', - '1.2.840.10008.1.2.1', - #'1.2.840.10008.1.2.1.99', # Deflated Explicit VR Little Endian - '1.2.840.10008.1.2.2', - '1.2.840.10008.1.2.4.50', - '1.2.840.10008.1.2.4.51', - '1.2.840.10008.1.2.4.57', - '1.2.840.10008.1.2.4.70', - #'1.2.840.10008.1.2.4.80', # This makes DCMTK 3.6.2 crash - #'1.2.840.10008.1.2.4.81', # This makes DCMTK 3.6.2 crash - ]: + a = ExtractDicomTags(DoGet(_REMOTE, '/instances/%s/file' % i), [ 'SOPInstanceUID' ]) [0] + self.assertTrue(len(a) > 20) + + SYNTAXES = [ + '1.2.840.10008.1.2', + '1.2.840.10008.1.2.1', + #'1.2.840.10008.1.2.1.99', # Deflated Explicit VR Little Endian (cannot be decoded in debug mode if Orthanc is statically linked against DCMTK 3.6.5) + '1.2.840.10008.1.2.2', + '1.2.840.10008.1.2.4.50', + '1.2.840.10008.1.2.4.51', + '1.2.840.10008.1.2.4.57', + '1.2.840.10008.1.2.4.70', + ] + + if HasGdcmPlugin(_REMOTE): + SYNTAXES = SYNTAXES + [ + '1.2.840.10008.1.2.4.80', # This makes DCMTK 3.6.2 crash + '1.2.840.10008.1.2.4.81', # This makes DCMTK 3.6.2 crash + '1.2.840.10008.1.2.4.90', # JPEG2k, unavailable without GDCM + '1.2.840.10008.1.2.4.91', # JPEG2k, unavailable without GDCM + ] + + for syntax in SYNTAXES: transcoded = DoPost(_REMOTE, '/instances/%s/modify' % i, { 'Transcode' : syntax, + 'Keep' : [ 'SOPInstanceUID' ], + 'Force' : True, }) self.assertEqual(syntax, GetTransferSyntax(transcoded)) + b = ExtractDicomTags(transcoded, [ 'SOPInstanceUID' ]) [0] + self.assertTrue(len(b) > 20) + if syntax in [ '1.2.840.10008.1.2.4.50', + '1.2.840.10008.1.2.4.51', + '1.2.840.10008.1.2.4.81', + '1.2.840.10008.1.2.4.91' ]: + # Lossy transcoding: The SOP instance UID must have changed + self.assertNotEqual(a, b) + else: + self.assertEqual(a, b) def test_archive_transcode(self): info = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm') @@ -5634,8 +5660,99 @@ self.assertEqual(2, len(z.namelist())) self.assertEqual('1.2.840.10008.1.2.4.57', GetTransferSyntax(z.read('IMAGES/IM0'))) + + def test_modify_keep_source(self): + # https://groups.google.com/d/msg/orthanc-users/CgU-Wg8vDio/BY5ZWcDEAgAJ + i = UploadInstance(_REMOTE, 'DummyCT.dcm') + self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) + + j = DoPost(_REMOTE, '/studies/%s/modify' % i['ParentStudy'], { + 'Replace' : { + 'StationName' : 'TEST', + }, + 'KeepSource' : True, + }) + + s = DoGet(_REMOTE, '/studies') + self.assertEqual(2, len(s)) + self.assertTrue(i['ParentStudy'] in s) + self.assertTrue(j['ID'] in s) + + DoDelete(_REMOTE, '/studies/%s' % j['ID']) + self.assertEqual(1, len(DoGet(_REMOTE, '/studies'))) + + j = DoPost(_REMOTE, '/studies/%s/modify' % i['ParentStudy'], { + 'Replace' : { + 'StationName' : 'TEST', + }, + 'KeepSource' : False, + }) + + s = DoGet(_REMOTE, '/studies') + self.assertEqual(1, len(s)) + self.assertFalse(i['ParentStudy'] in s) + self.assertTrue(j['ID'] in s) + + + def test_modify_transcode_study(self): + i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm') + self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax( + DoGet(_REMOTE, '/instances/%s/file' % i['ID']))) + + self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) + j = DoPost(_REMOTE, '/studies/%s/modify' % i['ParentStudy'], { + 'Transcode' : '1.2.840.10008.1.2.4.50', + 'KeepSource' : False + }) + + k = DoGet(_REMOTE, '/instances') + self.assertEqual(1, len(k)) + self.assertEqual(i['ID'], DoGet(_REMOTE, '/instances/%s/metadata?expand' % k[0]) ['ModifiedFrom']) + self.assertEqual('1.2.840.10008.1.2.4.50', GetTransferSyntax( + DoGet(_REMOTE, '/instances/%s/file' % k[0]))) + def test_store_peer_transcoding(self): + i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] + + SYNTAXES = [ + '1.2.840.10008.1.2', + '1.2.840.10008.1.2.1', + #'1.2.840.10008.1.2.1.99', # Deflated Explicit VR Little Endian (cannot be decoded in debug mode if Orthanc is statically linked against DCMTK 3.6.5) + '1.2.840.10008.1.2.2', + '1.2.840.10008.1.2.4.50', + '1.2.840.10008.1.2.4.51', + '1.2.840.10008.1.2.4.57', + '1.2.840.10008.1.2.4.70', + ] + + if HasGdcmPlugin(_REMOTE): + SYNTAXES = SYNTAXES + [ + '1.2.840.10008.1.2.4.80', # This makes DCMTK 3.6.2 crash + '1.2.840.10008.1.2.4.81', # This makes DCMTK 3.6.2 crash + '1.2.840.10008.1.2.4.90', # JPEG2k, unavailable without GDCM + '1.2.840.10008.1.2.4.91', # JPEG2k, unavailable without GDCM + ] + + for syntax in SYNTAXES: + body = { + 'Resources' : [ i ], + } + + if syntax != '1.2.840.10008.1.2.1': + body['Transcode'] = syntax + + self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) + self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) + DoPost(_REMOTE, '/peers/peer/store', body, 'text/plain') + self.assertEqual(1, len(DoGet(_LOCAL, '/instances'))) + self.assertEqual(1, len(DoGet(_REMOTE, '/instances'))) + self.assertEqual(syntax, GetTransferSyntax( + DoGet(_LOCAL, '/instances/%s/file' % DoGet(_LOCAL, '/instances') [0]))) + + DropOrthanc(_LOCAL) + + def test_getscu(self): def CleanTarget(): if os.path.isdir('/tmp/GETSCU'): @@ -5686,6 +5803,3 @@ os.system('ls -l /tmp/GETSCU') self.assertTrue(os.path.isfile('/tmp/GETSCU/MR.1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549')) self.assertTrue(os.path.isfile('/tmp/GETSCU/MR.1.2.276.0.7230010.3.1.4.2831176407.19977.1434973482.75579')) - - -