From ad2d0a28da818bb94056e01c036c865f8c90908a Mon Sep 17 00:00:00 2001 From: Julien Cabieces Date: Mon, 24 Jun 2019 09:07:42 +0200 Subject: [PATCH] Add unit test --- tests/src/python/test_provider_postgres.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/src/python/test_provider_postgres.py b/tests/src/python/test_provider_postgres.py index a5c451a21c2..d24f95d077d 100644 --- a/tests/src/python/test_provider_postgres.py +++ b/tests/src/python/test_provider_postgres.py @@ -1101,6 +1101,15 @@ class TestPyQgsPostgresProvider(unittest.TestCase, ProviderTestCase): self.assertEqual(vl2.extent(), originalExtent) + def testDeterminePkey(self): + """Test primary key auto-determination""" + + vl = QgsVectorLayer(self.dbconn + ' sslmode=disable srid=4326 type=POLYGON table="qgis_test"."authors" sql=', 'test', 'postgres') + self.assertTrue(vl.isValid()) + self.assertTrue(vl.dataProvider().hasMetadata()) + self.assertTrue("key='pk'" in vl.source()) + + def testCheckPkUnicityOnView(self): # vector layer based on view