comparison Tests/Tests.py @ 290:b5333f87065b

test_bitbucket_issue_169
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 07 May 2020 11:37:42 +0200
parents 4a70411ac9ad
children cfa785074c64
comparison
equal deleted inserted replaced
289:4a70411ac9ad 290:b5333f87065b
20 # You should have received a copy of the GNU General Public License 20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>. 21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 22
23 23
24 import base64 24 import base64
25 import bz2
25 import copy 26 import copy
26 import pprint 27 import pprint
27 import tempfile 28 import tempfile
28 import unittest 29 import unittest
29 30
5475 5476
5476 # Export, with transcoding disabled => this fails 5477 # Export, with transcoding disabled => this fails
5477 params['AllowTranscoding'] = False 5478 params['AllowTranscoding'] = False
5478 DoPut(_REMOTE, '/modalities/toto', params) 5479 DoPut(_REMOTE, '/modalities/toto', params)
5479 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/modalities/toto/store', str(i), 'text/plain')) 5480 self.assertRaises(Exception, lambda: DoPost(_REMOTE, '/modalities/toto/store', str(i), 'text/plain'))
5481
5482
5483 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:
5493 dicom = bz2.decompress(f.read())
5494
5495 self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(dicom))
5496
5497 self.assertEqual(44350560, len(dicom))
5498 i = DoPost(_REMOTE, '/instances', dicom, 'application/dicom') ['ID']
5499
5500 tags = DoGet(_REMOTE, '/instances/%s/tags' % i)
5501 self.assertEqual('NORMAL', tags['1337,1001']['Value'])
5502
5503 self.assertEqual(0, len(DoGet(_LOCAL, '/instances')))
5504 DoPost(_REMOTE, '/modalities/orthanctest/store', str(i), 'text/plain')
5505 j = DoGet(_LOCAL, '/instances')
5506 self.assertEqual(1, len(j))
5507
5508 # In Orthanc <= 1.6.1, transfer syntax changed from "Explicit
5509 # VR Little Endian" (1.2.840.10008.1.2.1) to "Implicit VR
5510 # Little Endian" (1.2.840.10008.1.2)
5511 self.assertEqual('1.2.840.10008.1.2.1',
5512 GetTransferSyntax(DoGet(_LOCAL, '/instances/%s/file' % j[0])))
5513
5514 # In Orthanc <= 1.6.1, the value of the private tags was lost
5515 # because of this transcoding
5516 tags = DoGet(_LOCAL, '/instances/%s/tags' % j[0])
5517 self.assertEqual('NORMAL', tags['1337,1001']['Value'])