Skip to content

Commit

Permalink
Add unit test with owslib to check GetCapabilities doc
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Apr 13, 2018
1 parent 414f4fa commit 199f725
Showing 1 changed file with 22 additions and 0 deletions.
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 @@ -216,6 +218,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 content
rootLayerName = 'QGIS Test Project'
self.assertTrue(rootLayerName in w.contents.keys())


if __name__ == '__main__':
unittest.main()

0 comments on commit 199f725

Please sign in to comment.