comparison Plugins/DicomWeb/Run.py @ 222:0f03ee6ffa80

DICOMweb: test_wado_hierarchy, test_wado_bulk, test_bitbucket_issue_112
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 26 Feb 2019 17:34:32 +0100
parents af8e034f4262
children f5aca0917d60
comparison
equal deleted inserted replaced
221:7daf6a227745 222:0f03ee6ffa80
341 UploadInstance(ORTHANC, 'ColorTestMalaterre.dcm') 341 UploadInstance(ORTHANC, 'ColorTestMalaterre.dcm')
342 342
343 a = DoGet(ORTHANC, '/dicom-web/studies', 343 a = DoGet(ORTHANC, '/dicom-web/studies',
344 headers = { 'accept' : 'application/json' }) 344 headers = { 'accept' : 'application/json' })
345 345
346 pprint.pprint(a)
347
348 self.assertEqual(1, len(a)) 346 self.assertEqual(1, len(a))
349 self.assertTrue('00080050' in a[0]) # AccessionNumber is null 347 self.assertTrue('00080050' in a[0]) # AccessionNumber is null
350 self.assertEqual(1, len(a[0]['00080050'])) # 'vr' is the only field to be present 348 self.assertEqual(1, len(a[0]['00080050'])) # 'vr' is the only field to be present
351 self.assertEqual('SH', a[0]['00080050']['vr']) 349 self.assertEqual('SH', a[0]['00080050']['vr'])
352 350
351
352 def test_wado_hierarchy(self):
353 def CheckJson(uri, headers = {}):
354 with open(GetDatabasePath('DummyCT.json'), 'r') as f:
355 expected = json.loads(f.read())
356 actual = DoGet(ORTHANC, uri, headers)
357 self.assertEqual(1, len(actual))
358 AssertAlmostEqualRecursive(self, expected, actual[0])
359
360 UploadInstance(ORTHANC, 'DummyCT.dcm')
361 study = '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390'
362 series = '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394'
363 instance = '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109'
364
365 URI = '/dicom-web/studies/%s/series/%s/instances/%s/metadata'
366 self.assertRaises(Exception, lambda: DoGet(ORTHANC, URI % (study, series, instance),
367 headers = { 'accept' : 'application/nope' }))
368
369 CheckJson(URI % (study, series, instance), headers = { 'accept' : 'application/dicom+json' })
370 CheckJson('/dicom-web/studies/%s/series/%s/metadata' % (study, series))
371 CheckJson('/dicom-web/studies/%s/metadata' % study)
372
373 self.assertRaises(Exception, lambda: DoGet(ORTHANC, URI % ('nope', series, instance)))
374 self.assertRaises(Exception, lambda: DoGet(ORTHANC, URI % (study, 'nope', instance)))
375 self.assertRaises(Exception, lambda: DoGet(ORTHANC, URI % (study, series, 'nope')))
376 self.assertRaises(Exception, lambda: DoGet(ORTHANC, '/dicom-web/studies/%s/series/%s/metadata' % ('nope', series)))
377 self.assertRaises(Exception, lambda: DoGet(ORTHANC, '/dicom-web/studies/%s/series/%s/metadata' % (study, 'nope')))
378 self.assertRaises(Exception, lambda: DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % 'nope'))
379
380
381 def test_wado_bulk(self):
382 def CheckBulk(value, bulk):
383 self.assertEqual(2, len(value))
384 self.assertTrue('BulkDataURI' in value)
385 self.assertTrue('vr' in value)
386 self.assertEqual(value['BulkDataURI'], bulk)
387
388 orthanc = UploadInstance(ORTHANC, 'PrivateTags.dcm') ['ID']
389 study = '1.2.840.113619.2.115.147416.1094281639.0.29'
390 series = '1.2.840.113619.2.115.147416.1094281639.0.30'
391 sop = '1.2.840.113619.2.115.147416.1094281639.0.38'
392
393 a = DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study)
394 self.assertEqual(1, len(a))
395
396 BASE_URI = '/dicom-web/studies/%s/series/%s/instances/%s/bulk' % (study, series, sop)
397 BASE_URL = 'http://localhost:8042%s' % BASE_URI
398
399 self.assertEqual(2, len(a[0]['60031010']['Value']))
400 CheckBulk(a[0]['60031010']['Value'][0]['60031011'], '%s/60031010/1/60031011' % BASE_URL)
401 CheckBulk(a[0]['60031010']['Value'][1]['60031011'], '%s/60031010/2/60031011' % BASE_URL)
402 CheckBulk(a[0]['7FE00010'], '%s/7fe00010' % BASE_URL)
403
404 b = DoGetRaw(ORTHANC, '/instances/%s/content/6003-1010/0/6003-1011' % orthanc) [1]
405 c = DoGetMultipart(ORTHANC, '%s/60031010/1/60031011' % BASE_URI)
406
407 self.assertEqual(12288, len(b))
408 self.assertEqual(1, len(c))
409 self.assertEqual(b, c[0])
410
411
412 def test_bitbucket_issue_112(self):
413 # QIDO-RS: wrong serialization of number values
414 # https://bitbucket.org/sjodogne/orthanc/issues/112
415 # https://bitbucket.org/sjodogne/orthanc-dicomweb/issues/4/
416
417 UploadInstance(ORTHANC, 'DummyCT.dcm')
418 study = '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390'
419
420 # This is the WADO-RS testing
421 a = DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % study)
422 self.assertEqual(1, len(a))
423 self.assertEqual('IS', a[0]['00180091']['vr']) # EchoTrainLength
424
425 b = a[0]['00180091']['Value'][0]
426 self.assertTrue(isinstance(b, (int, long)))
427 self.assertEqual(10, b)
428
429 # This is the QIDO-RS testing
430 a = DoGet(ORTHANC, '/dicom-web/studies')
431 self.assertEqual(1, len(a))
432 self.assertEqual('IS', a[0]['00201208']['vr']) # Number of Study Related Instances
433
434 b = a[0]['00201208']['Value'][0]
435 self.assertTrue(isinstance(b, (int, long)))
436 self.assertEqual(1, b)
437
438
439
353 try: 440 try:
354 print('\nStarting the tests...') 441 print('\nStarting the tests...')
355 unittest.main(argv = [ sys.argv[0] ] + args.options) 442 unittest.main(argv = [ sys.argv[0] ] + args.options)
356 443
357 finally: 444 finally: