comparison 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
comparison
equal deleted inserted replaced
307:5be63aef39b1 308:2565d39dd36c
137 { 137 {
138 'StudyDescription': 'Sébastien^', 138 'StudyDescription': 'Sébastien^',
139 'StudyDate' : '19700202', 139 'StudyDate' : '19700202',
140 } 140 }
141 ] 141 ]
142
143 142
144 143
145 class Orthanc(unittest.TestCase): 144 class Orthanc(unittest.TestCase):
146 def setUp(self): 145 def setUp(self):
147 if (sys.version_info >= (3, 0)): 146 if (sys.version_info >= (3, 0)):
1629 def test_googlecode_issue_19(self): 1628 def test_googlecode_issue_19(self):
1630 # This is an image with "YBR_FULL" photometric interpretation, it is not supported by Orthanc 1629 # This is an image with "YBR_FULL" photometric interpretation, it is not supported by Orthanc
1631 # gdcmconv -i /home/jodogne/DICOM/GdcmDatabase/US_DataSet/HDI5000_US/3EAF5E01 -w -o Issue19.dcm 1630 # gdcmconv -i /home/jodogne/DICOM/GdcmDatabase/US_DataSet/HDI5000_US/3EAF5E01 -w -o Issue19.dcm
1632 1631
1633 a = UploadInstance(_REMOTE, 'Issue19.dcm')['ID'] 1632 a = UploadInstance(_REMOTE, 'Issue19.dcm')['ID']
1634 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/941ad3c8-05d05b88-560459f9-0eae0e20-6cddd533/preview')) 1633 if not HasGdcmPlugin(_REMOTE):
1634 self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/instances/941ad3c8-05d05b88-560459f9-0eae0e20-6cddd533/preview'))
1635 1635
1636 1636
1637 def test_googlecode_issue_37(self): 1637 def test_googlecode_issue_37(self):
1638 # Same test for issues 35 and 37. Fixed in Orthanc 0.9.1 1638 # Same test for issues 35 and 37. Fixed in Orthanc 0.9.1
1639 u = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID'] 1639 u = UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm')['ID']
3072 Check('1.2.840.10008.1.2.4.70', '7132cfbc457305b04b59787030c785d2') 3072 Check('1.2.840.10008.1.2.4.70', '7132cfbc457305b04b59787030c785d2')
3073 Check('1.2.840.10008.1.2.4.80', '6ff51ae525d362e0d04f550a64075a0e') 3073 Check('1.2.840.10008.1.2.4.80', '6ff51ae525d362e0d04f550a64075a0e')
3074 Check('1.2.840.10008.1.2.4.81', '801579ae7cbf28e604ea74f2c99fa2ca') 3074 Check('1.2.840.10008.1.2.4.81', '801579ae7cbf28e604ea74f2c99fa2ca')
3075 Check('1.2.840.10008.1.2.5', '6ff51ae525d362e0d04f550a64075a0e') # RLE, supported since Orthanc 1.0.1 3075 Check('1.2.840.10008.1.2.5', '6ff51ae525d362e0d04f550a64075a0e') # RLE, supported since Orthanc 1.0.1
3076 Check('1.2.840.10008.1.2', 'd54aed9f67a100984b42942cc2e9939b') 3076 Check('1.2.840.10008.1.2', 'd54aed9f67a100984b42942cc2e9939b')
3077 Check('1.2.840.10008.1.2.4.90', None) # JPEG-2000 image, not supported 3077
3078 Check('1.2.840.10008.1.2.4.91', None) # JPEG-2000 image, not supported 3078 # JPEG2k image, not supported without GDCM plugin
3079 if not HasGdcmPlugin(_REMOTE):
3080 Check('1.2.840.10008.1.2.4.90', None)
3081 Check('1.2.840.10008.1.2.4.91', None)
3079 3082
3080 3083
3081 def test_raw_frame(self): 3084 def test_raw_frame(self):
3082 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID'] 3085 s = UploadInstance(_REMOTE, 'Issue22.dcm')['ID']
3083 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s))) 3086 self.assertEqual(24, len(DoGet(_REMOTE, '/instances/%s/frames' % s)))
5509 # because of this transcoding 5512 # because of this transcoding
5510 tags = DoGet(_LOCAL, '/instances/%s/tags' % j[0]) 5513 tags = DoGet(_LOCAL, '/instances/%s/tags' % j[0])
5511 self.assertEqual('NORMAL', tags['1337,1001']['Value']) 5514 self.assertEqual('NORMAL', tags['1337,1001']['Value'])
5512 5515
5513 5516
5514 def test_modify_transcode(self): 5517 def test_modify_transcode_instance(self):
5515 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] 5518 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID']
5516 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax( 5519 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(
5517 DoGet(_REMOTE, '/instances/%s/file' % i))) 5520 DoGet(_REMOTE, '/instances/%s/file' % i)))
5518 5521
5519 for syntax in [ 5522 a = ExtractDicomTags(DoGet(_REMOTE, '/instances/%s/file' % i), [ 'SOPInstanceUID' ]) [0]
5520 '1.2.840.10008.1.2', 5523 self.assertTrue(len(a) > 20)
5521 '1.2.840.10008.1.2.1', 5524
5522 #'1.2.840.10008.1.2.1.99', # Deflated Explicit VR Little Endian 5525 SYNTAXES = [
5523 '1.2.840.10008.1.2.2', 5526 '1.2.840.10008.1.2',
5524 '1.2.840.10008.1.2.4.50', 5527 '1.2.840.10008.1.2.1',
5525 '1.2.840.10008.1.2.4.51', 5528 #'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)
5526 '1.2.840.10008.1.2.4.57', 5529 '1.2.840.10008.1.2.2',
5527 '1.2.840.10008.1.2.4.70', 5530 '1.2.840.10008.1.2.4.50',
5528 #'1.2.840.10008.1.2.4.80', # This makes DCMTK 3.6.2 crash 5531 '1.2.840.10008.1.2.4.51',
5529 #'1.2.840.10008.1.2.4.81', # This makes DCMTK 3.6.2 crash 5532 '1.2.840.10008.1.2.4.57',
5530 ]: 5533 '1.2.840.10008.1.2.4.70',
5534 ]
5535
5536 if HasGdcmPlugin(_REMOTE):
5537 SYNTAXES = SYNTAXES + [
5538 '1.2.840.10008.1.2.4.80', # This makes DCMTK 3.6.2 crash
5539 '1.2.840.10008.1.2.4.81', # This makes DCMTK 3.6.2 crash
5540 '1.2.840.10008.1.2.4.90', # JPEG2k, unavailable without GDCM
5541 '1.2.840.10008.1.2.4.91', # JPEG2k, unavailable without GDCM
5542 ]
5543
5544 for syntax in SYNTAXES:
5531 transcoded = DoPost(_REMOTE, '/instances/%s/modify' % i, { 5545 transcoded = DoPost(_REMOTE, '/instances/%s/modify' % i, {
5532 'Transcode' : syntax, 5546 'Transcode' : syntax,
5547 'Keep' : [ 'SOPInstanceUID' ],
5548 'Force' : True,
5533 }) 5549 })
5534 5550
5535 self.assertEqual(syntax, GetTransferSyntax(transcoded)) 5551 self.assertEqual(syntax, GetTransferSyntax(transcoded))
5536 5552
5553 b = ExtractDicomTags(transcoded, [ 'SOPInstanceUID' ]) [0]
5554 self.assertTrue(len(b) > 20)
5555 if syntax in [ '1.2.840.10008.1.2.4.50',
5556 '1.2.840.10008.1.2.4.51',
5557 '1.2.840.10008.1.2.4.81',
5558 '1.2.840.10008.1.2.4.91' ]:
5559 # Lossy transcoding: The SOP instance UID must have changed
5560 self.assertNotEqual(a, b)
5561 else:
5562 self.assertEqual(a, b)
5537 5563
5538 def test_archive_transcode(self): 5564 def test_archive_transcode(self):
5539 info = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm') 5565 info = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')
5540 5566
5541 # GET on "/media" 5567 # GET on "/media"
5632 'Transcode' : '1.2.840.10008.1.2.4.57', 5658 'Transcode' : '1.2.840.10008.1.2.4.57',
5633 }) 5659 })
5634 self.assertEqual(2, len(z.namelist())) 5660 self.assertEqual(2, len(z.namelist()))
5635 self.assertEqual('1.2.840.10008.1.2.4.57', GetTransferSyntax(z.read('IMAGES/IM0'))) 5661 self.assertEqual('1.2.840.10008.1.2.4.57', GetTransferSyntax(z.read('IMAGES/IM0')))
5636 5662
5637 5663
5638 5664 def test_modify_keep_source(self):
5665 # https://groups.google.com/d/msg/orthanc-users/CgU-Wg8vDio/BY5ZWcDEAgAJ
5666 i = UploadInstance(_REMOTE, 'DummyCT.dcm')
5667 self.assertEqual(1, len(DoGet(_REMOTE, '/studies')))
5668
5669 j = DoPost(_REMOTE, '/studies/%s/modify' % i['ParentStudy'], {
5670 'Replace' : {
5671 'StationName' : 'TEST',
5672 },
5673 'KeepSource' : True,
5674 })
5675
5676 s = DoGet(_REMOTE, '/studies')
5677 self.assertEqual(2, len(s))
5678 self.assertTrue(i['ParentStudy'] in s)
5679 self.assertTrue(j['ID'] in s)
5680
5681 DoDelete(_REMOTE, '/studies/%s' % j['ID'])
5682 self.assertEqual(1, len(DoGet(_REMOTE, '/studies')))
5683
5684 j = DoPost(_REMOTE, '/studies/%s/modify' % i['ParentStudy'], {
5685 'Replace' : {
5686 'StationName' : 'TEST',
5687 },
5688 'KeepSource' : False,
5689 })
5690
5691 s = DoGet(_REMOTE, '/studies')
5692 self.assertEqual(1, len(s))
5693 self.assertFalse(i['ParentStudy'] in s)
5694 self.assertTrue(j['ID'] in s)
5695
5696
5697 def test_modify_transcode_study(self):
5698 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')
5699 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(
5700 DoGet(_REMOTE, '/instances/%s/file' % i['ID'])))
5701
5702 self.assertEqual(1, len(DoGet(_REMOTE, '/instances')))
5703 j = DoPost(_REMOTE, '/studies/%s/modify' % i['ParentStudy'], {
5704 'Transcode' : '1.2.840.10008.1.2.4.50',
5705 'KeepSource' : False
5706 })
5707
5708 k = DoGet(_REMOTE, '/instances')
5709 self.assertEqual(1, len(k))
5710 self.assertEqual(i['ID'], DoGet(_REMOTE, '/instances/%s/metadata?expand' % k[0]) ['ModifiedFrom'])
5711 self.assertEqual('1.2.840.10008.1.2.4.50', GetTransferSyntax(
5712 DoGet(_REMOTE, '/instances/%s/file' % k[0])))
5713
5714
5715 def test_store_peer_transcoding(self):
5716 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID']
5717
5718 SYNTAXES = [
5719 '1.2.840.10008.1.2',
5720 '1.2.840.10008.1.2.1',
5721 #'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)
5722 '1.2.840.10008.1.2.2',
5723 '1.2.840.10008.1.2.4.50',
5724 '1.2.840.10008.1.2.4.51',
5725 '1.2.840.10008.1.2.4.57',
5726 '1.2.840.10008.1.2.4.70',
5727 ]
5728
5729 if HasGdcmPlugin(_REMOTE):
5730 SYNTAXES = SYNTAXES + [
5731 '1.2.840.10008.1.2.4.80', # This makes DCMTK 3.6.2 crash
5732 '1.2.840.10008.1.2.4.81', # This makes DCMTK 3.6.2 crash
5733 '1.2.840.10008.1.2.4.90', # JPEG2k, unavailable without GDCM
5734 '1.2.840.10008.1.2.4.91', # JPEG2k, unavailable without GDCM
5735 ]
5736
5737 for syntax in SYNTAXES:
5738 body = {
5739 'Resources' : [ i ],
5740 }
5741
5742 if syntax != '1.2.840.10008.1.2.1':
5743 body['Transcode'] = syntax
5744
5745 self.assertEqual(0, len(DoGet(_LOCAL, '/instances')))
5746 self.assertEqual(1, len(DoGet(_REMOTE, '/instances')))
5747 DoPost(_REMOTE, '/peers/peer/store', body, 'text/plain')
5748 self.assertEqual(1, len(DoGet(_LOCAL, '/instances')))
5749 self.assertEqual(1, len(DoGet(_REMOTE, '/instances')))
5750 self.assertEqual(syntax, GetTransferSyntax(
5751 DoGet(_LOCAL, '/instances/%s/file' % DoGet(_LOCAL, '/instances') [0])))
5752
5753 DropOrthanc(_LOCAL)
5754
5755
5639 def test_getscu(self): 5756 def test_getscu(self):
5640 def CleanTarget(): 5757 def CleanTarget():
5641 if os.path.isdir('/tmp/GETSCU'): 5758 if os.path.isdir('/tmp/GETSCU'):
5642 shutil.rmtree('/tmp/GETSCU') 5759 shutil.rmtree('/tmp/GETSCU')
5643 os.makedirs('/tmp/GETSCU') 5760 os.makedirs('/tmp/GETSCU')
5684 ], env = env) 5801 ], env = env)
5685 5802
5686 os.system('ls -l /tmp/GETSCU') 5803 os.system('ls -l /tmp/GETSCU')
5687 self.assertTrue(os.path.isfile('/tmp/GETSCU/MR.1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549')) 5804 self.assertTrue(os.path.isfile('/tmp/GETSCU/MR.1.3.46.670589.11.0.0.11.4.2.0.8743.5.5396.2006120114314079549'))
5688 self.assertTrue(os.path.isfile('/tmp/GETSCU/MR.1.2.276.0.7230010.3.1.4.2831176407.19977.1434973482.75579')) 5805 self.assertTrue(os.path.isfile('/tmp/GETSCU/MR.1.2.276.0.7230010.3.1.4.2831176407.19977.1434973482.75579'))
5689
5690
5691