Skip to content

Commit 199f725

Browse files
committed
Add unit test with owslib to check GetCapabilities doc
1 parent 414f4fa commit 199f725

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/src/python/test_qgsserver_wms.py

+22
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
import osgeo.gdal # NOQA
3333

34+
from owslib.wms import WebMapService
35+
3436
from test_qgsserver import QgsServerTestBase
3537
from qgis.core import QgsProject
3638

@@ -216,6 +218,26 @@ def test_wms_GetProjectSettings_wms_print_layers(self):
216218
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)
217219
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)
218220

221+
def test_getcapabilities_owslib(self):
222+
223+
# read getcapabilities document
224+
docPath = self.testdata_path + 'getcapabilities.txt'
225+
f = open(docPath, 'r')
226+
doc = f.read()
227+
f.close()
228+
229+
# clean header in doc
230+
doc = doc.replace('Content-Length: 5775\n', '')
231+
doc = doc.replace('Content-Type: text/xml; charset=utf-8\n\n', '')
232+
doc = doc.replace('<?xml version="1.0" encoding="utf-8"?>\n', '')
233+
234+
# read capabilities document with owslib
235+
w = WebMapService(None, xml=doc, version='1.3.0')
236+
237+
# check content
238+
rootLayerName = 'QGIS Test Project'
239+
self.assertTrue(rootLayerName in w.contents.keys())
240+
219241

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

0 commit comments

Comments
 (0)