comparison NewTests/MaxStorageReject/test_max_storage_reject.py @ 544:47c43fdaf91d

fix
author Alain Mazy <am@osimis.io>
date Wed, 21 Jun 2023 13:04:19 +0200
parents d9d059c6082d
children
comparison
equal deleted inserted replaced
543:8722f7f95a38 544:47c43fdaf91d
58 cls.o.wait_started() 58 cls.o.wait_started()
59 59
60 60
61 def test_upload_3_patients_rest_api(self): 61 def test_upload_3_patients_rest_api(self):
62 62
63 self.o.delete_all_content() 63 if self.o.get_system()["ApiVersion"] > 20: # from Orthanc 1.12.1
64 self.o.delete_all_content()
64 65
65 # make sure the 3rd patient does not make it into the storage (through the Rest API) 66 # make sure the 3rd patient does not make it into the storage (through the Rest API)
66 self.o.upload_file(here / "../../Database/Brainix/Flair/IM-0001-0001.dcm") 67 self.o.upload_file(here / "../../Database/Brainix/Flair/IM-0001-0001.dcm")
67 self.o.upload_file(here / "../../Database/Knix/Loc/IM-0001-0001.dcm") 68 self.o.upload_file(here / "../../Database/Knix/Loc/IM-0001-0001.dcm")
68 with self.assertRaises(orthanc_exceptions.HttpError) as ctx: 69 with self.assertRaises(orthanc_exceptions.HttpError) as ctx:
69 self.o.upload_file(here / "../../Database/Phenix/IM-0001-0001.dcm") 70 self.o.upload_file(here / "../../Database/Phenix/IM-0001-0001.dcm")
70 self.assertEqual(507, ctx.exception.http_status_code) 71 self.assertEqual(507, ctx.exception.http_status_code)
71 self.assertEqual(2, len(self.o.studies.get_all_ids())) 72 self.assertEqual(2, len(self.o.studies.get_all_ids()))
72 self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject"))) 73 self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject")))
73 74
74 def upload_with_store_scu(self, path): 75 def upload_with_store_scu(self, path):
75 subprocess.check_call([Helpers.find_executable('storescu'), 76 subprocess.check_call([Helpers.find_executable('storescu'),
76 "-xs", 77 "-xs",
77 Helpers.get_orthanc_ip(), 78 Helpers.get_orthanc_ip(),
78 str(Helpers.get_orthanc_dicom_port()), 79 str(Helpers.get_orthanc_dicom_port()),
79 path]) 80 path])
80 81
81 def test_upload_3_patients_c_store(self): 82 def test_upload_3_patients_c_store(self):
82 83
83 self.o.delete_all_content() 84 if self.o.get_system()["ApiVersion"] > 20: # from Orthanc 1.12.1
84 85 self.o.delete_all_content()
85 # make sure the 3rd patient does not make it into the storage (through StoreSCU) 86
86 self.upload_with_store_scu(here / "../../Database/Brainix/Flair/IM-0001-0001.dcm") 87 # make sure the 3rd patient does not make it into the storage (through StoreSCU)
87 self.upload_with_store_scu(here / "../../Database/Knix/Loc/IM-0001-0001.dcm") 88 self.upload_with_store_scu(here / "../../Database/Brainix/Flair/IM-0001-0001.dcm")
88 with self.assertRaises(subprocess.CalledProcessError) as ctx: 89 self.upload_with_store_scu(here / "../../Database/Knix/Loc/IM-0001-0001.dcm")
89 self.upload_with_store_scu(here / "../../Database/Phenix/IM-0001-0001.dcm") 90 with self.assertRaises(subprocess.CalledProcessError) as ctx:
90 self.assertEqual(2, len(self.o.studies.get_all_ids())) 91 self.upload_with_store_scu(here / "../../Database/Phenix/IM-0001-0001.dcm")
91 self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject"))) 92 self.assertEqual(2, len(self.o.studies.get_all_ids()))
93 self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject")))
92 94
93 def test_upload_3_patients_dicomweb(self): 95 def test_upload_3_patients_dicomweb(self):
94 96
95 self.o.delete_all_content() 97 if self.o.get_system()["ApiVersion"] > 20: # from Orthanc 1.12.1
96 98 self.o.delete_all_content()
97 # make sure the 3rd patient does not make it into the storage (through DicomWeb) 99
98 self.o.upload_files_dicom_web([here / "../../Database/Brainix/Flair/IM-0001-0001.dcm"]) 100 # make sure the 3rd patient does not make it into the storage (through DicomWeb)
99 self.o.upload_files_dicom_web([here / "../../Database/Knix/Loc/IM-0001-0001.dcm"]) 101 self.o.upload_files_dicom_web([here / "../../Database/Brainix/Flair/IM-0001-0001.dcm"])
102 self.o.upload_files_dicom_web([here / "../../Database/Knix/Loc/IM-0001-0001.dcm"])
100 103
101 with self.assertRaises(orthanc_exceptions.HttpError) as ctx: 104 with self.assertRaises(orthanc_exceptions.HttpError) as ctx:
102 self.o.upload_files_dicom_web([here / "../../Database/Phenix/IM-0001-0001.dcm"]) 105 self.o.upload_files_dicom_web([here / "../../Database/Phenix/IM-0001-0001.dcm"])
103 self.assertEqual(400, ctx.exception.http_status_code) 106 self.assertEqual(400, ctx.exception.http_status_code)
104 107
105 self.assertEqual(2, len(self.o.studies.get_all_ids())) 108 self.assertEqual(2, len(self.o.studies.get_all_ids()))
106 self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject"))) 109 self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject")))
107 110
108 def test_upload_3_patients_dicomweb_in_one_query(self): 111 def test_upload_3_patients_dicomweb_in_one_query(self):
109 112
110 self.o.delete_all_content() 113 if self.o.get_system()["ApiVersion"] > 20: # from Orthanc 1.12.1
111 114 self.o.delete_all_content()
112 # make sure the 3rd patient does not make it into the storage (through DicomWeb) 115
113 r = self.o.upload_files_dicom_web([ 116 # make sure the 3rd patient does not make it into the storage (through DicomWeb)
114 here / "../../Database/Brainix/Flair/IM-0001-0001.dcm", 117 r = self.o.upload_files_dicom_web([
115 here / "../../Database/Knix/Loc/IM-0001-0001.dcm", 118 here / "../../Database/Brainix/Flair/IM-0001-0001.dcm",
116 here / "../../Database/Phenix/IM-0001-0001.dcm" 119 here / "../../Database/Knix/Loc/IM-0001-0001.dcm",
117 ]) 120 here / "../../Database/Phenix/IM-0001-0001.dcm"
121 ])
118 122
119 # pprint.pprint(r) 123 # pprint.pprint(r)
120 self.assertEqual(2, len(self.o.studies.get_all_ids())) 124 self.assertEqual(2, len(self.o.studies.get_all_ids()))
121 self.assertIn('00081198', r) 125 self.assertIn('00081198', r)
122 self.assertEqual(0xA700, r['00081198']['Value'][0]['00081197']['Value'][0]) # one failed instance with out-of-resource status 126 self.assertEqual(0xA700, r['00081198']['Value'][0]['00081197']['Value'][0]) # one failed instance with out-of-resource status
123 self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject"))) 127 self.assertEqual(2, count_files_in_storage(self.get_storage_path("max_storage_reject")))