Skip to content

Commit

Permalink
Test strange attribute names with QML style
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Sep 14, 2021
1 parent ad4251f commit a0187a2
Show file tree
Hide file tree
Showing 4 changed files with 298 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sample/layman.layer/strange_attribute_names.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "atraktivita_geoturizmu",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "x,": 18.913842, "y,": 48.46164, "z,": 0, "Atraktivita geoturizmu": "Scharfenberg", "ČÍSLO": 1, "Info": "Scharfenberg - Ostrý vrch, nachádza sa tu komplex sakrálnych stavieb známych ako banskoštiavnická kalvária" }, "geometry": { "type": "Point", "coordinates": [ 18.913842, 48.46164, 0.0 ] } }
]
}
262 changes: 262 additions & 0 deletions sample/style/strange_attribute_names.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis styleCategories="AllStyleCategories" simplifyDrawingTol="1" labelsEnabled="0" simplifyDrawingHints="0" simplifyAlgorithm="0" hasScaleBasedVisibilityFlag="0" readOnly="0" simplifyMaxScale="1" maxScale="0" version="3.14.16-Pi" minScale="100000000" simplifyLocal="1">
<flags>
<Identifiable>1</Identifiable>
<Removable>1</Removable>
<Searchable>1</Searchable>
</flags>
<temporal startField="" durationUnit="min" endField="" enabled="0" accumulate="0" endExpression="" durationField="" fixedDuration="0" startExpression="" mode="0">
<fixedRange>
<start></start>
<end></end>
</fixedRange>
</temporal>
<renderer-v2 type="singleSymbol" forceraster="0" symbollevels="0" enableorderby="0">
<symbols>
<symbol alpha="1" clip_to_extent="1" type="marker" force_rhr="0" name="0">
<layer enabled="1" locked="0" pass="0" class="SimpleMarker">
<prop k="angle" v="0"/>
<prop k="color" v="196,60,57,255"/>
<prop k="horizontal_anchor_point" v="1"/>
<prop k="joinstyle" v="bevel"/>
<prop k="name" v="circle"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="35,35,35,255"/>
<prop k="outline_style" v="solid"/>
<prop k="outline_width" v="0"/>
<prop k="outline_width_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="scale_method" v="diameter"/>
<prop k="size" v="2"/>
<prop k="size_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="size_unit" v="MM"/>
<prop k="vertical_anchor_point" v="1"/>
<data_defined_properties>
<Option type="Map">
<Option type="QString" name="name" value=""/>
<Option name="properties"/>
<Option type="QString" name="type" value="collection"/>
</Option>
</data_defined_properties>
</layer>
</symbol>
</symbols>
<rotation/>
<sizescale/>
</renderer-v2>
<customproperties>
<property key="dualview/previewExpressions" value="&quot;x,&quot;"/>
<property key="embeddedWidgets/count" value="0"/>
<property key="qgis2web/Interactive" value="true"/>
<property key="qgis2web/Visible" value="true"/>
<property key="qgis2web/popup/Atraktivita geoturizmu" value="no label"/>
<property key="qgis2web/popup/Info" value="no label"/>
<property key="qgis2web/popup/x," value="no label"/>
<property key="qgis2web/popup/y," value="no label"/>
<property key="qgis2web/popup/z," value="no label"/>
<property key="qgis2web/popup/ČÍSLO" value="no label"/>
<property key="variableNames"/>
<property key="variableValues"/>
</customproperties>
<blendMode>0</blendMode>
<featureBlendMode>0</featureBlendMode>
<layerOpacity>1</layerOpacity>
<SingleCategoryDiagramRenderer diagramType="Histogram" attributeLegend="1">
<DiagramCategory direction="0" maxScaleDenominator="1e+08" rotationOffset="270" sizeType="MM" labelPlacementMethod="XHeight" opacity="1" minScaleDenominator="0" minimumSize="0" scaleDependency="Area" lineSizeType="MM" enabled="0" backgroundAlpha="255" sizeScale="3x:0,0,0,0,0,0" penColor="#000000" spacing="5" diagramOrientation="Up" penAlpha="255" height="15" spacingUnit="MM" penWidth="0" scaleBasedVisibility="0" lineSizeScale="3x:0,0,0,0,0,0" showAxis="1" spacingUnitScale="3x:0,0,0,0,0,0" width="15" barWidth="5" backgroundColor="#ffffff">
<fontProperties description="MS Shell Dlg 2,7.8,-1,5,50,0,0,0,0,0" style=""/>
<attribute color="#000000" label="" field=""/>
<axisSymbol>
<symbol alpha="1" clip_to_extent="1" type="line" force_rhr="0" name="">
<layer enabled="1" locked="0" pass="0" class="SimpleLine">
<prop k="capstyle" v="square"/>
<prop k="customdash" v="5;2"/>
<prop k="customdash_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="customdash_unit" v="MM"/>
<prop k="draw_inside_polygon" v="0"/>
<prop k="joinstyle" v="bevel"/>
<prop k="line_color" v="35,35,35,255"/>
<prop k="line_style" v="solid"/>
<prop k="line_width" v="0.26"/>
<prop k="line_width_unit" v="MM"/>
<prop k="offset" v="0"/>
<prop k="offset_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="ring_filter" v="0"/>
<prop k="use_custom_dash" v="0"/>
<prop k="width_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<data_defined_properties>
<Option type="Map">
<Option type="QString" name="name" value=""/>
<Option name="properties"/>
<Option type="QString" name="type" value="collection"/>
</Option>
</data_defined_properties>
</layer>
</symbol>
</axisSymbol>
</DiagramCategory>
</SingleCategoryDiagramRenderer>
<DiagramLayerSettings dist="0" placement="0" obstacle="0" linePlacementFlags="18" priority="0" zIndex="0" showAll="1">
<properties>
<Option type="Map">
<Option type="QString" name="name" value=""/>
<Option name="properties"/>
<Option type="QString" name="type" value="collection"/>
</Option>
</properties>
</DiagramLayerSettings>
<geometryOptions geometryPrecision="0" removeDuplicateNodes="0">
<activeChecks/>
<checkConfiguration/>
</geometryOptions>
<referencedLayers/>
<referencingLayers/>
<fieldConfiguration>
<field name="x,">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="y,">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="z,">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="Atraktivita geoturizmu">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="ČÍSLO">
<editWidget type="Range">
<config>
<Option/>
</config>
</editWidget>
</field>
<field name="Info">
<editWidget type="TextEdit">
<config>
<Option/>
</config>
</editWidget>
</field>
</fieldConfiguration>
<aliases>
<alias name="" index="0" field="x,"/>
<alias name="" index="1" field="y,"/>
<alias name="" index="2" field="z,"/>
<alias name="" index="3" field="Atraktivita geoturizmu"/>
<alias name="" index="4" field="ČÍSLO"/>
<alias name="" index="5" field="Info"/>
</aliases>
<excludeAttributesWMS/>
<excludeAttributesWFS/>
<defaults>
<default applyOnUpdate="0" expression="" field="x,"/>
<default applyOnUpdate="0" expression="" field="y,"/>
<default applyOnUpdate="0" expression="" field="z,"/>
<default applyOnUpdate="0" expression="" field="Atraktivita geoturizmu"/>
<default applyOnUpdate="0" expression="" field="ČÍSLO"/>
<default applyOnUpdate="0" expression="" field="Info"/>
</defaults>
<constraints>
<constraint unique_strength="0" notnull_strength="0" exp_strength="0" constraints="0" field="x,"/>
<constraint unique_strength="0" notnull_strength="0" exp_strength="0" constraints="0" field="y,"/>
<constraint unique_strength="0" notnull_strength="0" exp_strength="0" constraints="0" field="z,"/>
<constraint unique_strength="0" notnull_strength="0" exp_strength="0" constraints="0" field="Atraktivita geoturizmu"/>
<constraint unique_strength="0" notnull_strength="0" exp_strength="0" constraints="0" field="ČÍSLO"/>
<constraint unique_strength="0" notnull_strength="0" exp_strength="0" constraints="0" field="Info"/>
</constraints>
<constraintExpressions>
<constraint exp="" desc="" field="x,"/>
<constraint exp="" desc="" field="y,"/>
<constraint exp="" desc="" field="z,"/>
<constraint exp="" desc="" field="Atraktivita geoturizmu"/>
<constraint exp="" desc="" field="ČÍSLO"/>
<constraint exp="" desc="" field="Info"/>
</constraintExpressions>
<expressionfields/>
<attributeactions>
<defaultAction key="Canvas" value="{00000000-0000-0000-0000-000000000000}"/>
</attributeactions>
<attributetableconfig sortOrder="0" sortExpression="" actionWidgetStyle="dropDown">
<columns>
<column width="-1" type="field" name="x," hidden="0"/>
<column width="-1" type="field" name="y," hidden="0"/>
<column width="-1" type="field" name="z," hidden="0"/>
<column width="-1" type="field" name="Atraktivita geoturizmu" hidden="0"/>
<column width="-1" type="field" name="ČÍSLO" hidden="0"/>
<column width="-1" type="field" name="Info" hidden="0"/>
<column width="-1" type="actions" hidden="1"/>
</columns>
</attributetableconfig>
<conditionalstyles>
<rowstyles/>
<fieldstyles/>
</conditionalstyles>
<storedexpressions/>
<editform tolerant="1"></editform>
<editforminit/>
<editforminitcodesource>0</editforminitcodesource>
<editforminitfilepath></editforminitfilepath>
<editforminitcode><![CDATA[# -*- coding: utf-8 -*-
"""
QGIS forms can have a Python function that is called when the form is
opened.
Use this function to add extra logic to your forms.
Enter the name of the function in the "Python Init function"
field.
An example follows:
"""
from qgis.PyQt.QtWidgets import QWidget

def my_form_open(dialog, layer, feature):
geom = feature.geometry()
control = dialog.findChild(QWidget, "MyLineEdit")
]]></editforminitcode>
<featformsuppress>0</featformsuppress>
<editorlayout>generatedlayout</editorlayout>
<editable>
<field editable="1" name="Atraktivita geoturizmu"/>
<field editable="1" name="Info"/>
<field editable="1" name="x,"/>
<field editable="1" name="y,"/>
<field editable="1" name="z,"/>
<field editable="1" name="ČÍSLO"/>
</editable>
<labelOnTop>
<field name="Atraktivita geoturizmu" labelOnTop="0"/>
<field name="Info" labelOnTop="0"/>
<field name="x," labelOnTop="0"/>
<field name="y," labelOnTop="0"/>
<field name="z," labelOnTop="0"/>
<field name="ČÍSLO" labelOnTop="0"/>
</labelOnTop>
<dataDefinedFieldProperties/>
<widgets/>
<previewExpression>"Atraktivita geoturizmu"</previewExpression>
<mapTip>&lt;b>[% "Atraktivita geoturizmu" %]&lt;/b>&#xd;
&lt;br>&lt;/br>&#xd;
&#xd;
&#xd;
[% "Info" %]</mapTip>
<layerGeometryType>0</layerGeometryType>
</qgis>
12 changes: 12 additions & 0 deletions tests/static_publications/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@
'users_can_write': [OWNER],
},
},
(COMMON_WORKSPACE, LAYER_TYPE, 'post_strange_attributes_qml'): {
DEFINITION: [
{'file_paths': ['sample/layman.layer/strange_attribute_names.geojson'],
'style_file': 'sample/style/strange_attribute_names.qml',
},
],
TEST_DATA: {
'file_type': settings.FILE_TYPE_VECTOR,
'style_type': 'qml',
'attributes': {'atraktivita geoturizmu', 'info', 'x,', 'y,', 'z,', 'ČÍslo'},
},
},
(OWNER2, LAYER_TYPE, 'post_private_sld2'): {
DEFINITION: [
{'headers': HEADERS[OWNER2]},
Expand Down
16 changes: 16 additions & 0 deletions tests/static_publications/single_publication/layers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,19 @@ def test_micka_xml(workspace, publ_type, publication):
assert minus_line.endswith(diff_line['minus_line_ends_with']), f'diff_lines={"".join(diff_lines)}, idx={idx}, diff_line={diff_line}'

assert len(diff_lines) == micka_xml_def['diff_lines_len'], ''.join(diff_lines)


@pytest.mark.parametrize('workspace, publ_type, publication', [
publ_tuple for publ_tuple in data.LIST_LAYERS
if data.PUBLICATIONS[publ_tuple][data.TEST_DATA].get('attributes') is not None
])
@pytest.mark.usefixtures('liferay_mock', 'ensure_layman')
def test_layer_attributes_in_db(workspace, publ_type, publication):
ensure_publication(workspace, publ_type, publication)
generated_names = {'wkb_geometry', 'ogc_fid'}
expected_names = data.PUBLICATIONS[(workspace, publ_type, publication)][data.TEST_DATA]['attributes']
expected_names.update(generated_names)

with app.app_context():
attr_names = {col.name for col in layer_db.get_all_column_infos(workspace, publication)}
assert attr_names == expected_names

0 comments on commit a0187a2

Please sign in to comment.