|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +"""QGIS Unit tests for QgsServer Locale Override Options. |
| 3 | +
|
| 4 | +From build dir, run: ctest -R PyQgsServerLocaleOverride -V |
| 5 | +
|
| 6 | +.. note:: This test needs env vars to be set before the server is |
| 7 | + configured for the first time, for this |
| 8 | + reason it cannot run as a test case of another server |
| 9 | + test. |
| 10 | +
|
| 11 | +.. note:: This program is free software; you can redistribute it and/or modify |
| 12 | +it under the terms of the GNU General Public License as published by |
| 13 | +the Free Software Foundation; either version 2 of the License, or |
| 14 | +(at your option) any later version. |
| 15 | +
|
| 16 | +""" |
| 17 | +__author__ = 'Alessandro Pasotti' |
| 18 | +__date__ = '01/04/2019' |
| 19 | +__copyright__ = 'Copyright 2019, The QGIS Project' |
| 20 | +# This will get replaced with a git SHA1 when you do a git archive |
| 21 | +__revision__ = '$Format:%H$' |
| 22 | + |
| 23 | +import os |
| 24 | + |
| 25 | +# Needed on Qt 5 so that the serialization of XML is consistent among all |
| 26 | +# executions |
| 27 | +os.environ['QT_HASH_SEED'] = '1' |
| 28 | + |
| 29 | +from utilities import ( |
| 30 | + unitTestDataPath, |
| 31 | +) |
| 32 | +from qgis.testing import unittest |
| 33 | + |
| 34 | +from test_qgsserver_wms import TestQgsServerWMSTestBase |
| 35 | +from qgis.core import QgsProject, QgsFontUtils |
| 36 | +from qgis.server import QgsServer |
| 37 | + |
| 38 | + |
| 39 | +class TestQgsServerWMSLocaleOverride(TestQgsServerWMSTestBase): |
| 40 | + """QGIS Server WMS Tests for GetFeatureInfo request""" |
| 41 | + |
| 42 | + # Set to True to re-generate reference files for this class |
| 43 | + regenerate_reference = False |
| 44 | + |
| 45 | + def setUp(self): |
| 46 | + """Create the server instance""" |
| 47 | + self.fontFamily = QgsFontUtils.standardTestFontFamily() |
| 48 | + QgsFontUtils.loadStandardTestFonts(['All']) |
| 49 | + |
| 50 | + self.testdata_path = unitTestDataPath('qgis_server') + '/' |
| 51 | + |
| 52 | + d = unitTestDataPath('qgis_server') + '/' |
| 53 | + self.projectPath = os.path.join(d, "project.qgs") |
| 54 | + |
| 55 | + # Clean env just to be sure |
| 56 | + env_vars = ['QUERY_STRING', 'QGIS_PROJECT_FILE'] |
| 57 | + for ev in env_vars: |
| 58 | + try: |
| 59 | + del os.environ[ev] |
| 60 | + except KeyError: |
| 61 | + pass |
| 62 | + |
| 63 | + os.environ['QGIS_SERVER_OVERRIDE_SYSTEM_LOCALE'] = 'EN_us' |
| 64 | + os.environ['QGIS_SERVER_SHOW_GROUP_SEPARATOR'] = '0' |
| 65 | + |
| 66 | + self.server = QgsServer() |
| 67 | + |
| 68 | + def testGetFeatureInfoThousandSeparator(self): |
| 69 | + |
| 70 | + self.wms_request_compare('GetFeatureInfo', |
| 71 | + '&layers=testlayer_thousands&styles=&' + |
| 72 | + 'info_format=text%2Fxml&transparent=true&' + |
| 73 | + 'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' + |
| 74 | + '5606005.488876367%2C913235.426296057%2C5606035.347090538&' + |
| 75 | + 'query_layers=testlayer_thousands&X=190&Y=320', |
| 76 | + 'wms_getfeatureinfo-thousands-text-xml', |
| 77 | + project='test_project_gfi_thousands.qgs',) |
| 78 | + |
| 79 | + |
| 80 | +if __name__ == '__main__': |
| 81 | + unittest.main() |
0 commit comments