Skip to content

Commit

Permalink
Add doctring
Browse files Browse the repository at this point in the history
  • Loading branch information
speillet authored and nyalldawson committed Jan 27, 2021
1 parent 0847f1e commit f507329
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/src/python/test_provider_postgres.py
Expand Up @@ -2273,6 +2273,9 @@ def _test(vl, ids):
_test(vl, [1, 3])

def testValidLayerDiscoverRelationsNone(self):
"""
Test checks that discover relation feature can be used on a layer that has no relation.
"""
vl = QgsVectorLayer(
self.dbconn +
' sslmode=disable key=\'pk\' srid=4326 type=POINT table="qgis_test"."someData" (geom) sql=',
Expand All @@ -2281,12 +2284,19 @@ def testValidLayerDiscoverRelationsNone(self):
self.assertEqual(vl.dataProvider().discoverRelations(vl, []), [])

def testInvalidLayerDiscoverRelations(self):
"""
Test that discover relations feature can be used on invalid layer.
"""
vl = QgsVectorLayer('{} table="qgis_test"."invalid_layer" sql='.format(self.dbconn), "invalid_layer",
"postgres")
self.assertFalse(vl.isValid())
self.assertEqual(vl.dataProvider().discoverRelations(vl, []), [])

def testValidLayerDiscoverRelations(self):
"""
Test implicit relations that can be discovers between tables, based on declared foreign keys.
The test also checks that two distinct relations can be discovered when two foreign keys are declared (see #41138).
"""
vl = QgsVectorLayer(
self.dbconn +
' sslmode=disable key=\'pk\' checkPrimaryKeyUnicity=\'1\' table="qgis_test"."referencing_layer"',
Expand Down

0 comments on commit f507329

Please sign in to comment.