diff Tests/Tests.py @ 525:b60a0cc28c34

added test
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Apr 2023 20:53:05 +0200
parents 767840cb4d3f
children 3112c7f2326e
line wrap: on
line diff
--- a/Tests/Tests.py	Sat Apr 08 10:13:11 2023 +0200
+++ b/Tests/Tests.py	Tue Apr 11 20:53:05 2023 +0200
@@ -9410,9 +9410,9 @@
             print("Your database backend doesn't support labels")
 
     def test_find_labels(self):
-        def Execute(labels, constraint):
+        def Execute(labels, constraint, query = { }):
             return DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance',
-                                                    'Query' : { },
+                                                    'Query' : query,
                                                     'Labels' : labels,
                                                     'LabelsConstraint' : constraint, })
         
@@ -9449,6 +9449,48 @@
             self.assertEqual(1, len(Execute([ 'a', 'b' ], 'Any')))
             self.assertEqual(0, len(Execute([ 'a', 'b' ], 'None')))
 
+            self.assertEqual(0, len(Execute([ 'a' ], 'All', { 'PatientID' : 'nope' })))
+            self.assertEqual(1, len(Execute([ 'a' ], 'All', { 'PatientID' : '' })))
+            self.assertEqual(0, len(Execute([ 'a' ], 'All', { 'StudyInstanceUID' : 'nope' })))
+            self.assertEqual(1, len(Execute([ 'a' ], 'All', { 'StudyInstanceUID' : '' })))
+            self.assertEqual(0, len(Execute([ 'a' ], 'All', { 'SeriesInstanceUID' : 'nope' })))
+            self.assertEqual(1, len(Execute([ 'a' ], 'All', { 'SeriesInstanceUID' : '' })))
+            self.assertEqual(0, len(Execute([ 'a' ], 'All', { 'SOPInstanceUID' : 'nope' })))
+            self.assertEqual(1, len(Execute([ 'a' ], 'All', { 'SOPInstanceUID' : '' })))
+            
+            self.assertEqual(1, len(Execute([ 'a' ], 'All', { 'PatientID' : 'ozp00SjY2xG' })))
+            return
+        
+            self.assertEqual(1, len(Execute([ 'a' ], 'All', { 'StudyInstanceUID' : '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390' })))
+            self.assertEqual(1, len(Execute([ 'a' ], 'All', { 'SeriesInstanceUID' : '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394' })))
+            self.assertEqual(1, len(Execute([ 'a' ], 'All', { 'SOPInstanceUID' : '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' })))
+            self.assertEqual(1, len(Execute([ 'a' ], 'All', {
+                'PatientID' : 'ozp00SjY2xG',
+                'StudyInstanceUID' : '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390',
+                'SeriesInstanceUID' : '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394',
+                'SOPInstanceUID' : '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109',
+            })))
+
+            self.assertEqual(0, len(Execute([ 'b' ], 'All', { 'PatientID' : 'nope' })))
+            self.assertEqual(0, len(Execute([ 'b' ], 'All', { 'PatientID' : '' })))
+            self.assertEqual(0, len(Execute([ 'b' ], 'All', { 'StudyInstanceUID' : 'nope' })))
+            self.assertEqual(0, len(Execute([ 'b' ], 'All', { 'StudyInstanceUID' : '' })))
+            self.assertEqual(0, len(Execute([ 'b' ], 'All', { 'SeriesInstanceUID' : 'nope' })))
+            self.assertEqual(0, len(Execute([ 'b' ], 'All', { 'SeriesInstanceUID' : '' })))
+            self.assertEqual(0, len(Execute([ 'b' ], 'All', { 'SOPInstanceUID' : 'nope' })))
+            self.assertEqual(0, len(Execute([ 'b' ], 'All', { 'SOPInstanceUID' : '' })))
+            
+            self.assertEqual(0, len(Execute([ 'b' ], 'All', { 'PatientID' : 'ozp00SjY2xG' })))
+            self.assertEqual(0, len(Execute([ 'b' ], 'All', { 'StudyInstanceUID' : '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390' })))
+            self.assertEqual(0, len(Execute([ 'b' ], 'All', { 'SeriesInstanceUID' : '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394' })))
+            self.assertEqual(0, len(Execute([ 'b' ], 'All', { 'SOPInstanceUID' : '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109' })))
+            self.assertEqual(0, len(Execute([ 'b' ], 'All', {
+                'PatientID' : 'ozp00SjY2xG',
+                'StudyInstanceUID' : '1.2.840.113619.2.176.2025.1499492.7391.1171285944.390',
+                'SeriesInstanceUID' : '1.2.840.113619.2.176.2025.1499492.7391.1171285944.394',
+                'SOPInstanceUID' : '1.2.840.113619.2.176.2025.1499492.7040.1171286242.109',
+            })))
+
             DoPut(_REMOTE, '/instances/%s/labels/b' % u)
             # The instance has labels "a" and "b"
             self.assertEqual(1, len(Execute([], 'All')))