# HG changeset patch # User Sebastien Jodogne # Date 1620312788 -7200 # Node ID dd519677974d6707dc81ea257c45ee519383b096 # Parent 9528e2a03d3cf2896ccb31bb07cdf0f1bfc78e95 integration tests for issue 195 diff -r 9528e2a03d3c -r dd519677974d Database/Issue195-bis.dcm Binary file Database/Issue195-bis.dcm has changed diff -r 9528e2a03d3c -r dd519677974d Database/Issue195-bis.dump --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Database/Issue195-bis.dump Thu May 06 16:53:08 2021 +0200 @@ -0,0 +1,5 @@ +# dump2dcm +Ug --write-xfer-little Issue195-bis.dump Issue195-bis.dcm +# => The tag (0008,103e) contains the binary value "42 00" (litte endian, in hexadecimal), as can be seen by hexdump + +(0008,1030) UN (no value available) # 0, 1 StudyDescription +(0008,103e) UN [42] # 0, 1 SeriesDescription diff -r 9528e2a03d3c -r dd519677974d Database/Issue195.dcm Binary file Database/Issue195.dcm has changed diff -r 9528e2a03d3c -r dd519677974d Database/Issue195.dump --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Database/Issue195.dump Thu May 06 16:53:08 2021 +0200 @@ -0,0 +1,4 @@ +# dump2dcm +Ug --write-xfer-little Issue195.dump Issue195.dcm + +(0008,1030) LO (no value available) # 0, 1 StudyDescription +(0008,103e) LO [Hello1] # 0, 1 SeriesDescription diff -r 9528e2a03d3c -r dd519677974d Plugins/DicomWeb/Run.py --- a/Plugins/DicomWeb/Run.py Wed May 05 18:59:08 2021 +0200 +++ b/Plugins/DicomWeb/Run.py Thu May 06 16:53:08 2021 +0200 @@ -1437,6 +1437,81 @@ #print(truth.getpixel((238,275))) # => 254 self.assertLessEqual(abs(bbox[2] - bbox[0]), 1) self.assertLessEqual(abs(bbox[3] - bbox[1]), 1) + + + def test_issue_195(self): + # This fails on Orthanc <= 1.9.2 + # https://bugs.orthanc-server.com/show_bug.cgi?id=195 + a = UploadInstance(ORTHANC, 'Issue195.dcm') ['ID'] + b = DoGet(ORTHANC, 'dicom-web/studies/1.2.276.0.7230010.3.1.2.8323329.13188.1620309604.848733/series/1.2.276.0.7230010.3.1.3.8323329.13188.1620309604.848734/instances/1.2.276.0.7230010.3.1.4.8323329.13188.1620309604.848735/metadata', + headers = { 'Accept' : 'application/dicom+json' }) + + self.assertEqual(1, len(b)) + self.assertEqual(5, len(b[0])) + + # The expected result can be found by typing "dcm2json Database/Issue195.dcm" + self.assertEqual(2, len(b[0]["00080018"])) + self.assertEqual("UI", b[0]["00080018"]["vr"]) + self.assertEqual("1.2.276.0.7230010.3.1.4.8323329.13188.1620309604.848735", + b[0]["00080018"]["Value"][0]) + + self.assertEqual(2, len(b[0]["0020000D"])) + self.assertEqual("UI", b[0]["0020000D"]["vr"]) + self.assertEqual("1.2.276.0.7230010.3.1.2.8323329.13188.1620309604.848733", + b[0]["0020000D"]["Value"][0]) + + self.assertEqual(2, len(b[0]["0020000E"])) + self.assertEqual("UI", b[0]["0020000E"]["vr"]) + self.assertEqual("1.2.276.0.7230010.3.1.3.8323329.13188.1620309604.848734", + b[0]["0020000E"]["Value"][0]) + + self.assertEqual(1, len(b[0]["00081030"])) # Case of an empty value + self.assertEqual("LO", b[0]["00081030"]["vr"]) + + self.assertEqual(2, len(b[0]["0008103E"])) + self.assertEqual("LO", b[0]["0008103E"]["vr"]) + self.assertEqual("Hello1", b[0]["0008103E"]["Value"][0]) + + + DoDelete(ORTHANC, 'instances/%s' % a) + a = UploadInstance(ORTHANC, 'Issue195-bis.dcm') ['ID'] + URI = 'dicom-web/studies/1.2.276.0.7230010.3.1.2.8323329.23653.1620311964.865418/series/1.2.276.0.7230010.3.1.3.8323329.23653.1620311964.865419/instances/1.2.276.0.7230010.3.1.4.8323329.23653.1620311964.865420' + b = DoGet(ORTHANC, '%s/metadata' % URI, + headers = { 'Accept' : 'application/dicom+json' }) + + self.assertEqual(1, len(b)) + self.assertEqual(5, len(b[0])) + + # The expected result can be found by typing "dcm2json Database/Issue195-bis.dcm" + self.assertEqual(2, len(b[0]["00080018"])) + self.assertEqual("UI", b[0]["00080018"]["vr"]) + self.assertEqual("1.2.276.0.7230010.3.1.4.8323329.23653.1620311964.865420", + b[0]["00080018"]["Value"][0]) + + self.assertEqual(2, len(b[0]["0020000D"])) + self.assertEqual("UI", b[0]["0020000D"]["vr"]) + self.assertEqual("1.2.276.0.7230010.3.1.2.8323329.23653.1620311964.865418", + b[0]["0020000D"]["Value"][0]) + + self.assertEqual(2, len(b[0]["0020000E"])) + self.assertEqual("UI", b[0]["0020000E"]["vr"]) + self.assertEqual("1.2.276.0.7230010.3.1.3.8323329.23653.1620311964.865419", + b[0]["0020000E"]["Value"][0]) + + self.assertEqual(2, len(b[0]["0008103E"])) + self.assertEqual("UN", b[0]["0008103E"]["vr"]) + self.assertEqual('http://%s:%s%s' % (args.server, args.rest, '/%s/bulk/0008103e' % URI), + b[0]["0008103E"]["BulkDataURI"]) + + c = DoGet(ORTHANC, '%s/bulk/0008103e' % URI) + self.assertTrue('Content-Length: 2\r\n' in c) + index = c.find('\r\n\r\n') + self.assertEqual(0x42, ord(c[index + 4])) + self.assertEqual(0x00, ord(c[index + 5])) + + # Case of an empty value, fails in Orthanc <= 1.9.2 because of issue #195 + self.assertEqual(1, len(b[0]["00081030"])) + self.assertEqual("UN", b[0]["00081030"]["vr"]) try: diff -r 9528e2a03d3c -r dd519677974d Tests/Tests.py --- a/Tests/Tests.py Wed May 05 18:59:08 2021 +0200 +++ b/Tests/Tests.py Thu May 06 16:53:08 2021 +0200 @@ -6934,3 +6934,67 @@ raise Exception('Internal error') self.assertEqual('hello2', DoGet(_REMOTE, '/instances/%s/attachments/1024/data' % i)) + + + def test_issue_195(self): + # This fails on Orthanc <= 1.9.2 + # https://bugs.orthanc-server.com/show_bug.cgi?id=195 + a = UploadInstance(_REMOTE, 'Issue195.dcm')['ID'] + b = DoGet(_REMOTE, '/instances/%s/file' % a, + headers = { 'Accept' : 'application/dicom+json' }) + + # The expected result can be found by typing "dcm2json Database/Issue195.dcm" + self.assertEqual(5, len(b)) + self.assertEqual(2, len(b["00080018"])) + self.assertEqual("UI", b["00080018"]["vr"]) + self.assertEqual("1.2.276.0.7230010.3.1.4.8323329.13188.1620309604.848735", + b["00080018"]["Value"][0]) + + self.assertEqual(2, len(b["0020000D"])) + self.assertEqual("UI", b["0020000D"]["vr"]) + self.assertEqual("1.2.276.0.7230010.3.1.2.8323329.13188.1620309604.848733", + b["0020000D"]["Value"][0]) + + self.assertEqual(2, len(b["0020000E"])) + self.assertEqual("UI", b["0020000E"]["vr"]) + self.assertEqual("1.2.276.0.7230010.3.1.3.8323329.13188.1620309604.848734", + b["0020000E"]["Value"][0]) + + self.assertEqual(1, len(b["00081030"])) # Case of an empty value + self.assertEqual("LO", b["00081030"]["vr"]) + + self.assertEqual(2, len(b["0008103E"])) + self.assertEqual("LO", b["0008103E"]["vr"]) + self.assertEqual("Hello1", b["0008103E"]["Value"][0]) + + a = UploadInstance(_REMOTE, 'Issue195-bis.dcm')['ID'] + b = DoGet(_REMOTE, '/instances/%s/file' % a, + headers = { 'Accept' : 'application/dicom+json' }) + + # The expected result can be found by typing "dcm2json Database/Issue195-bis.dcm" + self.assertEqual(5, len(b)) + self.assertEqual(2, len(b["00080018"])) + self.assertEqual("UI", b["00080018"]["vr"]) + self.assertEqual("1.2.276.0.7230010.3.1.4.8323329.23653.1620311964.865420", + b["00080018"]["Value"][0]) + + self.assertEqual(2, len(b["0020000D"])) + self.assertEqual("UI", b["0020000D"]["vr"]) + self.assertEqual("1.2.276.0.7230010.3.1.2.8323329.23653.1620311964.865418", + b["0020000D"]["Value"][0]) + + self.assertEqual(2, len(b["0020000E"])) + self.assertEqual("UI", b["0020000E"]["vr"]) + self.assertEqual("1.2.276.0.7230010.3.1.3.8323329.23653.1620311964.865419", + b["0020000E"]["Value"][0]) + + self.assertEqual(2, len(b["0008103E"])) + self.assertEqual("UN", b["0008103E"]["vr"]) + + # NB: "QgA=" corresponds to the base64 encoding of (uint16_t) 0x42 in little endian: + # $ echo -n 'QgA=' | base64 -d | hexdump -C + self.assertEqual("QgA=", b["0008103E"]["InlineBinary"]) + + # Case of an empty value, fails in Orthanc <= 1.9.2 because of issue #195 + self.assertEqual(1, len(b["00081030"])) + self.assertEqual("UN", b["00081030"]["vr"])