Skip to content
Permalink
Browse files

Fixed PyQgsServer tests.

Still disabled in Travis because of random failures
  • Loading branch information
elpaso committed Jul 2, 2015
1 parent 2083d6d commit 11a7522d9fe2869ae3ed63a2bd2d914cbf0345cb
@@ -21,8 +21,7 @@
from utilities import unitTestDataPath

# Strip path and content length because path may vary
RE_STRIP_PATH=r'MAP=[^&]+(&)*|Content-Length: \d+'

RE_STRIP_PATH=r'MAP=[^&]+|Content-Length: \d+'

class TestQgsServer(unittest.TestCase):

@@ -98,7 +97,7 @@ def responseComplete(self):
serverIface = self.server.serverInterface()
serverIface.registerFilter(SimpleHelloFilter(serverIface), 100 )
response = str(self.server.handleRequest('service=simple'))
expected = 'Content-type: text/plain\n\n\nHello from SimpleServer!'
expected = 'Content-type: text/plain\n\nHello from SimpleServer!'
self.assertEqual(response, expected)


@@ -109,9 +108,18 @@ def wms_request_compare(self, request):
f = open(self.testdata_path + request.lower() + '.txt')
expected = f.read()
f.close()
# Store for debug or to regenerate the reference documents:
"""
f = open(os.path.dirname(__file__) + '/expected.txt', 'w+')
f.write(expected)
f.close()
f = open(os.path.dirname(__file__) + '/response.txt', 'w+')
f.write(response)
f.close()
"""
response = re.sub(RE_STRIP_PATH, '', response)
expected = re.sub(RE_STRIP_PATH, '', expected)
self.assertEqual(response, expected, msg="request %s failed" % request)
self.assertEqual(response, expected, msg="request %s failed. Expected:\n%s\n\nResponse:\n%s" % (request, expected, response))


def test_project_wms(self):
@@ -1,8 +1,8 @@
Content-Type: text/xml; charset=utf-8
Content-Length: 5213
Content-Length: 4685

<?xml version="1.0" encoding="utf-8"?>
<WMS_Capabilities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.3" xmlns="http://www.opengis.net/wms" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd http://www.qgis.org/wms http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/testproject.qgs&amp;SERVICE=WMS&amp;REQUEST=GetSchemaExtension" xmlns:sld="http://www.opengis.net/sld" xmlns:qgs="http://www.qgis.org/wms">
<WMS_Capabilities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.3" xmlns="http://www.opengis.net/wms" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd http://www.qgis.org/wms http:?SERVICE=WMS&amp;REQUEST=GetSchemaExtension" xmlns:sld="http://www.opengis.net/sld" xmlns:qgs="http://www.qgis.org/wms">
<Service>
<Name>WMS</Name>
<Title>QGIS TestProject</Title>
@@ -26,7 +26,7 @@ Content-Length: 5213
<DCPType>
<HTTP>
<Get>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/testproject.qgs&amp;"/>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?"/>
</Get>
</HTTP>
</DCPType>
@@ -37,10 +37,11 @@ Content-Length: 5213
<Format>image/png; mode=16bit</Format>
<Format>image/png; mode=8bit</Format>
<Format>image/png; mode=1bit</Format>
<Format>application/dxf</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/testproject.qgs&amp;"/>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?"/>
</Get>
</HTTP>
</DCPType>
@@ -54,7 +55,7 @@ Content-Length: 5213
<DCPType>
<HTTP>
<Get>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/testproject.qgs&amp;"/>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?"/>
</Get>
</HTTP>
</DCPType>
@@ -65,7 +66,7 @@ Content-Length: 5213
<DCPType>
<HTTP>
<Get>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/testproject.qgs&amp;"/>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?"/>
</Get>
</HTTP>
</DCPType>
@@ -75,7 +76,7 @@ Content-Length: 5213
<DCPType>
<HTTP>
<Get>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/testproject.qgs&amp;"/>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?"/>
</Get>
</HTTP>
</DCPType>
@@ -85,7 +86,7 @@ Content-Length: 5213
<DCPType>
<HTTP>
<Get>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/testproject.qgs&amp;"/>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?"/>
</Get>
</HTTP>
</DCPType>
@@ -124,7 +125,7 @@ Content-Length: 5213
<Title>default</Title>
<LegendURL>
<Format>image/png</Format>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/testproject.qgs&amp;&amp;SERVICE=WMS&amp;VERSION=1.3&amp;REQUEST=GetLegendGraphic&amp;LAYER=testlayer èé&amp;FORMAT=image/png&amp;STYLE=default"/>
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?SERVICE=WMS&amp;VERSION=1.3&amp;REQUEST=GetLegendGraphic&amp;LAYER=testlayer èé&amp;FORMAT=image/png&amp;STYLE=default"/>
</LegendURL>
</Style>
</Layer>
@@ -1,5 +1,5 @@
Content-Type: text/xml; charset=utf-8
Content-Length: 6231
Content-Length: 6268

<?xml version="1.0" encoding="utf-8"?>
<WMS_Capabilities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.3.0" xmlns="http://www.opengis.net/wms" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd http://www.qgis.org/wms http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/testproject.qgs&amp;SERVICE=WMS&amp;REQUEST=GetSchemaExtension" xmlns:sld="http://www.opengis.net/sld" xmlns:qgs="http://www.qgis.org/wms">
@@ -37,6 +37,7 @@ Content-Length: 6231
<Format>image/png; mode=16bit</Format>
<Format>image/png; mode=8bit</Format>
<Format>image/png; mode=1bit</Format>
<Format>application/dxf</Format>
<DCPType>
<HTTP>
<Get>

0 comments on commit 11a7522

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