comparison Tests/Tests.py @ 557:1cdb14a679f2

fix anonymization tests
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 27 Jun 2023 17:56:04 +0200
parents 1028b75ac1ce
children 855c3720902a 3a5260cc6d55
comparison
equal deleted inserted replaced
556:1028b75ac1ce 557:1cdb14a679f2
7704 self.assertRaises(Exception, lambda: GetTags(study, { 'DicomVersion' : 'nope' })) 7704 self.assertRaises(Exception, lambda: GetTags(study, { 'DicomVersion' : 'nope' }))
7705 7705
7706 tags2008 = GetTags(study, { 'DicomVersion' : '2008' }) 7706 tags2008 = GetTags(study, { 'DicomVersion' : '2008' })
7707 tags2017c = GetTags(study, { 'DicomVersion' : '2017c' }) 7707 tags2017c = GetTags(study, { 'DicomVersion' : '2017c' })
7708 tags2021b = GetTags(study, { 'DicomVersion' : '2021b' }) 7708 tags2021b = GetTags(study, { 'DicomVersion' : '2021b' })
7709 tags2023b = GetTags(study, { 'DicomVersion' : '2023b' })
7709 tagsDefault = GetTags(study, {}) 7710 tagsDefault = GetTags(study, {})
7710 7711
7711 orthancVersion = DoGet(_REMOTE, '/system') ['Version'] 7712 orthancVersion = DoGet(_REMOTE, '/system') ['Version']
7712 self.assertEqual('Orthanc %s - PS 3.15-2008 Table E.1-1' % orthancVersion, tags2008['0012,0063']) 7713 self.assertEqual('Orthanc %s - PS 3.15-2008 Table E.1-1' % orthancVersion, tags2008['0012,0063'])
7713 self.assertEqual('Orthanc %s - PS 3.15-2017c Table E.1-1 Basic Profile' % orthancVersion, tags2017c['0012,0063']) 7714 self.assertEqual('Orthanc %s - PS 3.15-2017c Table E.1-1 Basic Profile' % orthancVersion, tags2017c['0012,0063'])
7714 self.assertEqual('Orthanc %s - PS 3.15-2021b Table E.1-1 Basic Profile' % orthancVersion, tags2021b['0012,0063']) 7715 self.assertEqual('Orthanc %s - PS 3.15-2021b Table E.1-1 Basic Profile' % orthancVersion, tags2021b['0012,0063'])
7715 self.assertEqual(tagsDefault['0012,0063'], tags2021b['0012,0063']) 7716 self.assertEqual('Orthanc %s - PS 3.15-2023b Table E.1-1 Basic Profile' % orthancVersion, tags2023b['0012,0063'])
7716 7717 self.assertEqual(tagsDefault['0012,0063'], tags2023b['0012,0063'])
7717 for t in [ tags2008, tags2017c, tags2021b, tagsDefault ]: 7718
7719 self.assertEqual(len(tags2021b), len(tags2023b))
7720 self.assertNotEqual(tags2021b, tags2023b)
7721
7722 for t in [ tags2008, tags2017c, tags2021b, tags2023b, tagsDefault ]:
7718 self.assertTrue(t['0010,0010'].startswith('Anonymized')) 7723 self.assertTrue(t['0010,0010'].startswith('Anonymized'))
7719 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', t['0008,0016']) 7724 self.assertEqual('1.2.840.10008.5.1.4.1.1.4', t['0008,0016'])
7720 self.assertEqual(36, len(t['0010,0020'])) # Length of a UUID 7725 self.assertEqual(36, len(t['0010,0020'])) # Length of a UUID
7721 self.assertEqual('YES', t['0012,0062']) 7726 self.assertEqual('YES', t['0012,0062'])
7722 7727
7723 for t in [ tags2008 ]: 7728 for t in [ tags2008 ]:
7724 self.assertEqual('20200101', t['0008,0020']) 7729 self.assertEqual('20200101', t['0008,0020'])
7725 7730
7726 for t in [ tags2017c, tags2021b, tagsDefault ]: 7731 for t in [ tags2017c, tags2021b, tags2023b, tagsDefault ]:
7727 self.assertEqual('', t['0008,0020']) # Study Date, anonymized between 2008 and 2017c 7732 self.assertEqual('', t['0008,0020']) # Study Date, anonymized between 2008 and 2017c
7728 7733
7729 for t in [ tags2008, tags2017c ]: 7734 for t in [ tags2008, tags2017c ]:
7730 self.assertEqual('HELLO^C', t['0050,0020']) 7735 self.assertEqual('HELLO^C', t['0050,0020'])
7731 self.assertEqual('HELLO^D', t['3006,0002']) 7736 self.assertEqual('HELLO^D', t['3006,0002'])
7732 7737
7733 for t in [ tags2021b, tagsDefault ]: 7738 for t in [ tags2021b, tags2023b, tagsDefault ]:
7734 self.assertFalse('0050,0020' in t) # Device Description, anonymized between 2017c and 2019c 7739 self.assertFalse('0050,0020' in t) # Device Description, anonymized between 2017c and 2019c
7735 self.assertEqual('', t['3006,0002']) # StructureSetLabel, anonymized between 2019c and 2021b 7740 self.assertEqual('', t['3006,0002']) # StructureSetLabel, anonymized between 2019c and 2021b
7736 7741
7737 7742
7738 def test_anonymize_relationships_6(self): 7743 def test_anonymize_relationships_6(self):
7846 'DimensionIndexSequence', # 0020,9222 7851 'DimensionIndexSequence', # 0020,9222
7847 'PerFrameFunctionalGroupsSequence[*].2005,140f[*].SOPInstanceUID', # 5200,9230 7852 'PerFrameFunctionalGroupsSequence[*].2005,140f[*].SOPInstanceUID', # 5200,9230
7848 '(5200,9230)[*].2005,140f[*].(0008,0023)', # Compatibility with Orthanc 1.9.4 7853 '(5200,9230)[*].2005,140f[*].(0008,0023)', # Compatibility with Orthanc 1.9.4
7849 '(5200,9230)[*].2005,140f[*].(0008,0033)', # Compatibility with Orthanc 1.9.4 7854 '(5200,9230)[*].2005,140f[*].(0008,0033)', # Compatibility with Orthanc 1.9.4
7850 ], 7855 ],
7856 'DicomVersion' : '2021b',
7851 'KeepPrivateTags' : True # Compatibility with Orthanc 1.9.4 7857 'KeepPrivateTags' : True # Compatibility with Orthanc 1.9.4
7852 }) 7858 })
7853 tags3 = GetTags(a['ID']) 7859 tags3 = GetTags(a['ID'])
7854 7860
7855 # UIDs 7861 # UIDs