Skip to content

Commit

Permalink
test for dxf export with reverse axis projections
Browse files Browse the repository at this point in the history
add test
  • Loading branch information
tudorbarascu committed Jan 28, 2021
1 parent 67bdbcf commit 0b19545
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/src/python/CMakeLists.txt
Expand Up @@ -408,6 +408,7 @@ if (WITH_SERVER)
ADD_PYTHON_TEST(PyQgsServerLandingPage test_qgsserver_landingpage.py)
ADD_PYTHON_TEST(PyQgsServerApiContext test_qgsserver_apicontext.py)
ADD_PYTHON_TEST(PyQgsServerWMSGetMap test_qgsserver_wms_getmap.py)
ADD_PYTHON_TEST(PyQgsServerWMSGetMapDxf test_qgsserver_wms_dxf.py)
ADD_PYTHON_TEST(PyQgsServerWMSGetMapSizeProject test_qgsserver_wms_getmap_size_project.py)
ADD_PYTHON_TEST(PyQgsServerWMSGetMapSizeServer test_qgsserver_wms_getmap_size_server.py)
ADD_PYTHON_TEST(PyQgsServerWMSGetMapIgnoreBadLayers test_qgsserver_wms_getmap_ignore_bad_layers.py)
Expand Down
69 changes: 69 additions & 0 deletions tests/src/python/test_qgsserver_wms_dxf.py
@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
"""QGIS Unit tests for QgsServer WMS GetPrint.
From build dir, run: ctest -R PyQgsServerWMSGetMapDxf -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__ = 'Tudor Bărăscu'
__date__ = '27/01/2021'
__copyright__ = 'Copyright 2020, The QGIS Project'

import os

import urllib.parse

from qgis.testing import unittest

from test_qgsserver import QgsServerTestBase

from qgis.core import (QgsVectorLayer)

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


class PyQgsServerWMSGetMapDxf(QgsServerTestBase):

def test_dxf_export_works_with_reverse_axis_epsg(self):
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(os.path.join(self.testdata_path,
'test_dxf_export.qgs')),
"SERVICE": "WMS",
"VERSION": "1.3.0",
"REQUEST": "GetMap",
"BBOX": "399980,449980,400050,450100",
"CRS": "EPSG:3844",
"LAYERS": "test_dxf_export",
"STYLES": ",",
"FORMAT": "application/dxf",
"SCALE": "500",
"FILE_NAME": "test_dxf_export.dxf"
}.items())])

r, h = self._result(self._execute_request(qs))

dxf = '/tmp/test_dxf_export.dxf'
f = open(dxf, 'wb')
f.write(r)
f.close()

vl = QgsVectorLayer(dxf, "lyr", "ogr")
myMessage = ('Expected downloaded: %s dxf contains 1 line\nGot: %s\n' %
(1, vl.featureCount()))

assert vl.featureCount() == 1, myMessage

line_from_dxf = next(vl.getFeatures()).geometry().asWkt()
line = 'LineString (450000 400000, 450100 400000)'

self.assertEqual(line_from_dxf, line)


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

0 comments on commit 0b19545

Please sign in to comment.