Skip to content

Commit

Permalink
Add unit tests with owslib
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed May 4, 2018
1 parent e290aa5 commit b6aaf8d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .docker/qgis3-build-deps.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ RUN apt-get update \
mock \
future \
termcolor \
&& apt-get autoremove -y python3-pip \
owslib \
&& apt-get clean

RUN echo "alias python=python3" >> ~/.bash_aliases
Expand Down
22 changes: 22 additions & 0 deletions tests/src/python/test_qgsserver_wms.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

import osgeo.gdal # NOQA

from owslib.wms import WebMapService

from test_qgsserver import QgsServerTestBase
from qgis.core import QgsProject

Expand Down Expand Up @@ -395,6 +397,26 @@ def test_wms_GetProjectSettings_wms_print_layers(self):
self.assertTrue(xmlResult.find("<WMSDataSource>contextualWMSLegend=0&amp;crs=EPSG:21781&amp;dpiMode=7&amp;featureCount=10&amp;format=image/png&amp;layers=public_geo_gemeinden&amp;styles=&amp;url=https://qgiscloud.com/mhugent/qgis_unittest_wms/wms?</WMSDataSource>") != -1)
self.assertTrue(xmlResult.find("<WMSPrintLayer>contextualWMSLegend=0&amp;amp;crs=EPSG:21781&amp;amp;dpiMode=7&amp;amp;featureCount=10&amp;amp;format=image/png&amp;amp;layers=public_geo_gemeinden&amp;amp;styles=&amp;amp;url=https://qgiscloud.com/mhugent/qgis_unittest_wms_print/wms?</WMSPrintLayer>") != -1)

def test_getcapabilities_owslib(self):

# read getcapabilities document
docPath = self.testdata_path + 'getcapabilities.txt'
f = open(docPath, 'r')
doc = f.read()
f.close()

# clean header in doc
doc = doc.replace('Content-Length: 5775\n', '')
doc = doc.replace('Content-Type: text/xml; charset=utf-8\n\n', '')
doc = doc.replace('<?xml version="1.0" encoding="utf-8"?>\n', '')

# read capabilities document with owslib
w = WebMapService(None, xml=doc, version='1.3.0')

# check root layer name
rootLayerName = 'QGIS Test Project'
self.assertTrue(rootLayerName in w.contents.keys())


if __name__ == '__main__':
unittest.main()
1 change: 0 additions & 1 deletion tests/testdata/qgis_server/getcapabilities.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ Content-Type: text/xml; charset=utf-8
<KeywordList>
<Keyword vocabulary="ISO">infoMapAccessService</Keyword>
</KeywordList>
<MetadataURL/>
<Layer queryable="1">
<Name>testlayer èé</Name>
<Title>A test vector layer</Title>
Expand Down
1 change: 0 additions & 1 deletion tests/testdata/qgis_server/getcapabilities_inspire.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ Content-Type: text/xml; charset=utf-8
<KeywordList>
<Keyword vocabulary="ISO">infoMapAccessService</Keyword>
</KeywordList>
<MetadataURL/>
<Layer queryable="1">
<Name>testlayer èé</Name>
<Title>A test vector layer</Title>
Expand Down
1 change: 0 additions & 1 deletion tests/testdata/qgis_server/getprojectsettings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ Content-Type: text/xml; charset=utf-8
<KeywordList>
<Keyword vocabulary="ISO">infoMapAccessService</Keyword>
</KeywordList>
<MetadataURL/>
<TreeName>QGIS Test Project</TreeName>
<Layer geometryType="Point" queryable="1" displayField="name" visible="1">
<Name>testlayer èé</Name>
Expand Down

0 comments on commit b6aaf8d

Please sign in to comment.