Skip to content

Commit

Permalink
Fix test to use re instead of lxml (the simpler the better)
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Jan 22, 2019
1 parent 691176b commit eef7f49
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions tests/src/python/test_qgsserver_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit eef7f49

Please sign in to comment.