comparison Tests/Tests.py @ 80:8466dbfcb22b

fix test against dcmtk 3.6.1
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Apr 2016 13:57:08 +0200
parents 962274ebd797
children 5920954287dd
comparison
equal deleted inserted replaced
79:962274ebd797 80:8466dbfcb22b
73 d = a[i] - b[i] 73 d = a[i] - b[i]
74 if abs(d) >= 0.51: # Add some tolerance for rounding errors 74 if abs(d) >= 0.51: # Add some tolerance for rounding errors
75 return False 75 return False
76 76
77 return True 77 return True
78
79
80 def CompareTags(a, b, tagsToIgnore):
81 for i in tagsToIgnore:
82 if i in a:
83 del a[i]
84 if i in b:
85 del b[i]
86
87 return a == b
78 88
79 89
80 def CallFindScu(args): 90 def CallFindScu(args):
81 p = subprocess.Popen([ FindExecutable('findscu'), 91 p = subprocess.Popen([ FindExecutable('findscu'),
82 '-P', '-aec', _REMOTE['DicomAet'], '-aet', _LOCAL['DicomAet'], 92 '-P', '-aec', _REMOTE['DicomAet'], '-aet', _LOCAL['DicomAet'],
2554 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID'] 2564 i = UploadInstance(_REMOTE, 'PrivateMDNTags.dcm')['ID']
2555 j = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID'] 2565 j = UploadInstance(_REMOTE, 'PrivateTags.dcm')['ID']
2556 2566
2557 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i) 2567 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % i)
2558 with open(GetDatabasePath('PrivateMDNTagsSimplify.json'), 'r') as f: 2568 with open(GetDatabasePath('PrivateMDNTagsSimplify.json'), 'r') as f:
2559 self.assertEqual(json.loads(f.read()), t) 2569 self.assertTrue(CompareTags(t, json.loads(f.read()), [
2570 'ACR_NEMA_2C_VariablePixelDataGroupLength',
2571 'GenericGroupLength'
2572 ]))
2560 2573
2561 t = DoGet(_REMOTE, '/instances/%s/tags' % i) 2574 t = DoGet(_REMOTE, '/instances/%s/tags' % i)
2562 with open(GetDatabasePath('PrivateMDNTagsFull.json'), 'r') as f: 2575 with open(GetDatabasePath('PrivateMDNTagsFull.json'), 'r') as f:
2563 self.assertEqual(json.loads(f.read()), t) 2576 self.assertTrue(CompareTags(t, json.loads(f.read()), [ '7fe0,0000' ]))
2564 2577
2565 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % j) 2578 t = DoGet(_REMOTE, '/instances/%s/tags?simplify' % j)
2566 with open(GetDatabasePath('PrivateTagsSimplify.json'), 'r') as f: 2579 with open(GetDatabasePath('PrivateTagsSimplify.json'), 'r') as f:
2567 a = json.loads(f.read()) 2580 self.assertTrue(CompareTags(t, json.loads(f.read()), [
2568 self.assertEqual(a, t) 2581 ]))
2569 2582
2570 t = DoGet(_REMOTE, '/instances/%s/tags' % j) 2583 t = DoGet(_REMOTE, '/instances/%s/tags' % j)
2571 with open(GetDatabasePath('PrivateTagsFull.json'), 'r') as f: 2584 with open(GetDatabasePath('PrivateTagsFull.json'), 'r') as f:
2572 a = json.loads(f.read()) 2585 a = json.loads(f.read())
2573
2574 aa = json.dumps(a).replace('2e+022', '2e+22') 2586 aa = json.dumps(a).replace('2e+022', '2e+22')
2575 tt = json.dumps(t).replace('2e+022', '2e+22') 2587 tt = json.dumps(t).replace('2e+022', '2e+22')
2576 self.assertEqual(aa, tt) 2588 self.assertEqual(aa, tt)
2577 2589
2578 2590