changeset 730:d2ac1c6588db

fix plugin version checks
author Alain Mazy <am@orthanc.team>
date Fri, 18 Oct 2024 18:03:05 +0200
parents 694b048afad9
children 33e8cb8511ca
files Plugins/DicomWeb/Run.py Plugins/WSI/Run.py Tests/Toolbox.py
diffstat 3 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/DicomWeb/Run.py	Fri Oct 18 14:26:20 2024 +0200
+++ b/Plugins/DicomWeb/Run.py	Fri Oct 18 18:03:05 2024 +0200
@@ -303,7 +303,7 @@
                                  { 'Resources' : [ 'nope' ],
                                    'Synchronous' : True }))  # inexisting resource
 
-        if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 18, 0):
+        if IsPluginVersionAtLeast(ORTHANC, "dicom-web", 1, 18, 0):
             l = 4   # "Server" has been added
         else:
             l = 3   # For >= 1.10.1
@@ -315,7 +315,7 @@
 
         self.assertEqual(l, len(r))
         self.assertEqual("0a9b3153-2512774b-2d9580de-1fc3dcf6-3bd83918", r['Resources']['Studies'][0])
-        if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 18, 0):
+        if IsPluginVersionAtLeast(ORTHANC, "dicom-web", 1, 18, 0):
             self.assertEqual("sample", r['Server'])
 
         # series
@@ -607,7 +607,7 @@
         self.assertEqual(u'王^小東', pn['Value'][0]['Ideographic'])
 
         # new derivated test added later
-        if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 18, 0):
+        if IsPluginVersionAtLeast(ORTHANC, "dicom-web", 1, 18, 0):
             a = DoGet(ORTHANC, '/dicom-web/studies?StudyInstanceUID=1.3.6.1.4.1.5962.1.2.0.1175775771.5711.0')
             self.assertEqual(1, len(a))
             pn = a[0]['00100010']  # Patient name
@@ -670,7 +670,7 @@
         # WADO-RS RetrieveFrames shall transcode ExplicitBigEndian to ExplicitLittleEndian
         # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=219
         
-        if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 17, 0):
+        if IsPluginVersionAtLeast(ORTHANC, "dicom-web", 1, 17, 0):
 
             UploadInstance(ORTHANC, 'TransferSyntaxes/1.2.840.10008.1.2.2.dcm')
 
@@ -698,7 +698,7 @@
         self.assertTrue('00280010' in a[0])
         self.assertEqual(512, a[0]['00280010']['Value'][0])
 
-        if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 17, 0):
+        if IsPluginVersionAtLeast(ORTHANC, "dicom-web", 1, 17, 0):
             a = DoGet(ORTHANC, '/dicom-web/studies/1.2.840.113619.2.176.2025.1499492.7391.1171285944.390/series/1.2.840.113619.2.176.2025.1499492.7391.1171285944.394/instances?includefield=00081140')
             self.assertEqual(1, len(a))
             self.assertTrue('00081140' in a[0])
@@ -1729,7 +1729,7 @@
         })
         self.assertIn("https://my-domain/dicom-web", m[0][u'7FE00010']['BulkDataURI'])
 
-        if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 13, 1):
+        if IsPluginVersionAtLeast(ORTHANC, "dicom-web", 1, 13, 1):
             m = DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % studyId, headers= {
                 'X-Forwarded-Host': 'my-domain',
                 'X-Forwarded-Proto': 'https'
@@ -1764,7 +1764,7 @@
         self.assertEqual(1, len(m))
         self.assertEqual(studyUid, m[0]['0020000D']['Value'][0])
 
-        if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 13, 1) and IsOrthancVersionAbove(ORTHANC, 1, 12, 1):
+        if IsPluginVersionAtLeast(ORTHANC, "dicom-web", 1, 13, 1) and IsOrthancVersionAbove(ORTHANC, 1, 12, 1):
             # This fails on DICOMweb <= 1.13 because of the "; q=.2",
             # since multiple accepts were not supported
             # https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=216
--- a/Plugins/WSI/Run.py	Fri Oct 18 14:26:20 2024 +0200
+++ b/Plugins/WSI/Run.py	Fri Oct 18 18:03:05 2024 +0200
@@ -461,7 +461,7 @@
 
         self.assertEqual(3, len(info['sizes']))
         
-        if IsPluginVersionAbove(ORTHANC, "wsi", 2, 1, 0):   # https://orthanc.uclouvain.be/hg/orthanc-wsi/rev/9dc7f1e8716d
+        if IsPluginVersionAtLeast(ORTHANC, "wsi", 2, 1, 0):   # https://orthanc.uclouvain.be/hg/orthanc-wsi/rev/9dc7f1e8716d
             self.assertEqual(512, info['sizes'][2]['width'])
             self.assertEqual(512, info['sizes'][2]['height'])
             self.assertEqual(256, info['sizes'][1]['width'])
--- a/Tests/Toolbox.py	Fri Oct 18 14:26:20 2024 +0200
+++ b/Tests/Toolbox.py	Fri Oct 18 18:03:05 2024 +0200
@@ -394,7 +394,7 @@
     return count
 
 
-def IsPluginVersionAbove(orthanc, plugin, major, minor, revision):
+def IsPluginVersionAtLeast(orthanc, plugin, major, minor, revision):
     v = DoGet(orthanc, '/plugins/%s' % plugin)['Version']
 
     if v.startswith('mainline'):
@@ -412,7 +412,7 @@
             a = int(tmp[0])
             b = int(tmp[1])
             return (a > major or
-                    (a == major and b > minor))
+                    (a == major and b >= minor))
         else:
             return False