Skip to content

Commit

Permalink
[Server][Tests] Fix WMS tests locally
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Oct 19, 2017
1 parent a6ac876 commit dc6bdc2
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 18 deletions.
14 changes: 9 additions & 5 deletions tests/src/python/test_qgsserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@

# Strip path and content length because path may vary
RE_STRIP_UNCHECKABLE = b'MAP=[^"]+|Content-Length: \d+'
RE_ELEMENT = b'</*([^>\s]+)[ >]'
RE_ELEMENT_CONTENT = b'\>([^><]+)'
RE_ELEMENT = b'</*([^>\[\s]+)[ >]'
RE_ELEMENT_CONTENT = b'<[^>\[]+>(.+)</[^>\[\s]+>'
RE_ATTRIBUTES = rb'((?:(?!\s|=).)*)\s*?=\s*?["\']?((?:(?<=")(?:(?<=\\)"|[^"])*|(?<=\')(?:(?<=\\)\'|[^\'])*)|(?:(?!"|\')(?:(?!\/>|>|\s).)+))'


Expand Down Expand Up @@ -82,17 +82,21 @@ def assertXMLEqual(self, response, expected, msg=''):
if len(expected_elements) == 2 and expected_elements[0] == expected_elements[1]:
expected_element_content = re.findall(RE_ELEMENT_CONTENT, expected_line)
response_element_content = re.findall(RE_ELEMENT_CONTENT, response_line)
self.assertEqual(expected_element_content[0],
response_element_content[0], msg=msg + "\nContent mismatch on line %s: %s != %s" % (line_no, expected_line, response_line))
self.assertEqual(len(expected_element_content), len(response_element_content),
msg=msg + "\nContent mismatch on line %s: %s != %s" % (line_no, expected_line, response_line))
if len(expected_element_content):
self.assertEqual(expected_element_content[0],
response_element_content[0], msg=msg + "\nContent mismatch on line %s: %s != %s" % (line_no, expected_line, response_line))
else:
self.assertEqual(expected_line, response_line, msg=msg + "\nTag line mismatch %s: %s != %s\n%s" % (line_no, expected_line, response_line, msg))
# print("---->%s\t%s == %s" % (line_no, expected_line, response_line))
# Compare attributes
if re.findall(RE_ATTRIBUTES, expected_line): # has attrs
expected_attrs, expected_values = zip(*sorted(re.findall(RE_ATTRIBUTES, expected_line)))
self.assertTrue(re.findall(RE_ATTRIBUTES, response_line), msg=msg + "\nXML attributes differ at line {0}: {1} != {2}".format(line_no, expected_line, response_line))
response_attrs, response_values = zip(*sorted(re.findall(RE_ATTRIBUTES, response_line)))
self.assertEqual(expected_attrs, response_attrs, msg=msg + "\nXML attributes differ at line {0}: {1} != {2}".format(line_no, expected_attrs, response_attrs))
self.assertEqual(expected_values, response_values, msg=msg + "\nXML attribute values differ at line {0}: {1} != {2}".format(line_no, expected_attrs, response_attrs))
self.assertEqual(expected_values, response_values, msg=msg + "\nXML attribute values differ at line {0}: {1} != {2}".format(line_no, expected_values, response_values))
line_no += 1

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/qgis_server/describelayer.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*****
Content-Type: text/xml; charset=utf-8

<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<DescribeLayerResponse xmlns="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/DescribeLayer.xsd" xmlns:se="http://www.opengis.net/se" xmlns:xlink="http://www.w3.org/1999/xlink">
<Version>1.1.0</Version>
<LayerDescription>
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/qgis_server/getcapabilities.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Content-Type: text/xml; charset=utf-8
<Service>
<Name>WMS</Name>
<Title>QGIS TestProject</Title>
<Abstract>Some UTF8 text èòù</Abstract>
<Abstract><![CDATA[Some UTF8 text èòù]]></Abstract>
<KeywordList>
<Keyword vocabulary="ISO">infoMapAccessService</Keyword>
</KeywordList>
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/qgis_server/getcapabilities_inspire.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Content-Type: text/xml; charset=utf-8
<Service>
<Name>WMS</Name>
<Title>QGIS TestProject</Title>
<Abstract>Some UTF8 text èòù</Abstract>
<Abstract><![CDATA[Some UTF8 text èòù]]></Abstract>
<KeywordList>
<Keyword vocabulary="ISO">infoMapAccessService</Keyword>
</KeywordList>
Expand Down
6 changes: 3 additions & 3 deletions tests/testdata/qgis_server/getcontext.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ Content-Type: text/xml; charset=utf-8
<General>
<Window width="800" height="600"/>
<ows:Title>QGIS TestProject</ows:Title>
<ows:Abstract>Some UTF8 text èòù</ows:Abstract>
<ows:Abstract><![CDATA[Some UTF8 text èòù]]></ows:Abstract>
<ows:BoundingBox crs="EPSG:4326">
<ows:LowerCorner>44.9012 8.20315</ows:LowerCorner>
<ows:UpperCorner>44.9016 8.20416</ows:UpperCorner>
</ows:BoundingBox>
</General>
<ResourceList>
<Layer opacity="1" queryable="true" hidden="false" id="testlayer_èé" name="testlayer èé">
<Layer hidden="true" queryable="true" id="testlayer_èé" name="testlayer èé" opacity="1">
<ows:Title>A test vector layer</ows:Title>
<ows:OutputFormat>image/png</ows:OutputFormat>
<Server version="1.3.0" default="true" service="urn:ogc:serviceType:WMS">
<OnlineResource xlink:href="https://www.qgis.org/?*****&amp;"/>
<OnlineResource xlink:href="https://www.qgis.org/?*****"/>
</Server>
<ows:Abstract>A test vector layer with unicode òà</ows:Abstract>
<StyleList>
Expand Down
12 changes: 6 additions & 6 deletions tests/testdata/qgis_server/getprojectsettings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Content-Type: text/xml; charset=utf-8
<Service>
<Name>WMS</Name>
<Title>QGIS TestProject</Title>
<Abstract>Some UTF8 text èòù</Abstract>
<Abstract><![CDATA[Some UTF8 text èòù]]></Abstract>
<KeywordList>
<Keyword vocabulary="ISO">infoMapAccessService</Keyword>
</KeywordList>
Expand Down Expand Up @@ -113,7 +113,7 @@ Content-Type: text/xml; charset=utf-8
<WFSLayers>
<WFSLayer name="testlayer èé"/>
</WFSLayers>
<Layer queryable="1">
<Layer>
<Name>QGIS Test Project</Name>
<Title>QGIS Test Project</Title>
<CRS>CRS:84</CRS>
Expand All @@ -128,7 +128,7 @@ Content-Type: text/xml; charset=utf-8
<BoundingBox maxy="5.60604e+06" maxx="913283" miny="5.60599e+06" CRS="EPSG:3857" minx="913171"/>
<BoundingBox maxy="8.20416" maxx="44.9016" miny="8.20315" CRS="EPSG:4326" minx="44.9012"/>
<TreeName>QGIS Test Project</TreeName>
<Layer geometryType="Point" queryable="1" displayField="name" visible="1">
<Layer geometryType="Point" queryable="1" displayField="name">
<Name>testlayer èé</Name>
<Title>A test vector layer</Title>
<Abstract>A test vector layer with unicode òà</Abstract>
Expand All @@ -153,9 +153,9 @@ Content-Type: text/xml; charset=utf-8
</Style>
<TreeName>testlayer èé</TreeName>
<Attributes>
<Attribute precision="0" type="qlonglong" editType="" typeName="Integer64" name="id" comment="" length="10"/>
<Attribute precision="0" type="QString" editType="" typeName="String" name="name" comment="" length="10"/>
<Attribute precision="0" type="QString" editType="" typeName="String" name="utf8nameè" comment="" length="13"/>
<Attribute precision="0" type="qlonglong" editType="TextEdit" typeName="Integer64" name="id" comment="" length="10"/>
<Attribute precision="0" type="QString" editType="TextEdit" typeName="String" name="name" comment="" length="10"/>
<Attribute precision="0" type="QString" editType="TextEdit" typeName="String" name="utf8nameè" comment="" length="13"/>
</Attributes>
</Layer>
</Layer>
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/qgis_server/getstyles.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*****
Content-Type: text/xml; charset=utf-8

<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:ogc="http://www.opengis.net/ogc" xmlns:se="http://www.opengis.net/se" version="1.1.0" xmlns:xlink="http://www.w3.org/1999/xlink">
<NamedLayer>
<se:Name>testlayer èé</se:Name>
Expand Down
1 change: 1 addition & 0 deletions tests/testdata/qgis_server/wms_getfeatureinfo_filter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Content-Type: text/xml; charset=utf-8
<Attribute value="2" name="id"/>
<Attribute value="two" name="name"/>
<Attribute value="two àò" name="utf8nameè"/>
<Attribute value="1" name="orig_ogc_fid"/>
<BoundingBox maxy="5606017.8743" maxx="913214.6741" miny="5606017.8743" CRS="EPSG:3857" minx="913214.6741"/>
<Attribute type="derived" value="Point (913214.6741 5606017.8743)" name="geometry"/>
</Feature>
Expand Down
2 changes: 2 additions & 0 deletions tests/testdata/qgis_server/wms_getfeatureinfo_filter_or.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ Content-Type: text/xml; charset=utf-8
<Attribute value="2" name="id"/>
<Attribute value="two" name="name"/>
<Attribute value="two àò" name="utf8nameè"/>
<Attribute value="1" name="orig_ogc_fid"/>
<BoundingBox maxy="5606017.8743" maxx="913214.6741" miny="5606017.8743" CRS="EPSG:3857" minx="913214.6741"/>
<Attribute type="derived" value="Point (913214.6741 5606017.8743)" name="geometry"/>
</Feature>
<Feature id="2">
<Attribute value="3" name="id"/>
<Attribute value="three" name="name"/>
<Attribute value="three èé↓" name="utf8nameè"/>
<Attribute value="2" name="orig_ogc_fid"/>
<BoundingBox maxy="5606011.4565" maxx="913204.9128" miny="5606011.4565" CRS="EPSG:3857" minx="913204.9128"/>
<Attribute type="derived" value="Point (913204.9128 5606011.4565)" name="geometry"/>
</Feature>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ Content-Type: text/xml; charset=utf-8
<Attribute value="2" name="id"/>
<Attribute value="two" name="name"/>
<Attribute value="two àò" name="utf8nameè"/>
<Attribute value="1" name="orig_ogc_fid"/>
<BoundingBox maxy="5606017.8743" maxx="913214.6741" miny="5606017.8743" CRS="EPSG:3857" minx="913214.6741"/>
<Attribute type="derived" value="Point (913214.6741 5606017.8743)" name="geometry"/>
</Feature>
<Feature id="2">
<Attribute value="3" name="id"/>
<Attribute value="three" name="name"/>
<Attribute value="three èé↓" name="utf8nameè"/>
<Attribute value="2" name="orig_ogc_fid"/>
<BoundingBox maxy="5606011.4565" maxx="913204.9128" miny="5606011.4565" CRS="EPSG:3857" minx="913204.9128"/>
<Attribute type="derived" value="Point (913204.9128 5606011.4565)" name="geometry"/>
</Feature>
Expand Down

0 comments on commit dc6bdc2

Please sign in to comment.