Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2190 from elpaso/server-test-update
Fixed PyQgsServer tests.
  • Loading branch information
jef-n committed Jul 3, 2015
2 parents 2083d6d + 132fa0d commit bc4f72c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -58,5 +58,5 @@ before_script:
- psql -c 'CREATE EXTENSION postgis;' -U postgres -d qgis_test
- psql -f $TRAVIS_BUILD_DIR/tests/testdata/provider/testdata.sql -U postgres -d qgis_test

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

1 change: 1 addition & 0 deletions src/server/qgsserver.cpp
Expand Up @@ -396,6 +396,7 @@ bool QgsServer::init( int & argc, char ** argv )

QgsEditorWidgetRegistry::initEditors();
mInitialised = TRUE;
QgsMessageLog::logMessage( "Server intialised", "Server", QgsMessageLog::INFO );
return TRUE;
}

Expand Down
16 changes: 12 additions & 4 deletions tests/src/python/test_qgsserver.py
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
3 changes: 2 additions & 1 deletion tests/testdata/qgis_server/getcapabilities.txt
@@ -1,5 +1,5 @@
Content-Type: text/xml; charset=utf-8
Content-Length: 5213
Content-Length: 5250

<?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">
Expand Down Expand Up @@ -37,6 +37,7 @@ 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>
Expand Down
3 changes: 2 additions & 1 deletion tests/testdata/qgis_server/getprojectsettings.txt
@@ -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 bc4f72c

Please sign in to comment.