Mercurial > hg > orthanc-tests
changeset 693:4567c3947f8a
more requested tags tests
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Thu, 19 Sep 2024 11:20:17 +0200 |
parents | 377ad9690c7a |
children | 92ec38cc5926 |
files | Tests/Tests.py Tests/Toolbox.py |
diffstat | 2 files changed, 97 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Tests/Tests.py Thu Sep 19 09:57:32 2024 +0200 +++ b/Tests/Tests.py Thu Sep 19 11:20:17 2024 +0200 @@ -628,7 +628,7 @@ def test_changes_extended(self): - if IsOrthancVersionAbove(_REMOTE, 1, 12, 5) and DoGet(_REMOTE, '/system').get("Capabilities") and DoGet(_REMOTE, '/system').get("Capabilities").get("HasExtendedChanges"): + if IsOrthancVersionAbove(_REMOTE, 1, 12, 5) and HasExtendedChanges(_REMOTE): # Check emptiness c = DoGet(_REMOTE, '/changes') self.assertEqual(0, len(c['Changes'])) @@ -10540,7 +10540,7 @@ self.assertEqual('2800', resource['RequestedTags']['RepetitionTime']) self.assertEqual(3, len(resource['RequestedTags']['DerivationCodeSequence'][0])) self.assertEqual('121327', resource['RequestedTags']['DerivationCodeSequence'][0]['CodeValue']) - + requestedTags = 'PatientID;StudyDescription;SeriesDescription;SOPClassUID;RepetitionTime;DerivationCodeSequence' a = DoGet(_REMOTE, '/patients?expand') @@ -10631,6 +10631,62 @@ CheckInstanceContent(a) CheckRequestedTags(a) + # this is equivalent to calling /dicom-web/series?PatientID=* + # when there are no StudyInstanceUID specified, the DICOM-Web standard says we should retrieve all Series and Study tags + # which includes e.g. NumberOfStudyRelatedInstances (0020,1208) that is a computed tag at study level + c = GetStorageAccessesCount(_REMOTE) + a = DoPost(_REMOTE, '/tools/find', { + "Query": { "PatientID": "*"}, + "Level": "Series", + "Expand": True, + "RequestedTags": [ + "0008,0020", + "0008,0030", + "0008,0050", + "0008,0056", + "0008,0060", + "0008,0061", + "0008,0090", + "0008,0201", + "0008,103e", + "0010,0010", + "0010,0020", + "0010,0030", + "0010,0040", + "0020,000d", + "0020,000e", + "0020,0010", + "0020,0011", + "0020,1206", + "0020,1208", + "0020,1209", + "0040,0244", + "0040,0245", + "0040,0275" + ] + }) + # Up to now, no versions of Orthanc ever returned this value but we keep the test for later (let's wait for someone to comlain !) + self.assertNotIn("NumberOfStudyRelatedInstances", a[0]["RequestedTags"]) + if HasExtendedFind(_REMOTE): + self.assertEqual(c, GetStorageAccessesCount(_REMOTE)) # the disk shall not have been accessed + + c = GetStorageAccessesCount(_REMOTE) + a = DoPost(_REMOTE, '/tools/find', { + "Query": { "PatientID": "*"}, + "Level": "Study", + "Expand": True, + "RequestedTags": [ + "SOPClassesInStudy", + "NumberOfStudyRelatedInstances" + ] + }) + # Up to now, no versions of Orthanc ever returned this value but we keep the test for later (let's wait for someone to comlain !) + self.assertIn("SOPClassesInStudy", a[0]["RequestedTags"]) + self.assertIn("NumberOfStudyRelatedInstances", a[0]["RequestedTags"]) + if HasExtendedFind(_REMOTE): + self.assertEqual(c, GetStorageAccessesCount(_REMOTE)) # the disk shall not have been accessed + + def test_computed_tags(self): # curl 'http://alice:orthanctest@localhost:8042/patients/0946fcb6-cf12ab43-bad958c1-bf057ad5-0fc6f54c?requested-tags=0020,1200;0020,1202;0020,1204'
--- a/Tests/Toolbox.py Thu Sep 19 09:57:32 2024 +0200 +++ b/Tests/Toolbox.py Thu Sep 19 11:20:17 2024 +0200 @@ -355,6 +355,45 @@ (a == major and b > minor) or (a == major and b == minor and c >= revision)) + +def HasExtendedFind(orthanc): + v = DoGet(orthanc, '/system') + + if 'Capabilities' in v and 'HasExtendedFind' in v['Capabilities']: + return v['Capabilities']['HasExtendedFind'] + return False + + +def HasExtendedChanges(orthanc): + v = DoGet(orthanc, '/system') + + if 'Capabilities' in v and 'HasExtendedChanges' in v['Capabilities']: + return v['Capabilities']['HasExtendedChanges'] + return False + + +def GetStorageAccessesCount(orthanc): + mm = DoGetRaw(orthanc, "/tools/metrics-prometheus")[1] + + if (sys.version_info >= (3, 0)): + try: + mm = mm.decode() + except: + pass + + mm = [x.split(" ") for x in mm.split("\n")] + + count = 0 + for m in mm: + if m[0] == 'orthanc_storage_cache_hit_count': + count += int(m[1]) + if m[0] == 'orthanc_storage_cache_miss_count': + count += int(m[1]) + + # print("storage access count = %s" % count) + return count + + def IsPluginVersionAbove(orthanc, plugin, major, minor, revision): v = DoGet(orthanc, '/plugins/%s' % plugin)['Version']