Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

868 map thumbnail #932

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'exp_before_rest_method': {
'map_layers': None,
'operates_on': None,
'thumbnail': None,
},
'rest_method': base_test_classes.RestMethodAll.POST,
'rest_args': {
Expand All @@ -43,6 +44,7 @@
(LAYER_HRANICE, 3, True),
},
'operates_on': [LAYER_HRANICE],
'thumbnail': os.path.join(DIRECTORY, 'map_liberec_hranice_thumbnail.png'),
},
},
'delete': {
Expand All @@ -56,12 +58,14 @@
(LAYER_HRANICE, 3, True),
},
'operates_on': [LAYER_HRANICE],
'thumbnail': os.path.join(DIRECTORY, 'map_liberec_hranice_thumbnail.png'),
},
'rest_method': base_test_classes.RestMethodAll.DELETE,
'rest_args': {},
'exp_after_rest_method': {
'map_layers': None,
'operates_on': None,
'thumbnail': None,
},
},
'patch_map_with_unauthorized_layer': {
Expand All @@ -71,14 +75,17 @@
'exp_before_rest_method': {
'map_layers': [(LAYER_HRANICE_PRIVATE, 1, True)],
'operates_on': [],
'thumbnail': os.path.join(DIRECTORY, 'map_liberec_thumbnail.png'),
},
'rest_method': base_test_classes.RestMethodAll.PATCH,
'rest_args': {
index-git marked this conversation as resolved.
Show resolved Hide resolved
'file_paths': [os.path.join(DIRECTORY, 'internal_hranice_private.json')],
'actor_name': PRIVATE_WORKSPACE,
},
'exp_after_rest_method': {
'map_layers': [(LAYER_HRANICE_PRIVATE, 1, True)],
'operates_on': [LAYER_HRANICE_PRIVATE],
'thumbnail': os.path.join(DIRECTORY, 'map_liberec_hranice_thumbnail.png'),
},
},
'patch_map_with_different_layers': {
Expand All @@ -93,6 +100,7 @@
(LAYER_HRANICE, 3, True),
},
'operates_on': [LAYER_HRANICE],
'thumbnail': os.path.join(DIRECTORY, 'map_liberec_hranice_thumbnail.png'),
},
'rest_method': base_test_classes.RestMethodAll.PATCH,
'rest_args': {
Expand All @@ -102,6 +110,7 @@
'exp_after_rest_method': {
'map_layers': [(LAYER_HRANICE_PRIVATE, 1, True)],
'operates_on': [LAYER_HRANICE_PRIVATE],
'thumbnail': os.path.join(DIRECTORY, 'map_liberec_hranice_thumbnail.png'),
},
},
}
Expand All @@ -117,6 +126,7 @@ class TestPublication(base_test.TestSingleRestPublication):
usernames_to_reserve = [PRIVATE_WORKSPACE]

test_cases = [base_test.TestCaseType(key=key,
publication=Publication(f'{WORKSPACE}_{key}', None, None),
params=params,
rest_args=params['rest_args'],
rest_method=params['rest_method'],
Expand Down Expand Up @@ -182,7 +192,7 @@ def assert_exp_map_layers(self, map, exp_map_layers, exp_operates_on, http_metho
})

@staticmethod
def assert_exp_layer_maps(layer, map_operates_on_tuples):
def assert_exp_layer_maps(layer, map_operates_on_tuples, workspaces_to_check):
exp_layer_maps = sorted([
(map.workspace, map.name)
for map, operates_on in map_operates_on_tuples
Expand All @@ -192,17 +202,25 @@ def assert_exp_layer_maps(layer, map_operates_on_tuples):
found_layer_maps = [
(m['workspace'], m['name'])
for m in get_publication_info(*layer, context={'keys': ['layer_maps']})['_layer_maps']
if m['workspace'] in workspaces_to_check
]
assert found_layer_maps == exp_layer_maps

@staticmethod
def assert_exp_map_thumbnail(map, exp_thumbnail):
if exp_thumbnail:
asserts_publ.internal.thumbnail_equals(map.workspace, map.type, map.name, exp_thumbnail,
max_diffs=0)

def test_publication(self, map, rest_method, rest_args, params):
exp = params['exp_before_rest_method']
self.assert_exp_map_layers(map, exp['map_layers'], exp['operates_on'], http_method=REQUEST_METHOD_POST,
actor_name=params['post_before_test_args'].get('actor_name'))
self.assert_exp_layer_maps(LAYER_HRANICE, [
(MAP_HRANICE, MAP_HRANICE_OPERATES_ON),
(map, exp['operates_on'] or []),
])
], workspaces_to_check=[map.workspace, MAP_HRANICE.workspace, PRIVATE_WORKSPACE])
self.assert_exp_map_thumbnail(map, exp['thumbnail'])

rest_method.fn(map, args=rest_args)
if rest_method.enum_item in [base_test_classes.RestMethodAll.POST, base_test_classes.RestMethodAll.PATCH]:
Expand All @@ -216,4 +234,5 @@ def test_publication(self, map, rest_method, rest_args, params):
self.assert_exp_layer_maps(LAYER_HRANICE, [
(MAP_HRANICE, MAP_HRANICE_OPERATES_ON),
(map, exp['operates_on'] or []),
])
], workspaces_to_check=[map.workspace, MAP_HRANICE.workspace, PRIVATE_WORKSPACE])
self.assert_exp_map_thumbnail(map, exp['thumbnail'])
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading