Skip to content

Commit

Permalink
Move publ_uuids to base test class
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Sep 13, 2023
1 parent f04e0ee commit f769e33
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
9 changes: 8 additions & 1 deletion tests/dynamic_data/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class TestSingleRestPublication:

post_before_test_scope = 'function'

publ_uuids = {}

@classmethod
@final
def parametrize_test_cases(cls) -> [TestCaseType]:
Expand Down Expand Up @@ -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'):
Expand Down
20 changes: 8 additions & 12 deletions tests/dynamic_data/publications/crs/maps/maps_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -48,7 +48,7 @@

class TestMap(base_test.TestSingleRestPublication):

workspace = 'dynamic_test_workspace_crs_maps'
workspace = WORKSPACE

publication_type = process_client.MAP_TYPE

Expand All @@ -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,
Expand All @@ -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', {})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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():
Expand Down

0 comments on commit f769e33

Please sign in to comment.