changeset 522:fce9e90acdc2

replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 07 Apr 2023 22:18:53 +0200
parents 8114f67e0f7f
children 767840cb4d3f
files Tests/Tests.py
diffstat 1 files changed, 71 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/Tests/Tests.py	Fri Apr 07 15:04:59 2023 +0200
+++ b/Tests/Tests.py	Fri Apr 07 22:18:53 2023 +0200
@@ -9394,91 +9394,89 @@
             print("Your database backend doesn't support labels")
 
     def test_find_labels(self):
-        def Execute(withLabels, withoutLabels):
+        def Execute(labels, constraint):
             return DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance',
                                                     'Query' : { },
-                                                    'WithLabels' : withLabels,
-                                                    'WithoutLabels' : withoutLabels, })
+                                                    'Labels' : labels,
+                                                    'LabelsConstraint' : constraint, })
         
         if (IsOrthancVersionAbove(_REMOTE, 1, 12, 0) and
             DoGet(_REMOTE, '/system') ['HasLabels']):
             u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID']
 
-            self.assertEqual(1, len(Execute([], [])))
-            self.assertEqual(0, len(Execute([ 'a' ], [])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [])))
-            self.assertEqual(1, len(Execute([], [ 'c' ])))
-            self.assertEqual(1, len(Execute([], [ 'c', 'd' ])))
-            self.assertEqual(0, len(Execute([ 'a' ], [ 'c' ])))
-            self.assertEqual(0, len(Execute([ 'a' ], [ 'c', 'd' ])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c' ])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c', 'd' ])))
+            # The instance has no label
+            self.assertEqual(1, len(Execute([], 'All')))
+            self.assertEqual(1, len(Execute([], 'Any')))
+            self.assertEqual(1, len(Execute([], 'None')))
+            self.assertEqual(0, len(Execute([ 'a' ], 'All')))
+            self.assertEqual(0, len(Execute([ 'a' ], 'Any')))
+            self.assertEqual(1, len(Execute([ 'a' ], 'None')))
+            self.assertEqual(0, len(Execute([ 'b' ], 'All')))
+            self.assertEqual(0, len(Execute([ 'b' ], 'Any')))
+            self.assertEqual(1, len(Execute([ 'b' ], 'None')))
+            self.assertEqual(0, len(Execute([ 'a', 'b' ], 'All')))
+            self.assertEqual(0, len(Execute([ 'a', 'b' ], 'Any')))
+            self.assertEqual(1, len(Execute([ 'a', 'b' ], 'None')))
 
             DoPut(_REMOTE, '/instances/%s/labels/a' % u)
-            self.assertEqual(1, len(Execute([], [])))
-            self.assertEqual(1, len(Execute([ 'a' ], [])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [])))
-            self.assertEqual(1, len(Execute([], [ 'c' ])))
-            self.assertEqual(1, len(Execute([], [ 'c', 'd' ])))
-            self.assertEqual(1, len(Execute([ 'a' ], [ 'c' ])))
-            self.assertEqual(1, len(Execute([ 'a' ], [ 'c', 'd' ])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c' ])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c', 'd' ])))
+            # The instance has label "a"
+            self.assertEqual(1, len(Execute([], 'All')))
+            self.assertEqual(1, len(Execute([], 'Any')))
+            self.assertEqual(1, len(Execute([], 'None')))
+            self.assertEqual(1, len(Execute([ 'a' ], 'All')))
+            self.assertEqual(1, len(Execute([ 'a' ], 'Any')))
+            self.assertEqual(0, len(Execute([ 'a' ], 'None')))
+            self.assertEqual(0, len(Execute([ 'b' ], 'All')))
+            self.assertEqual(0, len(Execute([ 'b' ], 'Any')))
+            self.assertEqual(1, len(Execute([ 'b' ], 'None')))
+            self.assertEqual(0, len(Execute([ 'a', 'b' ], 'All')))
+            self.assertEqual(1, len(Execute([ 'a', 'b' ], 'Any')))
+            self.assertEqual(0, len(Execute([ 'a', 'b' ], 'None')))
 
             DoPut(_REMOTE, '/instances/%s/labels/b' % u)
-            self.assertEqual(1, len(Execute([], [])))
-            self.assertEqual(1, len(Execute([ 'a' ], [])))
-            self.assertEqual(1, len(Execute([ 'a', 'b' ], [])))
-            self.assertEqual(1, len(Execute([], [ 'c' ])))
-            self.assertEqual(1, len(Execute([], [ 'c', 'd' ])))
-            self.assertEqual(1, len(Execute([ 'a' ], [ 'c' ])))
-            self.assertEqual(1, len(Execute([ 'a' ], [ 'c', 'd' ])))
-            self.assertEqual(1, len(Execute([ 'a', 'b' ], [ 'c' ])))
-            self.assertEqual(1, len(Execute([ 'a', 'b' ], [ 'c', 'd' ])))
-
-            DoPut(_REMOTE, '/instances/%s/labels/d' % u)
-            self.assertEqual(1, len(Execute([], [])))
-            self.assertEqual(1, len(Execute([ 'a' ], [])))
-            self.assertEqual(1, len(Execute([ 'a', 'b' ], [])))
-            self.assertEqual(1, len(Execute([], [ 'c' ])))
-            self.assertEqual(0, len(Execute([], [ 'c', 'd' ])))
-            self.assertEqual(1, len(Execute([ 'a' ], [ 'c' ])))
-            self.assertEqual(0, len(Execute([ 'a' ], [ 'c', 'd' ])))
-            self.assertEqual(1, len(Execute([ 'a', 'b' ], [ 'c' ])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c', 'd' ])))
-
-            DoPut(_REMOTE, '/instances/%s/labels/c' % u)
-            self.assertEqual(1, len(Execute([], [])))
-            self.assertEqual(1, len(Execute([ 'a' ], [])))
-            self.assertEqual(1, len(Execute([ 'a', 'b' ], [])))
-            self.assertEqual(0, len(Execute([], [ 'c' ])))
-            self.assertEqual(0, len(Execute([], [ 'c', 'd' ])))
-            self.assertEqual(0, len(Execute([ 'a' ], [ 'c' ])))
-            self.assertEqual(0, len(Execute([ 'a' ], [ 'c', 'd' ])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c' ])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c', 'd' ])))
-            
-            DoDelete(_REMOTE, '/instances/%s/labels/b' % u)
-            self.assertEqual(1, len(Execute([], [])))
-            self.assertEqual(1, len(Execute([ 'a' ], [])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [])))
-            self.assertEqual(0, len(Execute([], [ 'c' ])))
-            self.assertEqual(0, len(Execute([], [ 'c', 'd' ])))
-            self.assertEqual(0, len(Execute([ 'a' ], [ 'c' ])))
-            self.assertEqual(0, len(Execute([ 'a' ], [ 'c', 'd' ])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c' ])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c', 'd' ])))
+            # The instance has labels "a" and "b"
+            self.assertEqual(1, len(Execute([], 'All')))
+            self.assertEqual(1, len(Execute([], 'Any')))
+            self.assertEqual(1, len(Execute([], 'None')))
+            self.assertEqual(1, len(Execute([ 'a' ], 'All')))
+            self.assertEqual(1, len(Execute([ 'a' ], 'Any')))
+            self.assertEqual(0, len(Execute([ 'a' ], 'None')))
+            self.assertEqual(1, len(Execute([ 'b' ], 'All')))
+            self.assertEqual(1, len(Execute([ 'b' ], 'Any')))
+            self.assertEqual(0, len(Execute([ 'b' ], 'None')))
+            self.assertEqual(1, len(Execute([ 'a', 'b' ], 'All')))
+            self.assertEqual(1, len(Execute([ 'a', 'b' ], 'Any')))
+            self.assertEqual(0, len(Execute([ 'a', 'b' ], 'None')))
             
             DoDelete(_REMOTE, '/instances/%s/labels/a' % u)
-            self.assertEqual(1, len(Execute([], [])))
-            self.assertEqual(0, len(Execute([ 'a' ], [])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [])))
-            self.assertEqual(0, len(Execute([], [ 'c' ])))
-            self.assertEqual(0, len(Execute([], [ 'c', 'd' ])))
-            self.assertEqual(0, len(Execute([ 'a' ], [ 'c' ])))
-            self.assertEqual(0, len(Execute([ 'a' ], [ 'c', 'd' ])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c' ])))
-            self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c', 'd' ])))
-
+            # The instance has label "b"
+            self.assertEqual(1, len(Execute([], 'All')))
+            self.assertEqual(1, len(Execute([], 'Any')))
+            self.assertEqual(1, len(Execute([], 'None')))
+            self.assertEqual(0, len(Execute([ 'a' ], 'All')))
+            self.assertEqual(0, len(Execute([ 'a' ], 'Any')))
+            self.assertEqual(1, len(Execute([ 'a' ], 'None')))
+            self.assertEqual(1, len(Execute([ 'b' ], 'All')))
+            self.assertEqual(1, len(Execute([ 'b' ], 'Any')))
+            self.assertEqual(0, len(Execute([ 'b' ], 'None')))
+            self.assertEqual(0, len(Execute([ 'a', 'b' ], 'All')))
+            self.assertEqual(1, len(Execute([ 'a', 'b' ], 'Any')))
+            self.assertEqual(0, len(Execute([ 'a', 'b' ], 'None')))
+
+            DoDelete(_REMOTE, '/instances/%s/labels/b' % u)
+            # The instance has no more label
+            self.assertEqual(1, len(Execute([], 'All')))
+            self.assertEqual(1, len(Execute([], 'Any')))
+            self.assertEqual(1, len(Execute([], 'None')))
+            self.assertEqual(0, len(Execute([ 'a' ], 'All')))
+            self.assertEqual(0, len(Execute([ 'a' ], 'Any')))
+            self.assertEqual(1, len(Execute([ 'a' ], 'None')))
+            self.assertEqual(0, len(Execute([ 'b' ], 'All')))
+            self.assertEqual(0, len(Execute([ 'b' ], 'Any')))
+            self.assertEqual(1, len(Execute([ 'b' ], 'None')))
+            self.assertEqual(0, len(Execute([ 'a', 'b' ], 'All')))
+            self.assertEqual(0, len(Execute([ 'a', 'b' ], 'Any')))
+            self.assertEqual(1, len(Execute([ 'a', 'b' ], 'None')))
+            
         else:
             print("Your database backend doesn't support labels")