changeset 949:1c40e067143e

do not execute test_deeply_nested_sequence if the dcmtk patch is not applied
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Aug 2026 16:51:20 +0200
parents 20cf187b4727
children ae065472bc8f
files Tests/Tests.py Tests/Toolbox.py
diffstat 2 files changed, 49 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/Tests/Tests.py	Wed Aug 12 15:29:25 2026 +0200
+++ b/Tests/Tests.py	Wed Aug 12 16:51:20 2026 +0200
@@ -12797,10 +12797,12 @@
             self.assertEqual(42, v[2])
 
     def test_deeply_nested_sequence(self):
-        if IsOrthancVersionAbove(_REMOTE, 1, 13, 0):
+        if (IsThirdPartyLibraryVersionAbove(_REMOTE, 'dcmtk', 3, 7, 1) or
+            IsPatchApplied(_REMOTE, 'dcmtk-3.7.0-max-nested-sequence.patch')):
+            # note: unable to test with storescu since it does not support deeply nested sequences and crashes
             self.assertRaises(Exception, lambda: UploadInstance(_REMOTE, '2026-05-06-Deeply-Nested-Sequence.dcm'))
-
-            # note: unable to test with storescu since it does not support deeply nested sequences and crashes
+        else:
+            self.skipTest('Skipping because the required resource is unavailable')
 
     
     # small functional test, mainly to detect memory leaks (https://github.com/orthanc-server/orthanc-builder/issues/36)
--- a/Tests/Toolbox.py	Wed Aug 12 15:29:25 2026 +0200
+++ b/Tests/Toolbox.py	Wed Aug 12 16:51:20 2026 +0200
@@ -347,20 +347,6 @@
 
     return name
 
-def IsOrthancVersionAbove(orthanc, major, minor, revision):
-    v = DoGet(orthanc, '/system')['Version']
-
-    if v.startswith('mainline'):
-        return True
-    else:
-        tmp = v.split('.')
-        a = int(tmp[0])
-        b = int(tmp[1])
-        c = int(tmp[2])
-        return (a > major or
-                (a == major and b > minor) or
-                (a == major and b == minor and c >= revision))
-
 
 def HasExtendedFind(orthanc):
     v = DoGet(orthanc, '/system')
@@ -588,3 +574,47 @@
                 raise Exception()
         
         return result
+
+
+def IsVersionAbove(version, major, minor, revision = None):
+    tmp = version.split('.')
+
+    if revision == None:
+        assert(len(tmp) == 2)
+        a = int(tmp[0])
+        b = int(tmp[1])
+        return (a > major or
+                (a == major and b > minor))
+    else:
+        assert(len(tmp) == 3)
+        a = int(tmp[0])
+        b = int(tmp[1])
+        c = int(tmp[2])
+        return (a > major or
+                (a == major and b > minor) or
+                (a == major and b == minor and c >= revision))
+
+
+def IsOrthancVersionAbove(orthanc, major, minor, revision):
+    v = DoGet(orthanc, '/system')['Version']
+
+    if v.startswith('mainline'):
+        return True
+    else:
+        return IsVersionAbove(v, major, minor, revision)
+
+
+def IsThirdPartyLibraryVersionAbove(orthanc, library, major, minor, revision):
+    try:
+        v = DoGet(orthanc, '/system') ['ThirdPartyVersions'][library]
+        return IsVersionAbove(v, major, minor, revision)
+    except:
+        return False
+
+
+def IsPatchApplied(orthanc, patch):
+    try:
+        patches = DoGet(orthanc, '/system') ['ThirdPartyPatches']
+        return patch in patches
+    except:
+        return False