Skip to content
Permalink
Browse files

Fix test to use re instead of lxml (the simpler the better)

  • Loading branch information
elpaso committed Jan 22, 2019
1 parent 691176b commit eef7f49a210695516cda48e4b5f5cf0301654467
Showing with 4 additions and 13 deletions.
  1. +4 −13 tests/src/python/test_qgsserver_request.py
@@ -18,11 +18,10 @@


import os
import re
import unittest
from urllib.parse import parse_qs, urlencode, urlparse

from lxml import etree as ET

from qgis.PyQt.QtCore import QUrl
from qgis.server import (QgsBufferServerResponse, QgsFcgiServerRequest,
QgsServerRequest)
@@ -172,18 +171,10 @@ def _check_links(params, method='GET'):
self.assertTrue(original_url.startswith('http://www.myserver.com/aproject/'))
self.assertEqual(original_url.find(urlencode({'MAP': params['map']})), -1)

e = ET.fromstring(bytes(response.body()))
elems = []
for ns in ('wms', 'wfs', 'wcs'):
elems += e.xpath('//xxx:OnlineResource', namespaces={'xxx': 'http://www.opengis.net/%s' % ns})
elems += e.xpath('//ows:Get/ows:OnlineResource', namespaces={'ows': 'http://www.opengis.net/ows'})
elems += e.xpath('//ows:Post', namespaces={'ows': 'http://www.opengis.net/ows'})
elems += e.xpath('//ows:Get', namespaces={'ows': 'http://www.opengis.net/ows'})
elems += e.xpath('//ows:Get', namespaces={'ows': 'http://www.opengis.net/ows/1.1'})
exp = re.compile(r'href="([^"]+)"', re.DOTALL | re.MULTILINE)
elems = exp.findall(bytes(response.body()).decode('utf8'))
self.assertTrue(len(elems) > 0)
for _e in elems:
attrs = _e.attrib
href = attrs['{http://www.w3.org/1999/xlink}href']
for href in elems:
self.assertTrue(href.startswith('http://www.myserver.com/aproject/'))
self.assertEqual(href.find(urlencode({'MAP': params['map']})), -1)

0 comments on commit eef7f49

Please sign in to comment.
You can’t perform that action at this time.