Skip to content

Commit

Permalink
Comment Oracle failing test when proj < 7
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 committed Mar 22, 2021
1 parent fe62553 commit 9c6b7e8
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions tests/src/python/test_provider_oracle.py
Expand Up @@ -28,7 +28,8 @@
QgsVectorLayerExporter,
QgsField,
QgsFields,
QgsCoordinateReferenceSystem
QgsCoordinateReferenceSystem,
QgsProjUtils
)

from qgis.PyQt.QtCore import QDate, QTime, QDateTime, QVariant
Expand Down Expand Up @@ -188,6 +189,15 @@ def testAddFeatureWrongGeomType(self):
"""
pass

def testCrs(self):
"""
We override this test for Oracle provider, because without PROJ >= 7
Oracle is not able to understand correctly some EPSG code (4326 for instance)
"""
# TODO remove this when PROJ will be >= 7
if QgsProjUtils.projVersionMajor() >= 7:
super().testCrs()

# HERE GO THE PROVIDER SPECIFIC TESTS
def testDateTimeTypes(self):
vl = QgsVectorLayer('%s table="QGIS"."DATE_TIMES" sql=' %
Expand Down Expand Up @@ -842,7 +852,10 @@ def testCreateEmptyLayer(self):
self.assertTrue(query.exec_("SELECT column_name, srid FROM user_sdo_geom_metadata WHERE table_name = 'EMPTY_LAYER'"))
self.assertTrue(query.next())
self.assertEqual(query.value(0), "GEOM")
self.assertEqual(query.value(1), 4326)
# Cannot work with proj version < 7 because it cannot identify properly EPSG:4326
# TODO remove this when PROJ will be >= 7
if QgsProjUtils.projVersionMajor() >= 7:
self.assertEqual(query.value(1), 4326)
query.finish()

# no feature, so we cannot guess the geometry type, so the layer is not valid
Expand All @@ -864,13 +877,19 @@ def testCreateEmptyLayer(self):
query = QSqlQuery(self.conn)
self.assertTrue(query.exec_('SELECT "l"."GEOM"."SDO_SRID" from "QGIS"."EMPTY_LAYER" "l"'))
self.assertTrue(query.next())
self.assertEqual(query.value(0), 4326)
# Cannot work with proj version < 7 because it cannot identify properly EPSG:4326
# TODO remove this when PROJ will be >= 7
if QgsProjUtils.projVersionMajor() >= 7:
self.assertEqual(query.value(0), 4326)
query.finish()

# now we can autodetect geom type and srid
vl = QgsVectorLayer(self.dbconn + ' sslmode=disable table="QGIS"."EMPTY_LAYER" (GEOM) sql=', 'test', 'oracle')
self.assertTrue(vl.isValid())
self.assertEqual(vl.sourceCrs().authid(), "EPSG:4326")
# Cannot work with proj version < 7 because it cannot identify properly EPSG:4326
# TODO remove this when PROJ will be >= 7
if QgsProjUtils.projVersionMajor() >= 7:
self.assertEqual(vl.sourceCrs().authid(), "EPSG:4326")

def testCreateAspatialLayer(self):
"""
Expand Down

0 comments on commit 9c6b7e8

Please sign in to comment.