comparison Plugins/DicomWeb/Run.py @ 399:dd519677974d

integration tests for issue #195
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 May 2021 16:53:08 +0200
parents 9528e2a03d3c
children 2c142e070f19
comparison
equal deleted inserted replaced
398:9528e2a03d3c 399:dd519677974d
1435 # Tolerance of just 1 pixel of difference (needed on Windows) 1435 # Tolerance of just 1 pixel of difference (needed on Windows)
1436 #print(im2.getpixel((238,275))) # => 255 1436 #print(im2.getpixel((238,275))) # => 255
1437 #print(truth.getpixel((238,275))) # => 254 1437 #print(truth.getpixel((238,275))) # => 254
1438 self.assertLessEqual(abs(bbox[2] - bbox[0]), 1) 1438 self.assertLessEqual(abs(bbox[2] - bbox[0]), 1)
1439 self.assertLessEqual(abs(bbox[3] - bbox[1]), 1) 1439 self.assertLessEqual(abs(bbox[3] - bbox[1]), 1)
1440
1441
1442 def test_issue_195(self):
1443 # This fails on Orthanc <= 1.9.2
1444 # https://bugs.orthanc-server.com/show_bug.cgi?id=195
1445 a = UploadInstance(ORTHANC, 'Issue195.dcm') ['ID']
1446 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',
1447 headers = { 'Accept' : 'application/dicom+json' })
1448
1449 self.assertEqual(1, len(b))
1450 self.assertEqual(5, len(b[0]))
1451
1452 # The expected result can be found by typing "dcm2json Database/Issue195.dcm"
1453 self.assertEqual(2, len(b[0]["00080018"]))
1454 self.assertEqual("UI", b[0]["00080018"]["vr"])
1455 self.assertEqual("1.2.276.0.7230010.3.1.4.8323329.13188.1620309604.848735",
1456 b[0]["00080018"]["Value"][0])
1457
1458 self.assertEqual(2, len(b[0]["0020000D"]))
1459 self.assertEqual("UI", b[0]["0020000D"]["vr"])
1460 self.assertEqual("1.2.276.0.7230010.3.1.2.8323329.13188.1620309604.848733",
1461 b[0]["0020000D"]["Value"][0])
1462
1463 self.assertEqual(2, len(b[0]["0020000E"]))
1464 self.assertEqual("UI", b[0]["0020000E"]["vr"])
1465 self.assertEqual("1.2.276.0.7230010.3.1.3.8323329.13188.1620309604.848734",
1466 b[0]["0020000E"]["Value"][0])
1467
1468 self.assertEqual(1, len(b[0]["00081030"])) # Case of an empty value
1469 self.assertEqual("LO", b[0]["00081030"]["vr"])
1470
1471 self.assertEqual(2, len(b[0]["0008103E"]))
1472 self.assertEqual("LO", b[0]["0008103E"]["vr"])
1473 self.assertEqual("Hello1", b[0]["0008103E"]["Value"][0])
1474
1475
1476 DoDelete(ORTHANC, 'instances/%s' % a)
1477 a = UploadInstance(ORTHANC, 'Issue195-bis.dcm') ['ID']
1478 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'
1479 b = DoGet(ORTHANC, '%s/metadata' % URI,
1480 headers = { 'Accept' : 'application/dicom+json' })
1481
1482 self.assertEqual(1, len(b))
1483 self.assertEqual(5, len(b[0]))
1484
1485 # The expected result can be found by typing "dcm2json Database/Issue195-bis.dcm"
1486 self.assertEqual(2, len(b[0]["00080018"]))
1487 self.assertEqual("UI", b[0]["00080018"]["vr"])
1488 self.assertEqual("1.2.276.0.7230010.3.1.4.8323329.23653.1620311964.865420",
1489 b[0]["00080018"]["Value"][0])
1490
1491 self.assertEqual(2, len(b[0]["0020000D"]))
1492 self.assertEqual("UI", b[0]["0020000D"]["vr"])
1493 self.assertEqual("1.2.276.0.7230010.3.1.2.8323329.23653.1620311964.865418",
1494 b[0]["0020000D"]["Value"][0])
1495
1496 self.assertEqual(2, len(b[0]["0020000E"]))
1497 self.assertEqual("UI", b[0]["0020000E"]["vr"])
1498 self.assertEqual("1.2.276.0.7230010.3.1.3.8323329.23653.1620311964.865419",
1499 b[0]["0020000E"]["Value"][0])
1500
1501 self.assertEqual(2, len(b[0]["0008103E"]))
1502 self.assertEqual("UN", b[0]["0008103E"]["vr"])
1503 self.assertEqual('http://%s:%s%s' % (args.server, args.rest, '/%s/bulk/0008103e' % URI),
1504 b[0]["0008103E"]["BulkDataURI"])
1505
1506 c = DoGet(ORTHANC, '%s/bulk/0008103e' % URI)
1507 self.assertTrue('Content-Length: 2\r\n' in c)
1508 index = c.find('\r\n\r\n')
1509 self.assertEqual(0x42, ord(c[index + 4]))
1510 self.assertEqual(0x00, ord(c[index + 5]))
1511
1512 # Case of an empty value, fails in Orthanc <= 1.9.2 because of issue #195
1513 self.assertEqual(1, len(b[0]["00081030"]))
1514 self.assertEqual("UN", b[0]["00081030"]["vr"])
1440 1515
1441 1516
1442 try: 1517 try:
1443 print('\nStarting the tests...') 1518 print('\nStarting the tests...')
1444 unittest.main(argv = [ sys.argv[0] ] + args.options) 1519 unittest.main(argv = [ sys.argv[0] ] + args.options)