Skip to content
Permalink
Browse files

Added failing test for tables with INHERITS

  • Loading branch information
elpaso committed Dec 4, 2015
1 parent 7829497 commit 614db661295ad3ddb4ca699ac92f6af548975f00
Showing with 59 additions and 0 deletions.
  1. +15 −0 tests/src/python/test_provider_postgres.py
  2. +44 −0 tests/testdata/provider/testdata.sql
@@ -93,5 +93,20 @@ def test_table(dbconn, table_name, wkt):
test_table(self.dbconn, 'mls2d', 'MultiLineString ((0 0, 1 1),(2 2, 3 3))')
test_table(self.dbconn, 'mls3d', 'MultiLineStringZ ((0 0 0, 1 1 1),(2 2 2, 3 3 3))')

def testGetFeaturesUniqueId(self):
def test_unique(dbconn, table_name, num_features):
vl = QgsVectorLayer('%s srid=4326 table="qgis_test".%s (geom) sql=' % (dbconn, table_name), "testgeom", "postgres")
assert(vl.isValid())
features = [f for f in vl.getFeatures()]
featureids = []
for f in features:
self.assertFalse(f.id() in featureids)
featureids.append(f.id())
self.assertEqual(len(features), num_features)

test_unique(self.dbconn, 'someData', 5)
test_unique(self.dbconn, 'base_table', 4)


if __name__ == '__main__':
unittest.main()
@@ -188,3 +188,47 @@ CREATE TABLE qgis_test.mls3d(
);

INSERT INTO qgis_test.mls3d values (1, 'srid=4326;MultiLineString((0 0 0, 1 1 1),(2 2 2, 3 3 3))'::geometry);


CREATE TABLE qgis_test.base_table
(
gid serial NOT NULL,
geom geometry(Point,4326),
code character varying,
CONSTRAINT base_pkey PRIMARY KEY (gid)
)
WITH (
OIDS=FALSE
);

CREATE TABLE qgis_test.child_table
(
gid serial NOT NULL,
geom geometry(Point,4326),
code character varying,
CONSTRAINT child_pkey PRIMARY KEY (gid)
)
INHERITS ( qgis_test.base_table)
WITH (
OIDS=FALSE
);


CREATE TABLE qgis_test.child_table2
(
gid serial NOT NULL,
geom geometry(Point,4326),
code character varying,
CONSTRAINT child2_pkey PRIMARY KEY (gid)
)
INHERITS ( qgis_test.base_table)
WITH (
OIDS=FALSE
);

INSERT INTO qgis_test.child_table (gid, geom, code) VALUES (1, 'srid=4326;Point(0 0)'::geometry, 'child 1');
INSERT INTO qgis_test.child_table (gid, geom, code) VALUES (2, 'srid=4326;Point(1 1)'::geometry, 'child 2');


INSERT INTO qgis_test.child_table2 (gid, geom, code) VALUES (1, 'srid=4326;Point(-1 -1)::geometry', 'child2 1');
INSERT INTO qgis_test.child_table2 (gid, geom, code) VALUES (2, 'srid=4326;Point(-1 1)::geometry', 'child2 2');

0 comments on commit 614db66

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