Skip to content
Permalink
Browse files

Tests for PG views PKs ordering

  • Loading branch information
elpaso committed Feb 6, 2020
1 parent b7bdb9a commit 8671f6fc80140c3ee48fdb5b3ca68cb1159e01f0
Showing with 2 additions and 19 deletions.
  1. +2 −19 tests/src/python/test_qgsproviderconnection_postgres.py
@@ -164,30 +164,13 @@ def test_postgis_raster_rename(self):
self.assertFalse('Raster2' in table_names)
self.assertTrue('Raster1' in table_names)

def test_true_false(self):
"""Test returned values from BOOL queries"""

md = QgsProviderRegistry.instance().providerMetadata(self.providerKey)
conn = md.createConnection(self.uri, {})
self.assertEqual(conn.executeSql('SELECT FALSE'), [[False]])
self.assertEqual(conn.executeSql('SELECT TRUE'), [[True]])

def test_nulls(self):
"""Test returned values from typed NULL queries"""

md = QgsProviderRegistry.instance().providerMetadata(self.providerKey)
conn = md.createConnection(self.uri, {})
self.assertEqual(conn.executeSql('SELECT NULL::bool'), [[None]])
self.assertEqual(conn.executeSql('SELECT NULL::text'), [[None]])
self.assertEqual(conn.executeSql('SELECT NULL::bytea'), [[None]])

def test_pk_cols_order(self):
"""Test that PKs are returned in consistent order: see GH #34167"""

md = QgsProviderRegistry.instance().providerMetadata(self.providerKey)
conn = md.createConnection(self.uri, {})
self.assertEqual(conn.table('qgis_test', 'bikes_view').primaryKeyColumns(), ['pk', 'name'])
self.assertEqual(conn.table('qgis_test', 'some_poly_data_view').primaryKeyColumns(), ['pk', 'geom'])
self.assertEqual(self._table_by_name(conn.tables(), 'bikes_view').primaryKeyColumns(), ['pk', 'name'])
self.assertEqual(self._table_by_name(conn.tables(), 'some_poly_data_view').primaryKeyColumns(), ['pk', 'geom'])


if __name__ == '__main__':

0 comments on commit 8671f6f

Please sign in to comment.
You can’t perform that action at this time.