comparison Tests/Tests.py @ 588:8aa101e126d0

migration to UCLouvain servers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 22 Nov 2023 07:28:23 +0100
parents f29d3ff889bf
children 47b87c87213b
comparison
equal deleted inserted replaced
587:f29d3ff889bf 588:8aa101e126d0
4057 4057
4058 self.assertIn('OK', result) 4058 self.assertIn('OK', result)
4059 4059
4060 4060
4061 def test_bitbucket_issue_44(self): 4061 def test_bitbucket_issue_44(self):
4062 # https://bugs.orthanc-server.com/show_bug.cgi?id=44 4062 # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=44
4063 UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm') 4063 UploadInstance(_REMOTE, 'Issue44/Monochrome1.dcm')
4064 UploadInstance(_REMOTE, 'Issue44/Monochrome2.dcm') 4064 UploadInstance(_REMOTE, 'Issue44/Monochrome2.dcm')
4065 4065
4066 # dcmcjpeg +ua +eb Monochrome1.dcm Monochrome1-Jpeg.dcm 4066 # dcmcjpeg +ua +eb Monochrome1.dcm Monochrome1-Jpeg.dcm
4067 UploadInstance(_REMOTE, 'Issue44/Monochrome1-Jpeg.dcm') 4067 UploadInstance(_REMOTE, 'Issue44/Monochrome1-Jpeg.dcm')
4097 # white (255), should be rendered as white (255) 4097 # white (255), should be rendered as white (255)
4098 self.assertEqual(255, im.getpixel((0,0))) 4098 self.assertEqual(255, im.getpixel((0,0)))
4099 4099
4100 4100
4101 def test_bitbucket_issue_42(self): 4101 def test_bitbucket_issue_42(self):
4102 # https://bugs.orthanc-server.com/show_bug.cgi?id=42 4102 # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=42
4103 # This test fails on DCMTK 3.6.0, but succeeds in DCMTK 3.6.1 snapshots and DCMTK 3.6.2 4103 # This test fails on DCMTK 3.6.0, but succeeds in DCMTK 3.6.1 snapshots and DCMTK 3.6.2
4104 UploadInstance(_REMOTE, 'Issue42.dcm')['ID'] 4104 UploadInstance(_REMOTE, 'Issue42.dcm')['ID']
4105 modified = DoPost(_REMOTE, 4105 modified = DoPost(_REMOTE,
4106 '/patients/da128605-e040d0c4-310615d2-3475da63-df2d1ef4/modify', 4106 '/patients/da128605-e040d0c4-310615d2-3475da63-df2d1ef4/modify',
4107 '{"Replace":{"PatientID":"Hello","PatientName":"Sample patient name"},"Force":true}', 4107 '{"Replace":{"PatientID":"Hello","PatientName":"Sample patient name"},"Force":true}',
4109 self.assertTrue('PatientID' in modified) 4109 self.assertTrue('PatientID' in modified)
4110 4110
4111 4111
4112 def test_rest_find_limit(self): 4112 def test_rest_find_limit(self):
4113 # Check the "Since" and "Limit" parameters in URI "/tools/find" 4113 # Check the "Since" and "Limit" parameters in URI "/tools/find"
4114 # Related to issue 53: https://bugs.orthanc-server.com/show_bug.cgi?id=53 4114 # Related to issue 53: https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=53
4115 4115
4116 # Upload 6 instances 4116 # Upload 6 instances
4117 brainix = [] 4117 brainix = []
4118 knee = [] 4118 knee = []
4119 for i in range(2): 4119 for i in range(2):
4178 self.assertEqual(0, len(set(b) ^ set(knee))) 4178 self.assertEqual(0, len(set(b) ^ set(knee)))
4179 4179
4180 4180
4181 def test_bitbucket_issue_46(self): 4181 def test_bitbucket_issue_46(self):
4182 # "PHI remaining after anonymization" 4182 # "PHI remaining after anonymization"
4183 # https://bugs.orthanc-server.com/show_bug.cgi?id=46 4183 # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=46
4184 4184
4185 def GetAnonymizedTags(study, version): 4185 def GetAnonymizedTags(study, version):
4186 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study, 4186 anonymized = DoPost(_REMOTE, '/studies/%s/anonymize' % study,
4187 { 'DicomVersion' : version }, 4187 { 'DicomVersion' : version },
4188 'application/json') ['ID'] 4188 'application/json') ['ID']
4267 4267
4268 def test_bitbucket_issue_56(self): 4268 def test_bitbucket_issue_56(self):
4269 # Case-insensitive matching over accents. This test assumes 4269 # Case-insensitive matching over accents. This test assumes
4270 # that the "CaseSensitivePN" configuration option of Orthanc 4270 # that the "CaseSensitivePN" configuration option of Orthanc
4271 # is set to "false" (default value). 4271 # is set to "false" (default value).
4272 # https://bugs.orthanc-server.com/show_bug.cgi?id=56 4272 # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=56
4273 4273
4274 def Check(name, expected, expectedSensitive): 4274 def Check(name, expected, expectedSensitive):
4275 a = CallFindScu([ '-k', '0008,0005=ISO_IR 192', # Use UTF-8 4275 a = CallFindScu([ '-k', '0008,0005=ISO_IR 192', # Use UTF-8
4276 '-k', '0008,0052=PATIENT', 4276 '-k', '0008,0052=PATIENT',
4277 '-k', 'PatientName=%s' % name ]) 4277 '-k', 'PatientName=%s' % name ])
4553 self.assertEqual(str(content1), str(content2)) 4553 self.assertEqual(str(content1), str(content2))
4554 4554
4555 4555
4556 def test_bitbucket_issue_94(self): 4556 def test_bitbucket_issue_94(self):
4557 # "a simple instance modification should not modify FrameOfReferenceUID + ..." 4557 # "a simple instance modification should not modify FrameOfReferenceUID + ..."
4558 # https://bugs.orthanc-server.com/show_bug.cgi?id=94 4558 # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=94
4559 i = UploadInstance(_REMOTE, 'Issue94.dcm')['ID'] 4559 i = UploadInstance(_REMOTE, 'Issue94.dcm')['ID']
4560 4560
4561 source = DoGet(_REMOTE, '/instances/%s/attachments/dicom/data' % i) 4561 source = DoGet(_REMOTE, '/instances/%s/attachments/dicom/data' % i)
4562 4562
4563 modified = DoPost(_REMOTE, '/instances/%s/modify' % i, 4563 modified = DoPost(_REMOTE, '/instances/%s/modify' % i,
5253 Compare('HierarchicalAnonymization/StructuredReports/IM0', 5253 Compare('HierarchicalAnonymization/StructuredReports/IM0',
5254 'HierarchicalAnonymization/StructuredReports/IM0.json') 5254 'HierarchicalAnonymization/StructuredReports/IM0.json')
5255 5255
5256 5256
5257 def test_issue_95_encodings(self): 5257 def test_issue_95_encodings(self):
5258 # https://bugs.orthanc-server.com/show_bug.cgi?id=95 5258 # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=95
5259 # Check out image: "../Database/Encodings/DavidClunie/charsettests.screenshot.png" 5259 # Check out image: "../Database/Encodings/DavidClunie/charsettests.screenshot.png"
5260 5260
5261 # Very useful tool: "file2" from package "file-kanji" 5261 # Very useful tool: "file2" from package "file-kanji"
5262 5262
5263 def GetPatientName(dicom): 5263 def GetPatientName(dicom):
5332 5332
5333 5333
5334 def test_bitbucket_issue_131(self): 5334 def test_bitbucket_issue_131(self):
5335 # "Orthanc PACS silently fails to C-MOVE due to duplicate 5335 # "Orthanc PACS silently fails to C-MOVE due to duplicate
5336 # StudyInstanceUID in it's database." 5336 # StudyInstanceUID in it's database."
5337 # https://bugs.orthanc-server.com/show_bug.cgi?id=131 5337 # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=131
5338 5338
5339 # Insert 2 instances, with the same StudyInstanceUID, but with 5339 # Insert 2 instances, with the same StudyInstanceUID, but with
5340 # different patient IDs. Orthanc will create 2 distincts 5340 # different patient IDs. Orthanc will create 2 distincts
5341 # patients, and the hierarchy of resources above the two 5341 # patients, and the hierarchy of resources above the two
5342 # instances will be fully disjoint. 5342 # instances will be fully disjoint.
5545 5545
5546 5546
5547 def test_bitbucket_issue_140(self): 5547 def test_bitbucket_issue_140(self):
5548 # "Modifying private tags with REST API changes VR from LO to 5548 # "Modifying private tags with REST API changes VR from LO to
5549 # UN." This test fails if DCMTK <= 3.6.1 (e.g. fails on Ubuntu 16.04). 5549 # UN." This test fails if DCMTK <= 3.6.1 (e.g. fails on Ubuntu 16.04).
5550 # https://bugs.orthanc-server.com/show_bug.cgi?id=140 5550 # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=140
5551 source = UploadInstance(_REMOTE, 'Issue140.dcm') ['ID'] 5551 source = UploadInstance(_REMOTE, 'Issue140.dcm') ['ID']
5552 series = DoGet(_REMOTE, '/instances/%s' % source) ['ParentSeries'] 5552 series = DoGet(_REMOTE, '/instances/%s' % source) ['ParentSeries']
5553 5553
5554 target = DoPost(_REMOTE, '/series/%s/modify' % series, { 5554 target = DoPost(_REMOTE, '/series/%s/modify' % series, {
5555 'Replace' : { 'RadioButton3' : 'aaabbbccc' }, 5555 'Replace' : { 'RadioButton3' : 'aaabbbccc' },
5626 'Normalize' : False 5626 'Normalize' : False
5627 })) 5627 }))
5628 5628
5629 5629
5630 def test_bitbucket_issue_141(self): 5630 def test_bitbucket_issue_141(self):
5631 # https://bugs.orthanc-server.com/show_bug.cgi?id=141 5631 # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=141
5632 a = UploadInstance(_REMOTE, 'Issue141.dcm') ['ID'] 5632 a = UploadInstance(_REMOTE, 'Issue141.dcm') ['ID']
5633 study = '494c8037-b237f263-d8f15075-c8cb2280-daf39bd1' 5633 study = '494c8037-b237f263-d8f15075-c8cb2280-daf39bd1'
5634 5634
5635 with open(GetDatabasePath('HelloWorld.pdf'), 'rb') as f: 5635 with open(GetDatabasePath('HelloWorld.pdf'), 'rb') as f:
5636 pdf = f.read() 5636 pdf = f.read()
5652 UploadInstance(_REMOTE, '2019-06-17-VedranZdesic.dcm') 5652 UploadInstance(_REMOTE, '2019-06-17-VedranZdesic.dcm')
5653 DoPost(_REMOTE, '/studies/0c4aca1d-c107a241-6659d6aa-594c674a-a468b94a/modify', {}) 5653 DoPost(_REMOTE, '/studies/0c4aca1d-c107a241-6659d6aa-594c674a-a468b94a/modify', {})
5654 5654
5655 5655
5656 def test_log_level(self): 5656 def test_log_level(self):
5657 # https://bugs.orthanc-server.com/show_bug.cgi?id=65 5657 # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=65
5658 original = DoGet(_REMOTE, '/tools/log-level') 5658 original = DoGet(_REMOTE, '/tools/log-level')
5659 5659
5660 DoPut(_REMOTE, '/tools/log-level', 'default') 5660 DoPut(_REMOTE, '/tools/log-level', 'default')
5661 self.assertEqual('default', DoGet(_REMOTE, '/tools/log-level')) 5661 self.assertEqual('default', DoGet(_REMOTE, '/tools/log-level'))
5662 DoGet(_REMOTE, '/system') 5662 DoGet(_REMOTE, '/system')
6022 self.assertEqual(24, im.size[1]) 6022 self.assertEqual(24, im.size[1])
6023 6023
6024 6024
6025 def test_bitbucket_issue_154(self): 6025 def test_bitbucket_issue_154(self):
6026 # "Matching against list of UID-s by C-MOVE" 6026 # "Matching against list of UID-s by C-MOVE"
6027 # https://bugs.orthanc-server.com/show_bug.cgi?id=154 6027 # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=154
6028 a = UploadInstance(_REMOTE, 'Issue154-d1.dcm') ['ID'] 6028 a = UploadInstance(_REMOTE, 'Issue154-d1.dcm') ['ID']
6029 b = UploadInstance(_REMOTE, 'Issue154-d2.dcm') ['ID'] 6029 b = UploadInstance(_REMOTE, 'Issue154-d2.dcm') ['ID']
6030 6030
6031 study = '1.2.826.0.1.3680043.8.498.35214236271657363033644818354280454731' 6031 study = '1.2.826.0.1.3680043.8.498.35214236271657363033644818354280454731'
6032 series1 = '1.2.826.0.1.3680043.8.498.12243321927795467590791662266352305113' 6032 series1 = '1.2.826.0.1.3680043.8.498.12243321927795467590791662266352305113'
7703 self.assertEqual('hello2', DoGet(_REMOTE, '/instances/%s/attachments/1024/data' % i)) 7703 self.assertEqual('hello2', DoGet(_REMOTE, '/instances/%s/attachments/1024/data' % i))
7704 7704
7705 7705
7706 def test_issue_195(self): 7706 def test_issue_195(self):
7707 # This fails on Orthanc <= 1.9.2 7707 # This fails on Orthanc <= 1.9.2
7708 # https://bugs.orthanc-server.com/show_bug.cgi?id=195 7708 # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=195
7709 a = UploadInstance(_REMOTE, 'Issue195.dcm')['ID'] 7709 a = UploadInstance(_REMOTE, 'Issue195.dcm')['ID']
7710 b = DoGet(_REMOTE, '/instances/%s/file' % a, 7710 b = DoGet(_REMOTE, '/instances/%s/file' % a,
7711 headers = { 'Accept' : 'application/dicom+json' }) 7711 headers = { 'Accept' : 'application/dicom+json' })
7712 7712
7713 # The expected result can be found by typing "dcm2json Database/Issue195.dcm" 7713 # The expected result can be found by typing "dcm2json Database/Issue195.dcm"
7788 self.assertEqual('0020,9056', tags['0020,9165']) 7788 self.assertEqual('0020,9056', tags['0020,9165'])
7789 7789
7790 7790
7791 def test_issue_146(self): 7791 def test_issue_146(self):
7792 # "Update Anonyization to 2019c" 7792 # "Update Anonyization to 2019c"
7793 # https://bugs.orthanc-server.com/show_bug.cgi?id=146 7793 # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=146
7794 7794
7795 def GetTags(study, params): 7795 def GetTags(study, params):
7796 a = DoPost(_REMOTE, '/studies/%s/anonymize' % study, params) ['ID'] 7796 a = DoPost(_REMOTE, '/studies/%s/anonymize' % study, params) ['ID']
7797 b = DoGet(_REMOTE, '/studies/%s/instances' % a) 7797 b = DoGet(_REMOTE, '/studies/%s/instances' % a)
7798 self.assertEqual(1, len(b)) 7798 self.assertEqual(1, len(b))
8786 self.assertFalse('0008,1110' in tags2['0008,0124'][0]) 8786 self.assertFalse('0008,1110' in tags2['0008,0124'][0])
8787 8787
8788 8788
8789 def test_issue_200(self): 8789 def test_issue_200(self):
8790 # https://groups.google.com/g/orthanc-users/c/9CTLsL-JqDw/m/2I0xgyYHBAAJ 8790 # https://groups.google.com/g/orthanc-users/c/9CTLsL-JqDw/m/2I0xgyYHBAAJ
8791 # https://bugs.orthanc-server.com/show_bug.cgi?id=200 8791 # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=200
8792 self.assertEqual(0, len(DoGet(_REMOTE, '/changes') ['Changes'])) 8792 self.assertEqual(0, len(DoGet(_REMOTE, '/changes') ['Changes']))
8793 self.assertEqual(0, len(DoGet(_REMOTE, '/changes?last') ['Changes'])) 8793 self.assertEqual(0, len(DoGet(_REMOTE, '/changes?last') ['Changes']))
8794 u = UploadInstance(_REMOTE, 'DummyCT.dcm') ['ID'] 8794 u = UploadInstance(_REMOTE, 'DummyCT.dcm') ['ID']
8795 8795
8796 for change in DoGet(_REMOTE, '/changes') ['Changes']: 8796 for change in DoGet(_REMOTE, '/changes') ['Changes']: