diff --git a/tests/dynamic_data/base_test.py b/tests/dynamic_data/base_test.py index c8cdba7d7..2a705fdb8 100644 --- a/tests/dynamic_data/base_test.py +++ b/tests/dynamic_data/base_test.py @@ -7,7 +7,7 @@ from tests.asserts.util import recursive_dict_update from test_tools import process_client, cleanup, external_db from .base_test_classes import WithChunksDomain, CompressDomainBase, CompressDomain, RestArgs, RestMethod, PublicationByDefinitionBase, \ - LayerByUsedServers, PublicationByUsedServers, TestCaseType, Parametrization, StyleFileDomainBase # pylint: disable=unused-import + LayerByUsedServers, PublicationByUsedServers, TestCaseType, Parametrization, StyleFileDomainBase, RestMethodParam # pylint: disable=unused-import from . import base_test_util as util from .base_test_classes import ExternalTableDef from .. import Publication, EnumTestTypes, EnumTestKeys, PublicationValues @@ -41,7 +41,7 @@ def pytest_generate_tests(metafunc): publ_type_name: test_case.publication, 'key': test_case.key, 'params': copy.deepcopy(test_case.params), - 'rest_method': rest_method, + 'rest_method': RestMethodParam(test_case.rest_method, rest_method), 'rest_args': rest_args, 'parametrization': parametrization, 'post_before_test': (test_case.publication, test_case.rest_method, test_case.post_before_test_args), diff --git a/tests/dynamic_data/base_test_classes.py b/tests/dynamic_data/base_test_classes.py index cd091f32f..cecf38bb5 100644 --- a/tests/dynamic_data/base_test_classes.py +++ b/tests/dynamic_data/base_test_classes.py @@ -157,3 +157,10 @@ class TestCaseType: marks: List[_pytest.mark.structures.Mark] = field(default_factory=list) parametrization: Parametrization = None post_before_test_args: dict = field(default_factory=dict) + + +@dataclass(frozen=True) +class RestMethodParam: + # pylint: disable=invalid-name + enum_item: RestMethodBase = None + fn: callable = None diff --git a/tests/dynamic_data/publications/crs/maps/maps_test.py b/tests/dynamic_data/publications/crs/maps/maps_test.py index 1a16f15ca..a17d1e1f4 100644 --- a/tests/dynamic_data/publications/crs/maps/maps_test.py +++ b/tests/dynamic_data/publications/crs/maps/maps_test.py @@ -73,7 +73,7 @@ def test_input_crs(self, map, key, params, rest_method): 'crs': map_crs, 'title': map.name, } - rest_method(map, args=map_args) + rest_method.fn(map, args=map_args) exp_publication_detail = { 'description': 'Map generated for internal layers', diff --git a/tests/dynamic_data/publications/implicit_name_test.py b/tests/dynamic_data/publications/implicit_name_test.py index efadbc885..73efa6df1 100644 --- a/tests/dynamic_data/publications/implicit_name_test.py +++ b/tests/dynamic_data/publications/implicit_name_test.py @@ -135,6 +135,6 @@ class TestLayer(base_test.TestSingleRestPublication): @staticmethod def test_implicit_name(publication: Publication, rest_method, rest_args): """Parametrized using pytest_generate_tests""" - rest_method(publication, args=rest_args) + rest_method.fn(publication, args=rest_args) asserts_util.is_publication_valid_and_complete(publication) diff --git a/tests/dynamic_data/publications/layer_by_used_servers/layer_by_used_servers_test.py b/tests/dynamic_data/publications/layer_by_used_servers/layer_by_used_servers_test.py index ede111e01..9d9f781ef 100644 --- a/tests/dynamic_data/publications/layer_by_used_servers/layer_by_used_servers_test.py +++ b/tests/dynamic_data/publications/layer_by_used_servers/layer_by_used_servers_test.py @@ -64,7 +64,7 @@ class TestLayer(base_test.TestSingleRestPublication): def test_layer(layer, params, rest_args, rest_method, parametrization): """Parametrized using pytest_generate_tests""" publ_def = parametrization.publication_definition - rest_method(layer, args=rest_args) + rest_method.fn(layer, args=rest_args) assert_util.is_publication_valid_and_complete(layer) diff --git a/tests/dynamic_data/publications/layer_external_db/edge_db_username_and_password.py b/tests/dynamic_data/publications/layer_external_db/edge_db_username_and_password.py index 22a605eb3..703f3b9f5 100644 --- a/tests/dynamic_data/publications/layer_external_db/edge_db_username_and_password.py +++ b/tests/dynamic_data/publications/layer_external_db/edge_db_username_and_password.py @@ -80,7 +80,7 @@ def test_layer(self, layer: Publication, rest_method, rest_args, ): db_util.run_statement(statement, conn_cur=conn_cur) # publish layer from external DB table - rest_method(layer, args=rest_args) + rest_method.fn(layer, args=rest_args) # general checks assert_util.is_publication_valid_and_complete(layer) diff --git a/tests/dynamic_data/publications/layer_external_db/external_db_test.py b/tests/dynamic_data/publications/layer_external_db/external_db_test.py index 1186324de..310057d4d 100644 --- a/tests/dynamic_data/publications/layer_external_db/external_db_test.py +++ b/tests/dynamic_data/publications/layer_external_db/external_db_test.py @@ -225,7 +225,7 @@ def test_layer(self, layer: Publication, rest_method, rest_args, params): assert result[0][0] == params['exp_geometry_type'] # publish layer from external DB table - rest_method(layer, args=rest_args) + rest_method.fn(layer, args=rest_args) # general checks assert_util.is_publication_valid_and_complete(layer) diff --git a/tests/dynamic_data/publications/layer_overview_resampling/resampling_test.py b/tests/dynamic_data/publications/layer_overview_resampling/resampling_test.py index 948493e2b..a714576e2 100644 --- a/tests/dynamic_data/publications/layer_overview_resampling/resampling_test.py +++ b/tests/dynamic_data/publications/layer_overview_resampling/resampling_test.py @@ -38,7 +38,7 @@ def test_overview_resampling(layer, key, rest_method): 'overview_resampling': overview_resampling_method, 'style_file': os.path.join(DIRECTORY, 'style.sld'), } - rest_method(layer, args=layer_args) + rest_method.fn(layer, args=layer_args) assert_util.is_publication_valid_and_complete(layer) exp_thumbnail = os.path.join(DIRECTORY, f"thumbnail_{overview_resampling_method}.png") diff --git a/tests/dynamic_data/publications/layer_raster_contrast/contrast_test.py b/tests/dynamic_data/publications/layer_raster_contrast/contrast_test.py index a64940129..11b72a5ba 100644 --- a/tests/dynamic_data/publications/layer_raster_contrast/contrast_test.py +++ b/tests/dynamic_data/publications/layer_raster_contrast/contrast_test.py @@ -169,7 +169,7 @@ def test_contrast(layer: Publication, params, rest_method, rest_args): rel_file_path = os.path.relpath(abs_file_path, DIRECTORY) assert_input_file(abs_file_path, expected_input.get(rel_file_path, expected_input)) - rest_method(layer, args=rest_args) + rest_method.fn(layer, args=rest_args) assert_util.is_publication_valid_and_complete(layer) base_file_name = '_'.join(layer.name.split('_')[1:]) diff --git a/tests/dynamic_data/publications/layer_style/layer_qml_test.py b/tests/dynamic_data/publications/layer_style/layer_qml_test.py index e4e52aa6f..40ea09163 100644 --- a/tests/dynamic_data/publications/layer_style/layer_qml_test.py +++ b/tests/dynamic_data/publications/layer_style/layer_qml_test.py @@ -54,6 +54,6 @@ class TestLayer(base_test.TestSingleRestPublication): @staticmethod def test_qml_style(layer: Publication, rest_args, rest_method): """Parametrized using pytest_generate_tests""" - rest_method(layer, args=rest_args) + rest_method.fn(layer, args=rest_args) assert_util.is_publication_valid_and_complete(layer) diff --git a/tests/dynamic_data/publications/layer_style/layer_style_test.py b/tests/dynamic_data/publications/layer_style/layer_style_test.py index 883f73ee6..c378ec801 100644 --- a/tests/dynamic_data/publications/layer_style/layer_style_test.py +++ b/tests/dynamic_data/publications/layer_style/layer_style_test.py @@ -50,7 +50,7 @@ class TestLayer(base_test.TestSingleRestPublication): @staticmethod def test_style_xml(layer: Publication, params, rest_method): """Parametrized using pytest_generate_tests""" - rest_method(layer, args={ + rest_method.fn(layer, args={ 'file_paths': ['sample/layman.layer/small_layer.geojson'], 'style_file': params.get('style_file'), }) diff --git a/tests/dynamic_data/publications/layer_timeseries/timeseries_test.py b/tests/dynamic_data/publications/layer_timeseries/timeseries_test.py index 239a205be..eb36c2ac4 100644 --- a/tests/dynamic_data/publications/layer_timeseries/timeseries_test.py +++ b/tests/dynamic_data/publications/layer_timeseries/timeseries_test.py @@ -335,7 +335,7 @@ class TestLayer(base_test.TestSingleRestPublication): @pytest.mark.timeout(60) def test_timeseries_layer(self, layer: Publication, params, rest_method, rest_args): """Parametrized using pytest_generate_tests""" - rest_method(layer, args=rest_args) + rest_method.fn(layer, args=rest_args) asserts_util.is_publication_valid_and_complete(layer) @@ -362,9 +362,9 @@ def test_timeseries_layer(self, layer: Publication, params, rest_method, rest_ar exp_thumbnail = os.path.join(DIRECTORY, exp_thumbnail_file) asserts_publ.internal.thumbnail_equals(layer.workspace, layer.type, layer.name, exp_thumbnail, max_diffs=1) - if rest_method == self.post_publication: # pylint: disable=W0143 + if rest_method.enum_item == base_test.RestMethod.POST: http_method = common.REQUEST_METHOD_POST - elif rest_method == self.patch_publication: # pylint: disable=W0143 + elif rest_method.enum_item == base_test.RestMethod.PATCH: http_method = common.REQUEST_METHOD_PATCH else: raise NotImplementedError(f"Unknown rest_method: {rest_method}") diff --git a/tests/dynamic_data/publications/map_layer_relation/map_layer_relation_test.py b/tests/dynamic_data/publications/map_layer_relation/map_layer_relation_test.py index 59964b39b..445bd4d6d 100644 --- a/tests/dynamic_data/publications/map_layer_relation/map_layer_relation_test.py +++ b/tests/dynamic_data/publications/map_layer_relation/map_layer_relation_test.py @@ -181,8 +181,8 @@ def test_publication(self, map, rest_method, rest_args, params): (map, exp['operates_on'] or []), ]) - rest_method(map, args=rest_args) - if rest_method in [self.post_publication, self.patch_publication]: + rest_method.fn(map, args=rest_args) + if rest_method.enum_item in [base_test_classes.RestMethodAll.POST, base_test_classes.RestMethodAll.PATCH]: assert_util.is_publication_valid_and_complete(map) exp = params['exp_after_rest_method'] diff --git a/tests/dynamic_data/publications/publication_name_test.py b/tests/dynamic_data/publications/publication_name_test.py index e7f15ebdd..0cca17c7f 100644 --- a/tests/dynamic_data/publications/publication_name_test.py +++ b/tests/dynamic_data/publications/publication_name_test.py @@ -66,7 +66,7 @@ def function_cleanup(self, request): def test_publication_name(publication, rest_method, rest_args, parametrization): """Parametrized using pytest_generate_tests""" publ_def = parametrization.publication_definition - rest_method(publication, args=rest_args) + rest_method.fn(publication, args=rest_args) assert_util.is_publication_valid_and_complete(publication) publ_asserts.internal.correct_values_in_detail(publication.workspace, publication.type, publication.name, **publ_def.info_values) diff --git a/tests/dynamic_data/publications/updating_layer_test.py b/tests/dynamic_data/publications/updating_layer_test.py index e1a9d6e84..547bafbc6 100644 --- a/tests/dynamic_data/publications/updating_layer_test.py +++ b/tests/dynamic_data/publications/updating_layer_test.py @@ -33,7 +33,7 @@ class TestUpdatingLayer(base_test.TestSingleRestPublication): @staticmethod def test_layer(layer, params, rest_method): """Parametrized using pytest_generate_tests""" - rest_method(layer, args=params) + rest_method.fn(layer, args=params) exp_publication_detail = { 'geodata_type': 'unknown', diff --git a/tests/dynamic_data/publications/wrong_input/wrong_input_test.py b/tests/dynamic_data/publications/wrong_input/wrong_input_test.py index 52091cf17..ea195a148 100644 --- a/tests/dynamic_data/publications/wrong_input/wrong_input_test.py +++ b/tests/dynamic_data/publications/wrong_input/wrong_input_test.py @@ -1376,10 +1376,10 @@ def test_publication(self, publication: Publication, rest_method, rest_args, par format_exception(exp_exception, publication, parametrization) exception = pytest.raises(params[Key.EXCEPTION]) if is_sync else does_not_raise() with exception as exception_info: - response = rest_method(publication, args=rest_args) + response = rest_method.fn(publication, args=rest_args) if is_sync: processing.exception.response_exception(expected=exp_exception, thrown=exception_info) - if rest_method == self.patch_publication: # pylint: disable=W0143 + if rest_method.enum_item == base_test.RestMethod.PATCH: assert_utils.is_publication_valid_and_complete(publication) else: processing.response.valid_post(workspace=publication.workspace, diff --git a/tests/dynamic_data/publications/x_forwarded_prefix/rest_endpoints_test.py b/tests/dynamic_data/publications/x_forwarded_prefix/rest_endpoints_test.py index c8cbae1a0..706412cbc 100644 --- a/tests/dynamic_data/publications/x_forwarded_prefix/rest_endpoints_test.py +++ b/tests/dynamic_data/publications/x_forwarded_prefix/rest_endpoints_test.py @@ -30,7 +30,7 @@ class TestPublication(base_test.TestSingleRestPublication): def test_publication(self, publication, rest_method): proxy_prefix = '/layman-proxy' - response = rest_method(publication, args={'headers': {'X-Forwarded-Prefix': proxy_prefix}}) + response = rest_method.fn(publication, args={'headers': {'X-Forwarded-Prefix': proxy_prefix}}) publication_response = response[0] if isinstance(response, list) and len(response) == 1 else response if rest_method == self.patch_publication: # pylint: disable=W0143 if publication.type == process_client.LAYER_TYPE: