Skip to content
Permalink
Browse files

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 bc4f72c7a700ea51b5b03ca48cdaa5ef5e1afb56
@@ -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

@@ -396,6 +396,7 @@ bool QgsServer::init( int & argc, char ** argv )

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

@@ -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,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">
@@ -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>
@@ -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 bc4f72c

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