Skip to content

Commit 11a7522

Browse files
committedJul 3, 2015
Fixed PyQgsServer tests.
Still disabled in Travis because of random failures
1 parent 2083d6d commit 11a7522

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed
 

‎tests/src/python/test_qgsserver.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
from utilities import unitTestDataPath
2222

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

2726
class TestQgsServer(unittest.TestCase):
2827

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

104103

@@ -109,9 +108,18 @@ def wms_request_compare(self, request):
109108
f = open(self.testdata_path + request.lower() + '.txt')
110109
expected = f.read()
111110
f.close()
111+
# Store for debug or to regenerate the reference documents:
112+
"""
113+
f = open(os.path.dirname(__file__) + '/expected.txt', 'w+')
114+
f.write(expected)
115+
f.close()
116+
f = open(os.path.dirname(__file__) + '/response.txt', 'w+')
117+
f.write(response)
118+
f.close()
119+
"""
112120
response = re.sub(RE_STRIP_PATH, '', response)
113121
expected = re.sub(RE_STRIP_PATH, '', expected)
114-
self.assertEqual(response, expected, msg="request %s failed" % request)
122+
self.assertEqual(response, expected, msg="request %s failed. Expected:\n%s\n\nResponse:\n%s" % (request, expected, response))
115123

116124

117125
def test_project_wms(self):

‎tests/testdata/qgis_server/getcapabilities.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Content-Type: text/xml; charset=utf-8
2-
Content-Length: 5213
2+
Content-Length: 4685
33

44
<?xml version="1.0" encoding="utf-8"?>
5-
<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">
5+
<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">
66
<Service>
77
<Name>WMS</Name>
88
<Title>QGIS TestProject</Title>
@@ -26,7 +26,7 @@ Content-Length: 5213
2626
<DCPType>
2727
<HTTP>
2828
<Get>
29-
<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;"/>
29+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?"/>
3030
</Get>
3131
</HTTP>
3232
</DCPType>
@@ -37,10 +37,11 @@ Content-Length: 5213
3737
<Format>image/png; mode=16bit</Format>
3838
<Format>image/png; mode=8bit</Format>
3939
<Format>image/png; mode=1bit</Format>
40+
<Format>application/dxf</Format>
4041
<DCPType>
4142
<HTTP>
4243
<Get>
43-
<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;"/>
44+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?"/>
4445
</Get>
4546
</HTTP>
4647
</DCPType>
@@ -54,7 +55,7 @@ Content-Length: 5213
5455
<DCPType>
5556
<HTTP>
5657
<Get>
57-
<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;"/>
58+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?"/>
5859
</Get>
5960
</HTTP>
6061
</DCPType>
@@ -65,7 +66,7 @@ Content-Length: 5213
6566
<DCPType>
6667
<HTTP>
6768
<Get>
68-
<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;"/>
69+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?"/>
6970
</Get>
7071
</HTTP>
7172
</DCPType>
@@ -75,7 +76,7 @@ Content-Length: 5213
7576
<DCPType>
7677
<HTTP>
7778
<Get>
78-
<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;"/>
79+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?"/>
7980
</Get>
8081
</HTTP>
8182
</DCPType>
@@ -85,7 +86,7 @@ Content-Length: 5213
8586
<DCPType>
8687
<HTTP>
8788
<Get>
88-
<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;"/>
89+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?"/>
8990
</Get>
9091
</HTTP>
9192
</DCPType>
@@ -124,7 +125,7 @@ Content-Length: 5213
124125
<Title>default</Title>
125126
<LegendURL>
126127
<Format>image/png</Format>
127-
<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"/>
128+
<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"/>
128129
</LegendURL>
129130
</Style>
130131
</Layer>

‎tests/testdata/qgis_server/getprojectsettings.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Content-Type: text/xml; charset=utf-8
2-
Content-Length: 6231
2+
Content-Length: 6268
33

44
<?xml version="1.0" encoding="utf-8"?>
55
<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
3737
<Format>image/png; mode=16bit</Format>
3838
<Format>image/png; mode=8bit</Format>
3939
<Format>image/png; mode=1bit</Format>
40+
<Format>application/dxf</Format>
4041
<DCPType>
4142
<HTTP>
4243
<Get>

0 commit comments

Comments
 (0)
Please sign in to comment.