Skip to content

Commit

Permalink
Move empty_zip to generated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Nov 2, 2021
1 parent 6b8ce2c commit f3bf40c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 30 deletions.
28 changes: 0 additions & 28 deletions tests/dynamic_data/publications/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,34 +1045,6 @@
],
},
],
Publication(consts.COMMON_WORKSPACE, consts.LAYER_TYPE, 'empty_zip'): [
{
consts.KEY_ACTION: {
consts.KEY_CALL: Action(process_client.publish_workspace_publication, {
'file_paths': [],
'compress': True,
}),
consts.KEY_CALL_EXCEPTION: {
consts.KEY_EXCEPTION: LaymanError,
consts.KEY_EXCEPTION_ASSERTS: [
Action(processing.exception.response_exception, {
'expected': {'http_code': 400,
'code': 2,
'detail': {'parameter': 'file',
'message': 'Zip file without data file inside.',
'expected': 'At least one file with any of extensions: .geojson, .shp, .tiff, .tif, .jp2, .png, .jpg; or one of them in single .zip file.',
'files': [
'temporary_zip_file.zip',
],
}, }, }, ),
],
},
},
consts.KEY_FINAL_ASSERTS: [
Action(publication.internal.does_not_exist, dict())
],
},
],
**wrong_input.generate(consts.COMMON_WORKSPACE + '_generated_wrong_input'),
**file_input.generate(consts.COMMON_WORKSPACE + '_generated_file_input'),
}
29 changes: 27 additions & 2 deletions tests/dynamic_data/publications/wrong_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,30 @@
},
},
},
'empty_zip': {
KEY_PUBLICATION_TYPE: process_client.LAYER_TYPE,
KEY_ACTION_PARAMS: {
'file_paths': [],
'compress': True,
},
consts.KEY_EXCEPTION: LaymanError,
KEY_EXPECTED_EXCEPTION: {
KEY_DEFAULT: {'http_code': 400,
'sync': True,
'code': 2,
'detail': {'parameter': 'file',
'message': 'Zip file without data file inside.',
'expected': 'At least one file with any of extensions: .geojson, .shp, .tiff, .tif, .jp2, .png, .jpg; or one of them in single .zip file.',
'files': [
'temporary_zip_file.zip',
],
},
},
frozenset([('compress', True), ('with_chunks', True)]): {
'sync': False,
'detail': {'files': ['empty_zip_post_chunks_zipped.zip']}}
},
},
}


Expand All @@ -73,12 +97,13 @@ def generate(workspace=None):

result = dict()
for testcase, tc_params in TESTCASES.items():
all_combinations = itertools.product(*rest_param_all_values)
for rest_param_values in all_combinations:
for rest_param_values in itertools.product(*rest_param_all_values):
test_case_postfix = '_'.join([REST_PARAMETRIZATION[rest_param_names[idx]][value]
for idx, value in enumerate(rest_param_values)
if REST_PARAMETRIZATION[rest_param_names[idx]][value]])
rest_param_dict = {rest_param_names[idx]: value for idx, value in enumerate(rest_param_values)}
if any(k in rest_param_dict and rest_param_dict[k] != v for k, v in tc_params[KEY_ACTION_PARAMS].items()):
continue
rest_param_frozen_set = frozenset(rest_param_dict.items())
default_exp_exception = copy.deepcopy(tc_params[KEY_EXPECTED_EXCEPTION][KEY_DEFAULT])
exception_diff = tc_params[KEY_EXPECTED_EXCEPTION].get(rest_param_frozen_set, dict())
Expand Down

0 comments on commit f3bf40c

Please sign in to comment.