Skip to content

Commit

Permalink
Use 'qml' instead of 'qgis' for style identification
Browse files Browse the repository at this point in the history
  • Loading branch information
index-git committed Feb 23, 2021
1 parent c4be453 commit 8bb1c2a
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 25 deletions.
10 changes: 5 additions & 5 deletions src/layman/common/prime_db_schema/publications_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,20 @@ 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():
pubs = publications.get_publication_infos(username, LAYER_TYPE)
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
Expand All @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion src/layman/error_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
}
2 changes: 1 addition & 1 deletion src/layman/gs_wfs_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/layman/gs_wfs_proxy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/layman/layer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def get_layer_sources():
'sld',
True,
),
StyleTypeDef('qgis',
'qgis',
StyleTypeDef('qml',
'qgis',
'qml',
False,
),
]
Expand Down
2 changes: 1 addition & 1 deletion src/layman/layer/filesystem/input_style_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/layman/layer/qgis/output_srs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 11 additions & 11 deletions src/layman/layer/rest_layers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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'
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/layman/upgrade/upgrade_v1_10.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 $$;
Expand Down

0 comments on commit 8bb1c2a

Please sign in to comment.