Skip to content

Commit bc4f72c

Browse files
committedJul 3, 2015
Merge pull request #2190 from elpaso/server-test-update
Fixed PyQgsServer tests.
2 parents 2083d6d + 132fa0d commit bc4f72c

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed
 

‎.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ before_script:
5858
- psql -c 'CREATE EXTENSION postgis;' -U postgres -d qgis_test
5959
- psql -f $TRAVIS_BUILD_DIR/tests/testdata/provider/testdata.sql -U postgres -d qgis_test
6060

61-
script: xvfb-run ctest -V -E 'qgis_openstreetmaptest|qgis_wcsprovidertest|PyQgsServer' -S ../qgis-test-travis.ctest --output-on-failure
61+
script: xvfb-run ctest -V -E 'qgis_openstreetmaptest|qgis_wcsprovidertest' -S ../qgis-test-travis.ctest --output-on-failure
6262

‎src/server/qgsserver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ bool QgsServer::init( int & argc, char ** argv )
396396

397397
QgsEditorWidgetRegistry::initEditors();
398398
mInitialised = TRUE;
399+
QgsMessageLog::logMessage( "Server intialised", "Server", QgsMessageLog::INFO );
399400
return TRUE;
400401
}
401402

‎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: 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: 5213
2+
Content-Length: 5250
33

44
<?xml version="1.0" encoding="utf-8"?>
55
<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">
@@ -37,6 +37,7 @@ 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>

‎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.