Skip to content

Commit

Permalink
Add unit test for postgres layer metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 14, 2018
1 parent 7dd5caf commit feb20a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/src/python/test_provider_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
QgsReadWriteContext,
QgsRectangle,
QgsDefaultValue,
QgsCoordinateReferenceSystem,
QgsProject,
QgsWkbTypes,
QgsGeometry
Expand Down Expand Up @@ -197,6 +198,13 @@ def test_table(dbconn, table_name, wkt):

test_table(self.dbconn, 'pt4d', 'PointZM (1 2 3 4)')

def testMetadata(self):
""" Test that metadata is correctly acquired from provider """
metadata = self.vl.metadata()
self.assertEqual(metadata.crs(), QgsCoordinateReferenceSystem.fromEpsgId(4326))
self.assertEqual(metadata.type(), 'dataset')
self.assertEqual(metadata.abstract(), 'QGIS Test Table')

def testGetFeaturesUniqueId(self):
"""
Test tables with inheritance for unique ids
Expand Down
2 changes: 2 additions & 0 deletions tests/testdata/provider/testdata_pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ CREATE TABLE qgis_test."someData" (
geom public.geometry(Point,4326)
);

COMMENT ON TABLE qgis_test."someData" IS 'QGIS Test Table';

CREATE TABLE qgis_test."some_poly_data" (
pk SERIAL NOT NULL,
geom public.geometry(Polygon,4326)
Expand Down

0 comments on commit feb20a7

Please sign in to comment.