changeset 544:47c43fdaf91d

fix
author Alain Mazy <am@osimis.io>
date Wed, 21 Jun 2023 13:04:19 +0200
parents 8722f7f95a38
children 9155a7f25798
files NewTests/MaxStorageReject/test_max_storage_reject.py
diffstat 1 files changed, 45 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/NewTests/MaxStorageReject/test_max_storage_reject.py	Tue Jun 20 17:24:56 2023 +0200
+++ b/NewTests/MaxStorageReject/test_max_storage_reject.py	Wed Jun 21 13:04:19 2023 +0200
@@ -60,16 +60,17 @@
 
     def test_upload_3_patients_rest_api(self):
         
-        self.o.delete_all_content()
+        if self.o.get_system()["ApiVersion"] > 20:  # from Orthanc 1.12.1
+            self.o.delete_all_content()
 
-        # make sure the 3rd patient does not make it into the storage (through the Rest API)
-        self.o.upload_file(here / "../../Database/Brainix/Flair/IM-0001-0001.dcm")
-        self.o.upload_file(here / "../../Database/Knix/Loc/IM-0001-0001.dcm")
-        with self.assertRaises(orthanc_exceptions.HttpError) as ctx:
-            self.o.upload_file(here / "../../Database/Phenix/IM-0001-0001.dcm")
-        self.assertEqual(507, ctx.exception.http_status_code)
-        self.assertEqual(2, len(self.o.studies.get_all_ids()))
-        self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject")))
+            # make sure the 3rd patient does not make it into the storage (through the Rest API)
+            self.o.upload_file(here / "../../Database/Brainix/Flair/IM-0001-0001.dcm")
+            self.o.upload_file(here / "../../Database/Knix/Loc/IM-0001-0001.dcm")
+            with self.assertRaises(orthanc_exceptions.HttpError) as ctx:
+                self.o.upload_file(here / "../../Database/Phenix/IM-0001-0001.dcm")
+            self.assertEqual(507, ctx.exception.http_status_code)
+            self.assertEqual(2, len(self.o.studies.get_all_ids()))
+            self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject")))
 
     def upload_with_store_scu(self, path):
         subprocess.check_call([Helpers.find_executable('storescu'),
@@ -80,44 +81,47 @@
 
     def test_upload_3_patients_c_store(self):
 
-        self.o.delete_all_content()
-        
-        # make sure the 3rd patient does not make it into the storage (through StoreSCU)
-        self.upload_with_store_scu(here / "../../Database/Brainix/Flair/IM-0001-0001.dcm")
-        self.upload_with_store_scu(here / "../../Database/Knix/Loc/IM-0001-0001.dcm")
-        with self.assertRaises(subprocess.CalledProcessError) as ctx:
-            self.upload_with_store_scu(here / "../../Database/Phenix/IM-0001-0001.dcm")
-        self.assertEqual(2, len(self.o.studies.get_all_ids()))
-        self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject")))
+        if self.o.get_system()["ApiVersion"] > 20:  # from Orthanc 1.12.1
+            self.o.delete_all_content()
+            
+            # make sure the 3rd patient does not make it into the storage (through StoreSCU)
+            self.upload_with_store_scu(here / "../../Database/Brainix/Flair/IM-0001-0001.dcm")
+            self.upload_with_store_scu(here / "../../Database/Knix/Loc/IM-0001-0001.dcm")
+            with self.assertRaises(subprocess.CalledProcessError) as ctx:
+                self.upload_with_store_scu(here / "../../Database/Phenix/IM-0001-0001.dcm")
+            self.assertEqual(2, len(self.o.studies.get_all_ids()))
+            self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject")))
 
     def test_upload_3_patients_dicomweb(self):
 
-        self.o.delete_all_content()
-        
-        # make sure the 3rd patient does not make it into the storage (through DicomWeb)
-        self.o.upload_files_dicom_web([here / "../../Database/Brainix/Flair/IM-0001-0001.dcm"])
-        self.o.upload_files_dicom_web([here / "../../Database/Knix/Loc/IM-0001-0001.dcm"])
+        if self.o.get_system()["ApiVersion"] > 20:  # from Orthanc 1.12.1
+            self.o.delete_all_content()
+            
+            # make sure the 3rd patient does not make it into the storage (through DicomWeb)
+            self.o.upload_files_dicom_web([here / "../../Database/Brainix/Flair/IM-0001-0001.dcm"])
+            self.o.upload_files_dicom_web([here / "../../Database/Knix/Loc/IM-0001-0001.dcm"])
 
-        with self.assertRaises(orthanc_exceptions.HttpError) as ctx:
-            self.o.upload_files_dicom_web([here / "../../Database/Phenix/IM-0001-0001.dcm"])
-        self.assertEqual(400, ctx.exception.http_status_code)
+            with self.assertRaises(orthanc_exceptions.HttpError) as ctx:
+                self.o.upload_files_dicom_web([here / "../../Database/Phenix/IM-0001-0001.dcm"])
+            self.assertEqual(400, ctx.exception.http_status_code)
 
-        self.assertEqual(2, len(self.o.studies.get_all_ids()))
-        self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject")))
+            self.assertEqual(2, len(self.o.studies.get_all_ids()))
+            self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject")))
 
     def test_upload_3_patients_dicomweb_in_one_query(self):
 
-        self.o.delete_all_content()
-        
-        # make sure the 3rd patient does not make it into the storage (through DicomWeb)
-        r = self.o.upload_files_dicom_web([
-            here / "../../Database/Brainix/Flair/IM-0001-0001.dcm",
-            here / "../../Database/Knix/Loc/IM-0001-0001.dcm",
-            here / "../../Database/Phenix/IM-0001-0001.dcm"
-            ])
+        if self.o.get_system()["ApiVersion"] > 20:  # from Orthanc 1.12.1
+            self.o.delete_all_content()
+            
+            # make sure the 3rd patient does not make it into the storage (through DicomWeb)
+            r = self.o.upload_files_dicom_web([
+                here / "../../Database/Brainix/Flair/IM-0001-0001.dcm",
+                here / "../../Database/Knix/Loc/IM-0001-0001.dcm",
+                here / "../../Database/Phenix/IM-0001-0001.dcm"
+                ])
 
-        # pprint.pprint(r)
-        self.assertEqual(2, len(self.o.studies.get_all_ids()))
-        self.assertIn('00081198', r)
-        self.assertEqual(0xA700, r['00081198']['Value'][0]['00081197']['Value'][0])  # one failed instance with out-of-resource status
-        self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject")))
+            # pprint.pprint(r)
+            self.assertEqual(2, len(self.o.studies.get_all_ids()))
+            self.assertIn('00081198', r)
+            self.assertEqual(0xA700, r['00081198']['Value'][0]['00081197']['Value'][0])  # one failed instance with out-of-resource status
+            self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject")))