Skip to content
Permalink
Browse files

Add unit test with owslib to check GetCapabilities doc

  • Loading branch information
pblottiere committed Apr 13, 2018
1 parent 414f4fa commit 199f725d127fe280ba2007434a51cc90fa91a3f5
Showing with 22 additions and 0 deletions.
  1. +22 −0 tests/src/python/test_qgsserver_wms.py
@@ -31,6 +31,8 @@

import osgeo.gdal # NOQA

from owslib.wms import WebMapService

from test_qgsserver import QgsServerTestBase
from qgis.core import QgsProject

@@ -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.
You can’t perform that action at this time.