|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +"""QGIS Unit tests for the MS SQL provider. |
| 3 | +
|
| 4 | +.. note:: This program is free software; you can redistribute it and/or modify |
| 5 | +it under the terms of the GNU General Public License as published by |
| 6 | +the Free Software Foundation; either version 2 of the License, or |
| 7 | +(at your option) any later version. |
| 8 | +""" |
| 9 | +__author__ = 'Nyall Dawson' |
| 10 | +__date__ = '2015-12-07' |
| 11 | +__copyright__ = 'Copyright 2015, The QGIS Project' |
| 12 | +# This will get replaced with a git SHA1 when you do a git archive |
| 13 | +__revision__ = '$Format:%H$' |
| 14 | + |
| 15 | +import qgis |
| 16 | +import os |
| 17 | +import sys |
| 18 | +from qgis.core import NULL |
| 19 | + |
| 20 | +from qgis.core import QgsVectorLayer, QgsFeatureRequest, QgsFeature, QgsProviderRegistry |
| 21 | +from PyQt4.QtCore import QSettings |
| 22 | +from utilities import (unitTestDataPath, |
| 23 | + getQgisTestApp, |
| 24 | + unittest, |
| 25 | + TestCase |
| 26 | + ) |
| 27 | +from providertestbase import ProviderTestCase |
| 28 | + |
| 29 | +QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp() |
| 30 | +TEST_DATA_DIR = unitTestDataPath() |
| 31 | + |
| 32 | + |
| 33 | +class TestPyQgsMssqlProvider(TestCase, ProviderTestCase): |
| 34 | + |
| 35 | + @classmethod |
| 36 | + def setUpClass(cls): |
| 37 | + """Run before all tests""" |
| 38 | + cls.dbconn = u"dbname='gis' host=localhost\sqlexpress" |
| 39 | + if 'QGIS_MSSQLTEST_DB' in os.environ: |
| 40 | + cls.dbconn = os.environ['QGIS_MSSQLTEST_DB'] |
| 41 | + # Create test layer |
| 42 | + cls.vl = QgsVectorLayer(cls.dbconn + ' sslmode=disable key=\'pk\' srid=4326 type=POINT table="qgis_test"."someData" (geom) sql=', 'test', 'mssql') |
| 43 | + assert(cls.vl.isValid()) |
| 44 | + cls.provider = cls.vl.dataProvider() |
| 45 | + |
| 46 | + @classmethod |
| 47 | + def tearDownClass(cls): |
| 48 | + """Run after all tests""" |
| 49 | + |
| 50 | + def enableCompiler(self): |
| 51 | + QSettings().setValue(u'/qgis/compileExpressions', True) |
| 52 | + |
| 53 | + def disableCompiler(self): |
| 54 | + QSettings().setValue(u'/qgis/compileExpressions', False) |
| 55 | + |
| 56 | +if __name__ == '__main__': |
| 57 | + unittest.main() |
0 commit comments