diff --git a/src/layman/rest_publication_test.py b/src/layman/rest_publication_test.py index 01d94cefe..3790df195 100644 --- a/src/layman/rest_publication_test.py +++ b/src/layman/rest_publication_test.py @@ -1,8 +1,7 @@ -from test import process_client, util -from functools import partial +from test import process_client import pytest -from layman import LaymanError, settings, common, app +from layman import LaymanError, settings, common from layman.common.micka import util as micka_util db_schema = settings.LAYMAN_PRIME_SCHEMA @@ -126,13 +125,7 @@ def test_get_publication_layman_status(publ_type, error_params): assert 'publication_status' in info['layman_metadata'], f'info={info}' assert info['layman_metadata']['publication_status'] == 'UPDATING', f'info={info}' - publication_type_def = process_client.PUBLICATION_TYPES_DEF[publ_type] - with app.app_context(): - url = util.url_for(publication_type_def.get_workspace_publication_url, - workspace=workspace, - **{publication_type_def.url_param_name: publication}) - check_response_fn = partial(process_client.check_response_keys, publication_type_def.keys_to_check) - process_client.wait_for_rest(url, 30, 0.5, check_response_fn) + process_client.wait_for_publication_status(workspace, publ_type, publication) info = process_client.get_workspace_publication(publ_type, workspace, publication, ) assert 'layman_metadata' in info, f'info={info}' @@ -140,8 +133,7 @@ def test_get_publication_layman_status(publ_type, error_params): assert info['layman_metadata']['publication_status'] == 'COMPLETE', f'info={info}' if error_params: - check_response_fail = partial(process_client.wait_for_failure, publication_type_def.keys_to_check) - process_client.patch_workspace_publication(publ_type, workspace, publication, **error_params, check_response_fn=check_response_fail, ) + process_client.patch_workspace_publication(publ_type, workspace, publication, **error_params, ) info = process_client.get_workspace_publication(publ_type, workspace, publication, ) assert 'layman_metadata' in info, f'info={info}' assert 'publication_status' in info['layman_metadata'], f'info={info}' diff --git a/test/process_client.py b/test/process_client.py index 7391d55f0..1ecce0c74 100644 --- a/test/process_client.py +++ b/test/process_client.py @@ -72,20 +72,6 @@ } -def check_response_keys(keys_to_check, response): - if any(response.json()[k].get('status') == 'FAILURE' for k in keys_to_check): - error_keys = [k for k in keys_to_check if response.json()[k].get('status') == 'FAILURE'] - logger.error(f"failed_keys={error_keys}") - raise Exception('Some step failed!') - return response.status_code == 200 and all( - 'status' not in response.json()[k] for k in keys_to_check - ) - - -def wait_for_failure(keys_to_check, response): - return any(response.json()[k].get('status') == 'FAILURE' for k in keys_to_check) - - def wait_for_rest(url, max_attempts, sleeping_time, check_response, headers=None): headers = headers or None r = requests.get(url, headers=headers, timeout=5) @@ -130,7 +116,6 @@ def patch_workspace_publication(publication_type, headers = headers or {} file_paths = file_paths or [] publication_type_def = PUBLICATION_TYPES_DEF[publication_type] - check_response_fn = check_response_fn or partial(check_response_keys, publication_type_def.keys_to_check) if style_file: assert publication_type == LAYER_TYPE @@ -163,11 +148,7 @@ def patch_workspace_publication(publication_type, for fp in files: fp[1][1].close() - with app.app_context(): - url = url_for(publication_type_def.get_workspace_publication_url, - workspace=workspace, - **{publication_type_def.url_param_name: name}) - wait_for_rest(url, 30, 0.5, check_response_fn, headers=headers) + wait_for_publication_status(workspace, publication_type, name, check_response_fn=check_response_fn, headers=headers) wfs.clear_cache(workspace) wms.clear_cache(workspace) return r.json() @@ -224,7 +205,6 @@ def publish_workspace_publication(publication_type, headers = headers or {} publication_type_def = PUBLICATION_TYPES_DEF[publication_type] file_paths = file_paths or [publication_type_def.source_path, ] - check_response_fn = check_response_fn or partial(check_response_keys, publication_type_def.keys_to_check) if style_file: assert publication_type == LAYER_TYPE @@ -258,11 +238,7 @@ def publish_workspace_publication(publication_type, for fp in files: fp[1][1].close() - with app.app_context(): - url = url_for(publication_type_def.get_workspace_publication_url, - workspace=workspace, - **{publication_type_def.url_param_name: name}) - wait_for_rest(url, 30, 0.5, check_response_fn, headers=headers) + wait_for_publication_status(workspace, publication_type, name, check_response_fn=check_response_fn, headers=headers) return r.json()[0]