From ed2565fc0c07b14ea374efff699c7b245b0dd762 Mon Sep 17 00:00:00 2001 From: anikaweinmann Date: Fri, 15 Nov 2024 10:42:17 +0100 Subject: [PATCH] fix job resumption tests --- tests/test_job_resumption.py | 49 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/tests/test_job_resumption.py b/tests/test_job_resumption.py index 43f18b43..8a346520 100644 --- a/tests/test_job_resumption.py +++ b/tests/test_job_resumption.py @@ -288,8 +288,8 @@ class JobResumptionProcessingTestCase(ActiniaResourceTestCaseBase): cfg_file = os.environ.get("DEFAULT_CONFIG_PATH", "/etc/default/actinia") tmp_cfg_file = "%s_tmp" % cfg_file + endpoint = "nc_spm_08/processing_async" save_interim_results_value = None - endpoint = "/projects/nc_spm_08/processing_async" resource_user_id = None resource_resource_id = None sleep_time = 15 @@ -333,7 +333,7 @@ def test_notsaved_interim_results_by_success(self): """ tpl = Template(json_dumps(process_chain_1)) rv = self.server.post( - URL_PREFIX + self.endpoint, + f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}", headers=self.admin_auth_header, data=tpl.render(map1="elevation@PERMANENT", map2="baum"), content_type="application/json", @@ -364,18 +364,19 @@ def test_saved_interim_results(self): """Test if the interim results are not saved correctly""" step = 4 tpl = Template(json_dumps(process_chain_1)) - rv = self.server.post( - URL_PREFIX + self.endpoint, + # self.server.get(f"{URL_PREFIX}/{self.project_url_part}/nc_spm_08/mapsets",headers=self.admin_auth_header,content_type="application/json") + rv1 = self.server.post( + f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}", headers=self.admin_auth_header, data=tpl.render(map1="elevation@PERMANENT", map2="baum555"), content_type="application/json", ) self.waitAsyncStatusAssertHTTP( - rv, headers=self.admin_auth_header, http_status=400, status="error" + rv1, headers=self.admin_auth_header, http_status=400, status="error" ) # check if interim results are saved - resp_data = json_loads(rv.data) + resp_data = json_loads(rv1.data) rv_user_id = resp_data["user_id"] rv_resource_id = resp_data["resource_id"] interim_dir = os.path.join( @@ -407,7 +408,7 @@ def test_job_resumption(self): """Test job resumption with processing_async endpoint""" tpl = Template(json_dumps(process_chain_1)) rv = self.server.post( - URL_PREFIX + self.endpoint, + f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}", headers=self.admin_auth_header, data=tpl.render(map1="elevation2@PERMANENT", map2="baum"), content_type="application/json", @@ -450,7 +451,7 @@ def test_job_2_times_resumption(self): """Test job 2 times resumption with processing_async endpoint""" tpl = Template(json_dumps(process_chain_1)) rv = self.server.post( - URL_PREFIX + self.endpoint, + f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}", headers=self.admin_auth_header, data=tpl.render(map1="elevation2@PERMANENT", map2="baum"), content_type="application/json", @@ -512,7 +513,7 @@ def test_job_resumption_error_by_running(self): """ tpl = Template(json_dumps(process_chain_2_error)) rv = self.server.post( - URL_PREFIX + self.endpoint, + f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}", headers=self.admin_auth_header, data=tpl.render(seconds=self.sleep_time), content_type="application/json", @@ -559,7 +560,7 @@ def test_job_resumption_importer(self): """Test job resumption with processing_async endpoint and importer""" tpl = Template(json_dumps(process_chain_3_importer)) rv = self.server.post( - URL_PREFIX + self.endpoint, + f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}", headers=self.admin_auth_header, data=tpl.render(map1="elevation2@PERMANENT", map2="baum"), content_type="application/json", @@ -604,7 +605,7 @@ def test_job_2_times_resumption_importer(self): """ tpl = Template(json_dumps(process_chain_3_importer)) rv = self.server.post( - URL_PREFIX + self.endpoint, + f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}", headers=self.admin_auth_header, data=tpl.render(map1="elevation2@PERMANENT", map2="baum"), content_type="application/json", @@ -729,7 +730,7 @@ def test_job_resumption_stdout(self): """Test job resumption with processing_async endpoint and stdout""" tpl = Template(json_dumps(process_chain_5_stdout)) rv = self.server.post( - URL_PREFIX + self.endpoint, + f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}", headers=self.admin_auth_header, data=tpl.render(map1="elevation2@PERMANENT", map2="baum"), content_type="application/json", @@ -775,7 +776,7 @@ def test_job_2_times_resumption_stdout(self): """ tpl = Template(json_dumps(process_chain_5_stdout)) rv = self.server.post( - URL_PREFIX + self.endpoint, + f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}", headers=self.admin_auth_header, data=tpl.render(map1="elevation2@PERMANENT", map2="baum"), content_type="application/json", @@ -916,7 +917,7 @@ def test_resource_endpoints(self): class JobResumptionProcessingExportTestCase(JobResumptionProcessingTestCase): - endpoint = "/projects/nc_spm_08/processing_async_export" + endpoint = "nc_spm_08/processing_async_export" resource_user_id = None resource_resource_id = None @@ -926,7 +927,7 @@ def test_job_resumption_exporter(self): """ tpl = Template(json_dumps(process_chain_4_exporter)) rv = self.server.post( - URL_PREFIX + self.endpoint, + f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}", headers=self.admin_auth_header, data=tpl.render(map1="elevation2@PERMANENT", map2="baum"), content_type="application/json", @@ -993,7 +994,7 @@ def test_job_2_times_resumption_exporter(self): """ tpl = Template(json_dumps(process_chain_4_exporter)) rv = self.server.post( - URL_PREFIX + self.endpoint, + f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}", headers=self.admin_auth_header, data=tpl.render(map1="elevation2@PERMANENT", map2="baum"), content_type="application/json", @@ -1077,7 +1078,7 @@ class JobResumptionPersistentProcessingTestCase( ): project = "nc_spm_08" mapset = "test_mapset" - endpoint = "/projects/%s/mapsets/%s/processing_async" % (project, mapset) + endpoint = f"{project}/mapsets/{mapset}/processing_async" resource_user_id = None resource_resource_id = None mapset_created = True @@ -1085,14 +1086,14 @@ class JobResumptionPersistentProcessingTestCase( def tearDown(self): if self.mapset_created is True: rv = self.server.delete( - URL_PREFIX - + "/projects/%s/mapsets/%s/lock" % (self.project, self.mapset), + f"{URL_PREFIX}/{self.project_url_part}/{self.project}/mapsets/" + f"{self.mapset}/lock", headers=self.admin_auth_header, ) self.waitAsyncStatusAssertHTTP(rv, headers=self.admin_auth_header) rv2 = self.server.delete( - URL_PREFIX - + "/projects/%s/mapsets/%s" % (self.project, self.mapset), + f"{URL_PREFIX}/{self.project_url_part}/{self.project}/mapsets/" + f"{self.mapset}", headers=self.admin_auth_header, ) self.waitAsyncStatusAssertHTTP(rv2, headers=self.admin_auth_header) @@ -1105,7 +1106,7 @@ def test_saved_interim_results(self): self.create_new_mapset(self.mapset, self.project) tpl = Template(json_dumps(process_chain_1)) rv = self.server.post( - URL_PREFIX + self.endpoint, + f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}", headers=self.admin_auth_header, data=tpl.render(map1="elevation@PERMANENT", map2="baum"), content_type="application/json", @@ -1148,7 +1149,7 @@ def test_resource_endpoints(self): class JobResumptionErrorTestCase(ActiniaResourceTestCaseBase): - endpoint = "/projects/nc_spm_08/processing_async" + endpoint = "nc_spm_08/processing_async" def test_job_resumption_config_error(self): """Test if the job resumption fails if save_interim_results is set to @@ -1156,7 +1157,7 @@ def test_job_resumption_config_error(self): """ tpl = Template(json_dumps(process_chain_1)) rv = self.server.post( - URL_PREFIX + self.endpoint, + f"{URL_PREFIX}/{self.project_url_part}/{self.endpoint}", headers=self.admin_auth_header, data=tpl.render(map1="elevation2@PERMANENT", map2="baum"), content_type="application/json",