Skip to content

Commit

Permalink
Fixed PyQgsServer tests.
Browse files Browse the repository at this point in the history
Still disabled in Travis because of random failures
  • Loading branch information
elpaso committed Jul 3, 2015
1 parent 2083d6d commit 11a7522
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
16 changes: 12 additions & 4 deletions tests/src/python/test_qgsserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -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)


Expand All @@ -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):
Expand Down
19 changes: 10 additions & 9 deletions tests/testdata/qgis_server/getcapabilities.txt
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
3 changes: 2 additions & 1 deletion tests/testdata/qgis_server/getprojectsettings.txt
Original file line number Diff line number Diff line change
@@ -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">
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 11a7522

Please sign in to comment.