diff --git a/tests/dynamic_data/base_test.py b/tests/dynamic_data/base_test.py index d5397cd8c..c8cdba7d7 100644 --- a/tests/dynamic_data/base_test.py +++ b/tests/dynamic_data/base_test.py @@ -81,6 +81,8 @@ class TestSingleRestPublication: post_before_test_scope = 'function' + publ_uuids = {} + @classmethod @final def parametrize_test_cases(cls) -> [TestCaseType]: @@ -185,8 +187,13 @@ def post_publication(cls, publication, args=None, scope='function'): else: cls.publications_to_cleanup_on_function_end.add(publication) - return process_client.publish_workspace_publication(publication.type, publication.workspace, publication.name, + resp = process_client.publish_workspace_publication(publication.type, publication.workspace, publication.name, **args) + if isinstance(resp, dict): + maybe_uuid = resp.get('uuid', None) + if maybe_uuid: + cls.publ_uuids[publication] = maybe_uuid + return resp @classmethod def ensure_publication(cls, publication, args=None, scope='function'): diff --git a/tests/dynamic_data/publications/crs/maps/maps_test.py b/tests/dynamic_data/publications/crs/maps/maps_test.py index 67f5f6e19..1a16f15ca 100644 --- a/tests/dynamic_data/publications/crs/maps/maps_test.py +++ b/tests/dynamic_data/publications/crs/maps/maps_test.py @@ -7,8 +7,8 @@ from ..... import Publication DIRECTORY = os.path.dirname(os.path.abspath(__file__)) - -LAYER_FOR_MAPS = "layer_for_map_crs" +WORKSPACE = 'dynamic_test_workspace_crs_maps' +LAYER_FOR_MAPS = Publication(WORKSPACE, process_client.LAYER_TYPE, "layer_for_map_crs") KEY_INFO_VALUES = 'info_values' KEY_THUMBNAIL_TOLERANCE = 'thumbnail_tolerance' @@ -48,7 +48,7 @@ class TestMap(base_test.TestSingleRestPublication): - workspace = 'dynamic_test_workspace_crs_maps' + workspace = WORKSPACE publication_type = process_client.MAP_TYPE @@ -61,18 +61,14 @@ class TestMap(base_test.TestSingleRestPublication): type=tests.EnumTestTypes.MANDATORY, ) for key, params in TEST_CASES.items()] - layer_uuids = {} - def before_class(self): - resp = self.post_publication(Publication(self.workspace, process_client.LAYER_TYPE, LAYER_FOR_MAPS), scope='class') - self.layer_uuids[LAYER_FOR_MAPS] = resp['uuid'] + self.post_publication(LAYER_FOR_MAPS, scope='class') def test_input_crs(self, map, key, params, rest_method): """Parametrized using pytest_generate_tests""" map_crs = key - layer_name = LAYER_FOR_MAPS map_args = { - 'map_layers': [(self.workspace, layer_name)], + 'map_layers': [(LAYER_FOR_MAPS.workspace, LAYER_FOR_MAPS.name)], 'native_extent': params[KEY_INFO_VALUES]['exp_publication_detail']['native_bounding_box'], 'crs': map_crs, 'title': map.name, @@ -84,10 +80,10 @@ def test_input_crs(self, map, key, params, rest_method): 'native_crs': map_crs, 'title': map.name, '_map_layers': [{ - 'name': LAYER_FOR_MAPS, - 'workspace': self.workspace, + 'name': LAYER_FOR_MAPS.name, + 'workspace': LAYER_FOR_MAPS.workspace, 'index': 1, - 'uuid': self.layer_uuids[LAYER_FOR_MAPS], + 'uuid': self.publ_uuids[LAYER_FOR_MAPS], }], **params.get(KEY_INFO_VALUES, {}).get('exp_publication_detail', {}) } diff --git a/tests/dynamic_data/publications/map_layer_relation/map_layer_relation.py b/tests/dynamic_data/publications/map_layer_relation/map_layer_relation.py index 2c72f3908..cbafbd200 100644 --- a/tests/dynamic_data/publications/map_layer_relation/map_layer_relation.py +++ b/tests/dynamic_data/publications/map_layer_relation/map_layer_relation.py @@ -77,10 +77,8 @@ class TestPublication(base_test.TestSingleRestPublication): type=EnumTestTypes.MANDATORY, ) for key, params in TEST_CASES.items()] - publ_uuids = {} - def before_class(self): - resp = self.post_publication(LAYER_HRANICE, args={ + self.post_publication(LAYER_HRANICE, args={ 'file_paths': [ 'tmp/naturalearth/110m/cultural/ne_110m_admin_0_boundary_lines_land.cpg', 'tmp/naturalearth/110m/cultural/ne_110m_admin_0_boundary_lines_land.dbf', @@ -89,12 +87,10 @@ def before_class(self): 'tmp/naturalearth/110m/cultural/ne_110m_admin_0_boundary_lines_land.shx', ], }, scope='class') - self.publ_uuids[LAYER_HRANICE] = resp['uuid'] - resp = self.post_publication(MAP_HRANICE, args={ + self.post_publication(MAP_HRANICE, args={ 'file_paths': [os.path.join(DIRECTORY, 'internal_hranice.json')], }, scope='class') - self.publ_uuids[MAP_HRANICE] = resp['uuid'] def assert_exp_map_layers(self, map, exp_map_layers, exp_operates_on): with app.app_context():