Skip to content

Commit

Permalink
Isolate test_wms_getprint_atlas
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Jun 25, 2020
1 parent 89ccc77 commit c223130
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 26 deletions.
1 change: 1 addition & 0 deletions tests/src/python/CMakeLists.txt
Expand Up @@ -360,6 +360,7 @@ IF (WITH_SERVER)
ADD_PYTHON_TEST(PyQgsServerWMSGetLegendGraphic test_qgsserver_wms_getlegendgraphic.py)
ADD_PYTHON_TEST(PyQgsServerWMSGetPrint test_qgsserver_wms_getprint.py)
ADD_PYTHON_TEST(PyQgsServerWMSGetPrintOutputs test_qgsserver_wms_getprint_outputs.py)
ADD_PYTHON_TEST(PyQgsServerWMSGetPrintAtlas test_qgsserver_wms_getprint_atlas.py)
ADD_PYTHON_TEST(PyQgsServerWMSDimension test_qgsserver_wms_dimension.py)
ADD_PYTHON_TEST(PyQgsServerSettings test_qgsserver_settings.py)
ADD_PYTHON_TEST(PyQgsServerProjectUtils test_qgsserver_projectutils.py)
Expand Down
26 changes: 0 additions & 26 deletions tests/src/python/test_qgsserver_wms_getprint.py
Expand Up @@ -444,32 +444,6 @@ def test_wms_getprint_two_maps(self):
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetPrint_TwoMaps")

def test_wms_getprint_atlas(self):
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
"SERVICE": "WMS",
"VERSION": "1.3.0",
"REQUEST": "GetPrint",
"TEMPLATE": "layoutA4",
"FORMAT": "png",
"CRS": "EPSG:3857",
"ATLAS_PK": "3",
"map0:LAYERS": "Country,Hello",
}.items())])
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetPrint_Atlas")

def test_wms_getprint_atlas_getProjectSettings(self):
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
"SERVICE": "WMS",
"VERSION": "1.3.0",
"REQUEST": "GetProjectSettings",
}.items())])
r, h = self._result(self._execute_request(qs))
self.assertTrue('atlasEnabled="1"' in str(r))
self.assertTrue('<PrimaryKeyAttribute>' in str(r))

@unittest.skipIf(os.environ.get('TRAVIS', '') == 'true',
'Can\'t rely on external resources for continuous integration')
def test_wms_getprint_external(self):
Expand Down
60 changes: 60 additions & 0 deletions tests/src/python/test_qgsserver_wms_getprint_atlas.py
@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
"""QGIS Unit tests for QgsServer WMS GetPrint.
From build dir, run: ctest -R PyQgsServerWMSGetPrintAtlas -V
.. note:: This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
"""
__author__ = 'René-Luc DHONT'
__date__ = '24/06/2020'
__copyright__ = 'Copyright 2020, The QGIS Project'

import os

# Needed on Qt 5 so that the serialization of XML is consistent among all executions
os.environ['QT_HASH_SEED'] = '1'

import urllib.parse

from qgis.testing import unittest

from test_qgsserver import QgsServerTestBase


class TestQgsServerWMSGetPrintAtlas(QgsServerTestBase):
"""QGIS Server WMS Tests for GetPrint atlas request"""

def test_wms_getprint_atlas(self):
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
"SERVICE": "WMS",
"VERSION": "1.3.0",
"REQUEST": "GetPrint",
"TEMPLATE": "layoutA4",
"FORMAT": "png",
"CRS": "EPSG:3857",
"ATLAS_PK": "3",
"map0:LAYERS": "Country,Hello",
}.items())])
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetPrint_Atlas")

def test_wms_getprint_atlas_getProjectSettings(self):
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
"SERVICE": "WMS",
"VERSION": "1.3.0",
"REQUEST": "GetProjectSettings",
}.items())])
r, h = self._result(self._execute_request(qs))
self.assertTrue('atlasEnabled="1"' in str(r))
self.assertTrue('<PrimaryKeyAttribute>' in str(r))


if __name__ == '__main__':
unittest.main()

0 comments on commit c223130

Please sign in to comment.