def test_get_processes_invalid_schemas_handled(self): path = "/processes" # deploy valid test process process_name = self.fully_qualified_test_process_name() process_data = self.get_process_deploy_template(process_name) package_mock = mocked_process_package() with contextlib.ExitStack() as stack: for pkg in package_mock: stack.enter_context(pkg) resp = self.app.post_json(path, params=process_data, headers=self.json_headers, expect_errors=True) # TODO: status should be 201 when properly modified to match API conformance assert resp.status_code == 200 assert resp.json["processSummary"]["id"] == process_name # change value that will trigger schema error on check process = self.process_store.fetch_by_id(process_name) process["jobControlOptions"] = "random" # invalid process["visibility"] = VISIBILITY_PUBLIC self.process_store.save_process(process, overwrite=True) resp = self.app.get(path, headers=self.json_headers, expect_errors=True) assert resp.status_code == 503 assert resp.content_type == CONTENT_TYPE_APP_JSON assert process_name in resp.json.get("description")
def test_deploy_process_conflict(self): process_name = self.process_private.identifier process_data = self.get_process_deploy_template(process_name) package_mock = mocked_process_package() with contextlib.ExitStack() as stack: for pkg in package_mock: stack.enter_context(pkg) uri = "/processes" resp = self.app.post_json(uri, params=process_data, headers=self.json_headers, expect_errors=True) assert resp.status_code == 409 assert resp.content_type == CONTENT_TYPE_APP_JSON
def test_deploy_process_missing_or_invalid_components(self): process_name = self.fully_qualified_test_process_name() process_data = self.get_process_deploy_template(process_name) package_mock = mocked_process_package() # remove components for testing different cases process_data_tests = [deepcopy(process_data) for _ in range(12)] process_data_tests[0].pop("processDescription") process_data_tests[1]["processDescription"].pop("process") process_data_tests[2]["processDescription"]["process"].pop("id") process_data_tests[3]["processDescription"][ "jobControlOptions"] = EXECUTE_CONTROL_OPTION_ASYNC process_data_tests[4]["processDescription"]["jobControlOptions"] = [ EXECUTE_MODE_ASYNC ] process_data_tests[5].pop("deploymentProfileName") process_data_tests[6].pop("executionUnit") process_data_tests[7]["executionUnit"] = {} process_data_tests[8]["executionUnit"] = list() process_data_tests[9]["executionUnit"][0] = { "unit": "something" } # unit as string instead of package process_data_tests[10]["executionUnit"][0] = { "href": {} } # href as package instead of url process_data_tests[11]["executionUnit"][0] = { "unit": {}, "href": "" } # can"t have both unit/href together with contextlib.ExitStack() as stack: for pkg in package_mock: stack.enter_context(pkg) uri = "/processes" for i, data in enumerate(process_data_tests): resp = self.app.post_json(uri, params=data, headers=self.json_headers, expect_errors=True) msg = "Failed with test variation '{}' with value '{}'." assert resp.status_code in [400, 422 ], msg.format(i, resp.status_code) assert resp.content_type == CONTENT_TYPE_APP_JSON, msg.format( i, resp.content_type)
def test_deploy_process_success(self): process_name = self.fully_qualified_test_process_name() process_data = self.get_process_deploy_template(process_name) package_mock = mocked_process_package() with contextlib.ExitStack() as stack: for pkg in package_mock: stack.enter_context(pkg) uri = "/processes" resp = self.app.post_json(uri, params=process_data, headers=self.json_headers, expect_errors=True) # TODO: status should be 201 when properly modified to match API conformance assert resp.status_code == 200 assert resp.content_type == CONTENT_TYPE_APP_JSON assert resp.json["processSummary"]["id"] == process_name assert isinstance(resp.json["deploymentDone"], bool) and resp.json["deploymentDone"]
def test_deploy_process_default_endpoint_wps1(self): """Validates that the default (localhost) endpoint to execute WPS requests are saved during deployment.""" process_name = self.fully_qualified_test_process_name() process_data = self.get_process_deploy_template(process_name) package_mock = mocked_process_package() with contextlib.ExitStack() as stack: for pkg in package_mock: stack.enter_context(pkg) uri = "/processes" resp = self.app.post_json(uri, params=process_data, headers=self.json_headers, expect_errors=True) # TODO: status should be 201 when properly modified to match API conformance assert resp.status_code == 200 weaver_wps_path = get_wps_url(self.config.registry.settings) process_wps_endpoint = self.process_store.fetch_by_id( process_name).processEndpointWPS1 assert isinstance(process_wps_endpoint, str) and len(process_wps_endpoint) assert process_wps_endpoint == weaver_wps_path