Mercurial > hg > orthanc-tests
comparison Tests/Tests.py @ 291:cfa785074c64
test_modify_transcode
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 07 May 2020 15:33:40 +0200 |
parents | b5333f87065b |
children | e1827a4f5d3b |
comparison
equal
deleted
inserted
replaced
290:b5333f87065b | 291:cfa785074c64 |
---|---|
134 { | 134 { |
135 'StudyDescription': 'Sébastien^', | 135 'StudyDescription': 'Sébastien^', |
136 'StudyDate' : '19700202', | 136 'StudyDate' : '19700202', |
137 } | 137 } |
138 ] | 138 ] |
139 | |
140 | 139 |
141 | 140 |
142 | 141 |
143 class Orthanc(unittest.TestCase): | 142 class Orthanc(unittest.TestCase): |
144 def setUp(self): | 143 def setUp(self): |
5479 DoPut(_REMOTE, '/modalities/toto', params) | 5478 DoPut(_REMOTE, '/modalities/toto', params) |
5480 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/modalities/toto/store', str(i), 'text/plain')) | 5479 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/modalities/toto/store', str(i), 'text/plain')) |
5481 | 5480 |
5482 | 5481 |
5483 def test_bitbucket_issue_169(self): | 5482 def test_bitbucket_issue_169(self): |
5484 def GetTransferSyntax(dicom): | |
5485 with tempfile.NamedTemporaryFile(delete = True) as f: | |
5486 f.write(dicom) | |
5487 f.flush() | |
5488 data = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) | |
5489 | |
5490 return re.search('<data-set xfer="(.*?)"', data).group(1) | |
5491 | |
5492 with open(GetDatabasePath('Issue169.dcm.bz2'), 'rb') as f: | 5483 with open(GetDatabasePath('Issue169.dcm.bz2'), 'rb') as f: |
5493 dicom = bz2.decompress(f.read()) | 5484 dicom = bz2.decompress(f.read()) |
5494 | 5485 |
5495 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(dicom)) | 5486 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(dicom)) |
5496 | 5487 |
5506 self.assertEqual(1, len(j)) | 5497 self.assertEqual(1, len(j)) |
5507 | 5498 |
5508 # In Orthanc <= 1.6.1, transfer syntax changed from "Explicit | 5499 # In Orthanc <= 1.6.1, transfer syntax changed from "Explicit |
5509 # VR Little Endian" (1.2.840.10008.1.2.1) to "Implicit VR | 5500 # VR Little Endian" (1.2.840.10008.1.2.1) to "Implicit VR |
5510 # Little Endian" (1.2.840.10008.1.2) | 5501 # Little Endian" (1.2.840.10008.1.2) |
5511 self.assertEqual('1.2.840.10008.1.2.1', | 5502 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax( |
5512 GetTransferSyntax(DoGet(_LOCAL, '/instances/%s/file' % j[0]))) | 5503 DoGet(_LOCAL, '/instances/%s/file' % j[0]))) |
5513 | 5504 |
5514 # In Orthanc <= 1.6.1, the value of the private tags was lost | 5505 # In Orthanc <= 1.6.1, the value of the private tags was lost |
5515 # because of this transcoding | 5506 # because of this transcoding |
5516 tags = DoGet(_LOCAL, '/instances/%s/tags' % j[0]) | 5507 tags = DoGet(_LOCAL, '/instances/%s/tags' % j[0]) |
5517 self.assertEqual('NORMAL', tags['1337,1001']['Value']) | 5508 self.assertEqual('NORMAL', tags['1337,1001']['Value']) |
5509 | |
5510 | |
5511 def test_modify_transcode(self): | |
5512 i = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')['ID'] | |
5513 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax( | |
5514 DoGet(_REMOTE, '/instances/%s/file' % i))) | |
5515 | |
5516 for syntax in [ | |
5517 '1.2.840.10008.1.2', | |
5518 '1.2.840.10008.1.2.1', | |
5519 #'1.2.840.10008.1.2.1.99', # Deflated Explicit VR Little Endian | |
5520 '1.2.840.10008.1.2.2', | |
5521 '1.2.840.10008.1.2.4.50', | |
5522 '1.2.840.10008.1.2.4.51', | |
5523 '1.2.840.10008.1.2.4.57', | |
5524 '1.2.840.10008.1.2.4.70', | |
5525 #'1.2.840.10008.1.2.4.80', # This makes DCMTK 3.6.2 crash | |
5526 #'1.2.840.10008.1.2.4.81', # This makes DCMTK 3.6.2 crash | |
5527 ]: | |
5528 transcoded = DoPost(_REMOTE, '/instances/%s/modify' % i, { | |
5529 'Transcode' : syntax, | |
5530 }) | |
5531 | |
5532 self.assertEqual(syntax, GetTransferSyntax(transcoded)) | |
5533 |