From 86d001c344a837decf158b9127f3418c4727a62c Mon Sep 17 00:00:00 2001 From: index-git <66255344+index-git@users.noreply.github.com> Date: Tue, 23 Feb 2021 18:21:45 +0100 Subject: [PATCH] Use 'qml' instead of 'qgis' for style identification --- .../prime_db_schema/publications_test.py | 10 ++++----- src/layman/error_list.py | 2 +- src/layman/gs_wfs_proxy.py | 2 +- src/layman/gs_wfs_proxy_test.py | 4 ++-- src/layman/layer/__init__.py | 4 ++-- .../layer/filesystem/input_style_test.py | 2 +- src/layman/layer/qgis/output_srs.py | 2 +- src/layman/layer/rest_layers_test.py | 22 +++++++++---------- src/layman/upgrade/upgrade_v1_10.py | 2 +- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/layman/common/prime_db_schema/publications_test.py b/src/layman/common/prime_db_schema/publications_test.py index 37ce4554a..dec51e466 100644 --- a/src/layman/common/prime_db_schema/publications_test.py +++ b/src/layman/common/prime_db_schema/publications_test.py @@ -93,12 +93,12 @@ def publications_by_type(prefix, def test_select_publications(): username = 'test_select_publications_user1' layername = 'test_select_publications_layer1' - layer_qgis = 'test_select_publications_layer_qgis' + layer_qml = 'test_select_publications_layer_qml' mapname = 'test_select_publications_map1' - qgis_style_file = 'sample/style/small_layer.qml' + qml_style_file = 'sample/style/small_layer.qml' process_client.publish_layer(username, layername) - process_client.publish_layer(username, layer_qgis, style_file=qgis_style_file,) + process_client.publish_layer(username, layer_qml, style_file=qml_style_file,) process_client.publish_map(username, mapname) with app.app_context(): @@ -106,7 +106,7 @@ def test_select_publications(): assert len(pubs) == 2 pubs = publications.get_publication_infos(username, MAP_TYPE) assert len(pubs) == 1 - pubs = publications.get_publication_infos(username, style_type='qgis') + pubs = publications.get_publication_infos(username, style_type='qml') assert len(pubs) == 1 pubs = publications.get_publication_infos(username, style_type='sld') assert len(pubs) == 1 @@ -116,7 +116,7 @@ def test_select_publications(): assert len(pubs) >= 3 process_client.delete_layer(username, layername) - process_client.delete_layer(username, layer_qgis) + process_client.delete_layer(username, layer_qml) process_client.delete_map(username, mapname) with app.app_context(): diff --git a/src/layman/error_list.py b/src/layman/error_list.py index 99349a5f2..7069c8c78 100644 --- a/src/layman/error_list.py +++ b/src/layman/error_list.py @@ -46,6 +46,6 @@ 43: (400, 'Wrong access rights.'), 44: (403, 'Unsuccessful HTTP Header authentication.'), 45: (400, 'Workspace ended with reserved suffix.'), - 46: (400, 'Unknown style file. Can recognize only SLD and QGIS files.'), + 46: (400, 'Unknown style file. Can recognize only SLD and QML files.'), 47: (400, 'Error in QML'), } diff --git a/src/layman/gs_wfs_proxy.py b/src/layman/gs_wfs_proxy.py index 42c99f20e..8d5153b96 100644 --- a/src/layman/gs_wfs_proxy.py +++ b/src/layman/gs_wfs_proxy.py @@ -51,7 +51,7 @@ def ensure_wfs_t_attributes(binary_data): if created_attributes: changed_layers = {(workspace, layer) for workspace, layer, _ in created_attributes} qgis_changed_layers = {(workspace, layer) for workspace, layer in changed_layers - if layer_util.get_layer_info(workspace, layer)['style_type'] == 'qgis'} + if layer_util.get_layer_info(workspace, layer)['style_type'] == 'qml'} for workspace, layer in qgis_changed_layers: qgis_wms.save_qgs_file(workspace, layer) gs_reset(settings.LAYMAN_GS_AUTH) diff --git a/src/layman/gs_wfs_proxy_test.py b/src/layman/gs_wfs_proxy_test.py index eb6c272fe..6725f3f93 100644 --- a/src/layman/gs_wfs_proxy_test.py +++ b/src/layman/gs_wfs_proxy_test.py @@ -206,7 +206,7 @@ def wfs_post(workspace, attr_names_list, data_xml): layer_schema = get_wfs_schema( wfs_url, typename=f"{workspace}:{layer}", version=geoserver_wfs.VERSION, headers=authn_headers) old_wfs_properties[layer] = sorted(layer_schema['properties'].keys()) - if style_type == 'qgis': + if style_type == 'qml': assert qgis_wms.get_layer_info(workspace, layer) old_qgis_attributes = qgis_util.get_layer_attribute_names(workspace, layer) assert all(attr_name not in old_qgis_attributes for attr_name in attr_names), (attr_names, old_qgis_attributes) @@ -233,7 +233,7 @@ def wfs_post(workspace, attr_names_list, data_xml): assert attr_name in new_wfs_properties[layer], f"new_wfs_properties={new_wfs_properties[layer]}, attr_name={attr_name}" assert set(attr_names).union(set(old_wfs_properties[layer])) == set(new_wfs_properties[layer]),\ set(new_wfs_properties[layer]).difference(set(attr_names).union(set(old_wfs_properties[layer]))) - if style_type == 'qgis': + if style_type == 'qml': assert qgis_wms.get_layer_info(workspace, layer) new_qgis_attributes = qgis_util.get_layer_attribute_names(workspace, layer) assert all(attr_name in new_qgis_attributes for attr_name in attr_names), (attr_names, new_qgis_attributes) diff --git a/src/layman/layer/__init__.py b/src/layman/layer/__init__.py index 9630a9f4f..18a34f733 100644 --- a/src/layman/layer/__init__.py +++ b/src/layman/layer/__init__.py @@ -91,9 +91,9 @@ def get_layer_sources(): 'sld', True, ), - StyleTypeDef('qgis', - 'qgis', + StyleTypeDef('qml', 'qgis', + 'qml', False, ), ] diff --git a/src/layman/layer/filesystem/input_style_test.py b/src/layman/layer/filesystem/input_style_test.py index 8063b00bc..ca8090392 100644 --- a/src/layman/layer/filesystem/input_style_test.py +++ b/src/layman/layer/filesystem/input_style_test.py @@ -9,7 +9,7 @@ @pytest.mark.parametrize('file_path, expected_type', [ ('sample/style/generic-blue_sld.xml', 'sld'), ('sample/style/sld_1_1_0.xml', 'sld'), - ('sample/style/small_layer.qml', 'qgis'), + ('sample/style/small_layer.qml', 'qml'), (None, 'sld'), ]) def test_get_style_type_from_xml_file(file_path, diff --git a/src/layman/layer/qgis/output_srs.py b/src/layman/layer/qgis/output_srs.py index aba78bf76..039afd56b 100644 --- a/src/layman/layer/qgis/output_srs.py +++ b/src/layman/layer/qgis/output_srs.py @@ -6,7 +6,7 @@ def ensure_output_srs_for_all(): - layers = layman_util.get_publication_infos(style_type='qgis') + layers = layman_util.get_publication_infos(style_type='qml') if layers: (workspace, _, layer) = next(iter(layers.keys())) old_set = util.get_layer_wms_crs_list_values(workspace, layer) diff --git a/src/layman/layer/rest_layers_test.py b/src/layman/layer/rest_layers_test.py index df440d274..3b60351f9 100644 --- a/src/layman/layer/rest_layers_test.py +++ b/src/layman/layer/rest_layers_test.py @@ -54,7 +54,7 @@ def assert_style_file(workspace, @pytest.mark.parametrize('source_style_file_path, layer_suffix, expected_style_file_template, expected_style_type', [ ('sample/style/generic-blue_sld.xml', '_sld', '/layman_data_test/users/{workspace}/layers/{layer}/input_style/{layer}.sld', 'sld'), ('sample/style/sld_1_1_0.xml', '_sld11', '/layman_data_test/users/{workspace}/layers/{layer}/input_style/{layer}.sld', 'sld'), - ('sample/style/small_layer.qml', '_qml', '/layman_data_test/users/{workspace}/layers/{layer}/input_style/{layer}.qgis', 'qgis'), + ('sample/style/small_layer.qml', '_qml', '/layman_data_test/users/{workspace}/layers/{layer}/input_style/{layer}.qml', 'qml'), ('', '_no_style', None, 'sld'), ]) @pytest.mark.usefixtures('ensure_layman') @@ -97,7 +97,7 @@ class TestQgisCascadeWmsClass: workspace = 'test_qgis_cascade_wms_workspace' layer = 'test_qgis_cascade_wms_layer' qgis_layer_files = ['/code/tmp/naturalearth/10m/cultural/ne_10m_admin_0_countries.geojson'] - qgis_style_file = 'sample/style/ne_10m_admin_0_countries.qml' + qml_style_file = 'sample/style/ne_10m_admin_0_countries.qml' sld_layer_files = ['/code/tmp/naturalearth/110m/cultural/ne_110m_admin_0_countries.geojson'] sld_style_file = 'sample/style/generic-blue_sld.xml' expected_qgis_thumbnail = 'sample/style/test_qgis_style_applied_in_thumbnail_layer.png' @@ -113,18 +113,18 @@ def assert_wms_layer(workspace, layer, style, expected_thumbnail_path=None): with app.app_context(): info = layer_util.get_layer_info(workspace, layer) - assert (info['style_type'] == 'qgis') == (style == 'qgis'), info.get('style_type', None) + assert (info['style_type'] == 'qml') == (style == 'qml'), info.get('style_type', None) - assert (os.path.exists(expected_style_file + '.qgis')) == (style == 'qgis') + assert (os.path.exists(expected_style_file + '.qml')) == (style == 'qml') assert (os.path.exists(expected_style_file + '.sld')) == (style == 'sld') - assert (os.path.exists(expected_qgis_file)) == (style == 'qgis') + assert (os.path.exists(expected_qgis_file)) == (style == 'qml') rv = requests.get(wms_stores_url, auth=settings.LAYMAN_GS_AUTH, timeout=5, ) assert rv.status_code == 200, rv.json() - if style == 'qgis': + if style == 'qml': assert rv.json()['wmsStores']['wmsStore'][0]['name'] == f'{DEFAULT_WMS_STORE_PREFIX}_{layer}', rv.json() rv = requests.get(wms_layers_url, @@ -143,16 +143,16 @@ def assert_wms_layer(workspace, layer, style, expected_thumbnail_path=None): @pytest.mark.usefixtures('ensure_layman') @pytest.mark.parametrize('operations', [ [ - ({'file_paths': qgis_layer_files, 'style_file': qgis_style_file, }, 'qgis', expected_qgis_thumbnail), + ({'file_paths': qgis_layer_files, 'style_file': qml_style_file, }, 'qml', expected_qgis_thumbnail), ], [ ({'file_paths': qgis_layer_files, }, None, None), - ({'style_file': qgis_style_file, }, 'qgis', expected_qgis_thumbnail), - ({'title': 'Title defined', }, 'qgis', expected_qgis_thumbnail), - ({'file_paths': sld_layer_files, }, 'qgis', None), + ({'style_file': qml_style_file, }, 'qml', expected_qgis_thumbnail), + ({'title': 'Title defined', }, 'qml', expected_qgis_thumbnail), + ({'file_paths': sld_layer_files, }, 'qml', None), ({'style_file': sld_style_file, }, 'sld', expected_sld_thumbnail), ({'file_paths': qgis_layer_files, }, 'sld', None), - ({'style_file': qgis_style_file, }, 'qgis', expected_qgis_thumbnail), + ({'style_file': qml_style_file, }, 'qml', expected_qgis_thumbnail), ], ]) def test_qgis_cascade_wms(self, diff --git a/src/layman/upgrade/upgrade_v1_10.py b/src/layman/upgrade/upgrade_v1_10.py index 6c580d143..4c2abb33a 100644 --- a/src/layman/upgrade/upgrade_v1_10.py +++ b/src/layman/upgrade/upgrade_v1_10.py @@ -27,7 +27,7 @@ def alter_schema(): db_schema = settings.LAYMAN_PRIME_SCHEMA add_column = f''' DO $$ BEGIN - CREATE TYPE enum_style_type AS ENUM ('sld', 'qgis'); + CREATE TYPE enum_style_type AS ENUM ('sld', 'qml'); EXCEPTION WHEN duplicate_object THEN null; END $$;