Mercurial > hg > orthanc-tests
comparison Tests/Tests.py @ 722:6cdba3322ef0 find-refactoring tip
more find tests
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Mon, 14 Oct 2024 17:21:47 +0200 |
parents | 43fd1686f4a2 |
children |
comparison
equal
deleted
inserted
replaced
721:43fd1686f4a2 | 722:6cdba3322ef0 |
---|---|
11331 UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm') | 11331 UploadInstance(_REMOTE, 'Beaufix/IM-0001-0001.dcm') |
11332 UploadInstance(_REMOTE, 'Encodings/Lena-ascii.dcm') | 11332 UploadInstance(_REMOTE, 'Encodings/Lena-ascii.dcm') |
11333 | 11333 |
11334 self.assertEqual(14, len(DoGet(_REMOTE, '/series'))) | 11334 self.assertEqual(14, len(DoGet(_REMOTE, '/series'))) |
11335 | 11335 |
11336 | |
11336 knixInstancesNoLimit = DoPost(_REMOTE, '/tools/find', { | 11337 knixInstancesNoLimit = DoPost(_REMOTE, '/tools/find', { |
11337 'Level' : 'Instances', | 11338 'Level' : 'Instances', |
11338 'Query' : { | 11339 'Query' : { |
11339 'PatientName' : 'KNIX' | 11340 'PatientName' : 'KNIX' |
11340 }, | 11341 }, |
11341 'Expand': False | 11342 'Expand': False |
11342 }) | 11343 }) |
11343 | 11344 |
11344 # pprint.pprint(knixInstancesNoLimit) | 11345 # pprint.pprint(knixInstancesNoLimit) |
11345 self.assertEqual(20, len(knixInstancesNoLimit)) | 11346 if IsOrthancVersionAbove(_REMOTE, 1, 12, 5) and HasExtendedFind(_REMOTE): # TODO: remove HasExtendedFind once find-refactoring branch has been merged |
11347 self.assertEqual(20, len(knixInstancesNoLimit)) | |
11348 else: | |
11349 self.assertEqual(21, len(knixInstancesNoLimit)) | |
11346 | 11350 |
11347 knixInstancesSince5Limit20 = DoPost(_REMOTE, '/tools/find', { | 11351 knixInstancesSince5Limit20 = DoPost(_REMOTE, '/tools/find', { |
11348 'Level' : 'Instances', | 11352 'Level' : 'Instances', |
11349 'Query' : { | 11353 'Query' : { |
11350 'PatientName' : 'KNIX' | 11354 'PatientName' : 'KNIX' |
11374 'Since': 0, | 11378 'Since': 0, |
11375 'Limit': 23 | 11379 'Limit': 23 |
11376 }) | 11380 }) |
11377 if IsOrthancVersionAbove(_REMOTE, 1, 12, 5) and HasExtendedFind(_REMOTE): # TODO: remove HasExtendedFind once find-refactoring branch has been merged | 11381 if IsOrthancVersionAbove(_REMOTE, 1, 12, 5) and HasExtendedFind(_REMOTE): # TODO: remove HasExtendedFind once find-refactoring branch has been merged |
11378 self.assertEqual(20, len(knixInstancesSince0Limit23)) | 11382 self.assertEqual(20, len(knixInstancesSince0Limit23)) |
11383 else: | |
11384 self.assertEqual(21, len(knixInstancesSince0Limit23)) | |
11379 | 11385 |
11380 seriesNoLimit = DoPost(_REMOTE, '/tools/find', { | 11386 seriesNoLimit = DoPost(_REMOTE, '/tools/find', { |
11381 'Level' : 'Series', | 11387 'Level' : 'Series', |
11382 'Query' : { | 11388 'Query' : { |
11383 'PatientName' : '*' | 11389 'PatientName' : '*' |
11384 }, | 11390 }, |
11385 'Expand': False | 11391 'Expand': False |
11386 }) | 11392 }) |
11387 | 11393 |
11388 # pprint.pprint(seriesNoLimit) | 11394 # pprint.pprint(seriesNoLimit) |
11389 self.assertEqual(10, len(seriesNoLimit)) | 11395 if IsOrthancVersionAbove(_REMOTE, 1, 12, 5) and HasExtendedFind(_REMOTE): # TODO: remove HasExtendedFind once find-refactoring branch has been merged |
11396 self.assertEqual(10, len(seriesNoLimit)) | |
11397 else: | |
11398 self.assertEqual(11, len(seriesNoLimit)) | |
11390 | 11399 |
11391 seriesSince8Limit6 = DoPost(_REMOTE, '/tools/find', { | 11400 seriesSince8Limit6 = DoPost(_REMOTE, '/tools/find', { |
11392 'Level' : 'Series', | 11401 'Level' : 'Series', |
11393 'Query' : { | 11402 'Query' : { |
11394 'PatientName' : '*' | 11403 'PatientName' : '*' |
11406 for i in range(0, 7): | 11415 for i in range(0, 7): |
11407 self.assertNotIn(seriesNoLimit[i], seriesSince8Limit6) | 11416 self.assertNotIn(seriesNoLimit[i], seriesSince8Limit6) |
11408 # the last 3 from last call shall not be in the first answer | 11417 # the last 3 from last call shall not be in the first answer |
11409 for i in range(3, 5): | 11418 for i in range(3, 5): |
11410 self.assertNotIn(seriesSince8Limit6[i], seriesNoLimit) | 11419 self.assertNotIn(seriesSince8Limit6[i], seriesNoLimit) |
11420 | |
11421 # query by a tag that is not in the DB (there are 27 instances from Knix/Loc + 10 instances from other series that satisfies this criteria) | |
11422 a = DoPost(_REMOTE, '/tools/find', { | |
11423 'Level' : 'Instances', | |
11424 'Query' : { | |
11425 'PhotometricInterpretation' : 'MONOCHROME*' | |
11426 }, | |
11427 'Expand': True, | |
11428 'OrderBy' : [ | |
11429 { | |
11430 'Type': 'DicomTag', | |
11431 'Key': 'InstanceNumber', | |
11432 'Direction': 'ASC' | |
11433 } | |
11434 ]}) | |
11435 | |
11436 if IsOrthancVersionAbove(_REMOTE, 1, 12, 5) and HasExtendedFind(_REMOTE): # TODO: remove HasExtendedFind once find-refactoring branch has been merged | |
11437 # pprint.pprint(a) | |
11438 # print(len(a)) | |
11439 # TODO: we should have something in the response that notifies us that the response is not "complete" | |
11440 # TODO: we should receive an error if we try to use "since" in this kind of search ? | |
11441 self.assertEqual(17, len(a)) # the fast DB filtering returns 20 instances -> only 17 meet the criteria | |
11442 else: | |
11443 self.assertEqual(21, len(a)) # previous Orthanc version returns 21 instances because they are not ordered and, by chance, Orthanc picks 21 instances that are matching the criteria |