-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[oracle] Implement provider test suite
On behalf of Faunalia, sponsored by ENEL (cherry-picked from 38e65c3)
- Loading branch information
1 parent
012a29d
commit 01f61c5
Showing
3 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# -*- coding: utf-8 -*- | ||
"""QGIS Unit tests for the Oracle provider. | ||
.. 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__ = 'Nyall Dawson' | ||
__date__ = '2016-07-06' | ||
__copyright__ = 'Copyright 2016, The QGIS Project' | ||
# This will get replaced with a git SHA1 when you do a git archive | ||
__revision__ = '$Format:%H$' | ||
|
||
import qgis # NOQA | ||
|
||
import os | ||
|
||
from qgis.core import QgsVectorLayer, QgsFeatureRequest | ||
|
||
from qgis.PyQt.QtCore import QSettings, QDate, QTime, QDateTime, QVariant | ||
|
||
from utilities import unitTestDataPath | ||
from qgis.testing import start_app, unittest | ||
from providertestbase import ProviderTestCase | ||
|
||
start_app() | ||
TEST_DATA_DIR = unitTestDataPath() | ||
|
||
|
||
class TestPyQgsOracleProvider(unittest.TestCase, ProviderTestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
"""Run before all tests""" | ||
cls.dbconn = u"host=localhost port=1521 user='QGIS' password='qgis'" | ||
if 'QGIS_ORACLETEST_DB' in os.environ: | ||
cls.dbconn = os.environ['QGIS_ORACLETEST_DB'] | ||
# Create test layers | ||
cls.vl = QgsVectorLayer( | ||
cls.dbconn + ' sslmode=disable key=\'pk\' srid=4326 type=POINT table="QGIS"."SOME_DATA" (GEOM) sql=', 'test', 'oracle') | ||
assert(cls.vl.isValid()) | ||
cls.provider = cls.vl.dataProvider() | ||
cls.poly_vl = QgsVectorLayer( | ||
cls.dbconn + ' sslmode=disable key=\'pk\' srid=4326 type=POLYGON table="QGIS"."SOME_POLY_DATA" (GEOM) sql=', 'test', 'oracle') | ||
assert(cls.poly_vl.isValid()) | ||
cls.poly_provider = cls.poly_vl.dataProvider() | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
"""Run after all tests""" | ||
|
||
def enableCompiler(self): | ||
QSettings().setValue(u'/qgis/compileExpressions', True) | ||
|
||
def disableCompiler(self): | ||
QSettings().setValue(u'/qgis/compileExpressions', False) | ||
|
||
def uncompiledFilters(self): | ||
filters = set([ | ||
'(name = \'Apple\') is not null', | ||
'"name" || \' \' || "name" = \'Orange Orange\'', | ||
'"name" || \' \' || "cnt" = \'Orange 100\'', | ||
'\'x\' || "name" IS NOT NULL', | ||
'\'x\' || "name" IS NULL', | ||
'false and NULL', | ||
'true and NULL', | ||
'NULL and false', | ||
'NULL and true', | ||
'NULL and NULL', | ||
'false or NULL', | ||
'true or NULL', | ||
'NULL or false', | ||
'NULL or true', | ||
'NULL or NULL', | ||
'not null', | ||
'intersects($geometry,geom_from_wkt( \'Polygon ((-72.2 66.1, -65.2 66.1, -65.2 72.0, -72.2 72.0, -72.2 66.1))\'))']) | ||
return filters | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
CREATE TABLE QGIS.SOME_DATA ( "pk" INTEGER PRIMARY KEY, "cnt" INTEGER, "name" VARCHAR2(100) DEFAULT 'qgis', "name2" VARCHAR2(100) DEFAULT 'qgis', "num_char" VARCHAR2(100), GEOM SDO_GEOMETRY); | ||
|
||
INSERT INTO QGIS.SOME_DATA ("pk", "cnt", "name", "name2", "num_char", GEOM) | ||
SELECT 5, -200, NULL, 'NuLl', '5', SDO_GEOMETRY( 2001,4326,SDO_POINT_TYPE(-71.123, 78.23, NULL), NULL, NULL) from dual | ||
UNION ALL SELECT 3, 300, 'Pear', 'PEaR', '3', NULL from dual | ||
UNION ALL SELECT 1, 100, 'Orange', 'oranGe', '1', SDO_GEOMETRY( 2001,4326,SDO_POINT_TYPE(-70.332, 66.33, NULL), NULL, NULL) from dual | ||
UNION ALL SELECT 2, 200, 'Apple', 'Apple', '2', SDO_GEOMETRY( 2001,4326,SDO_POINT_TYPE(-68.2, 70.8, NULL), NULL, NULL) from dual | ||
UNION ALL SELECT 4, 400, 'Honey', 'Honey', '4', SDO_GEOMETRY( 2001,4326,SDO_POINT_TYPE(-65.32, 78.3, NULL), NULL, NULL) from dual; | ||
|
||
INSERT INTO user_sdo_geom_metadata (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES ( 'SOME_DATA', 'GEOM', sdo_dim_array(sdo_dim_element('X',-75,-55,0.005),sdo_dim_element('Y',65,85,0.005)),4326); | ||
|
||
CREATE INDEX some_data_spatial_idx ON QGIS.SOME_DATA(GEOM) INDEXTYPE IS MDSYS.SPATIAL_INDEX; | ||
|
||
CREATE TABLE QGIS.SOME_POLY_DATA ( "pk" INTEGER PRIMARY KEY, GEOM SDO_GEOMETRY); | ||
|
||
INSERT INTO QGIS.SOME_POLY_DATA ("pk", GEOM) | ||
SELECT 1, SDO_GEOMETRY( 2003,4326,NULL, SDO_ELEM_INFO_ARRAY(1,1003,1), SDO_ORDINATE_ARRAY(-69.0,81.4 , -69.0,80.2 , -73.7,80.2 , -73.7,76.3 , -74.9,76.3 , -74.9,81.4 , -69.0,81.4)) from dual | ||
UNION ALL SELECT 2, SDO_GEOMETRY( 2003,4326,NULL, SDO_ELEM_INFO_ARRAY(1,1003,1), SDO_ORDINATE_ARRAY(-67.6,81.2 , -66.3,81.2 , -66.3,76.9 , -67.6,76.9 , -67.6,81.2))from dual | ||
UNION ALL SELECT 3, SDO_GEOMETRY( 2003,4326,NULL, SDO_ELEM_INFO_ARRAY(1,1003,1), SDO_ORDINATE_ARRAY(-68.4,75.8 , -67.5,72.6 , -68.6,73.7 , -70.2,72.9 , -68.4,75.8)) from dual | ||
UNION ALL SELECT 4, NULL from dual; | ||
|
||
|
||
INSERT INTO user_sdo_geom_metadata (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES ( 'SOME_POLY_DATA', 'GEOM', sdo_dim_array(sdo_dim_element('X',-80,-55,0.005),sdo_dim_element('Y',65,85,0.005)),4326); | ||
|
||
CREATE INDEX some_poly_data_spatial_idx ON QGIS.SOME_POLY_DATA(GEOM) INDEXTYPE IS MDSYS.SPATIAL_INDEX; | ||
|