Skip to content

Commit 3accda6

Browse files
committedJun 9, 2016
Also test the estimatedmetadata code path for signedInts
1 parent 8b9a035 commit 3accda6

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed
 

‎tests/src/python/test_provider_postgres.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ def test_unique(features, num_features):
158158

159159
# See http://hub.qgis.org/issues/14262
160160
def testSignedIdentifiers(self):
161-
def test_query_attribute(dbconn, query, att, val, fidval):
162-
ql = QgsVectorLayer('%s table="%s" (g) key=\'%s\' sql=' % (dbconn, query.replace('"', '\\"'), att), "testgeom", "postgres")
161+
def test_layer(ql, att, val, fidval):
163162
self.assertTrue(ql.isValid())
164163
features = ql.getFeatures()
165164
att_idx = ql.fieldNameIndex(att)
@@ -169,9 +168,18 @@ def test_query_attribute(dbconn, query, att, val, fidval):
169168
self.assertEqual(f.attributes()[att_idx], val)
170169
self.assertEqual(f.id(), fidval)
171170
self.assertEqual(count, 1)
172-
test_query_attribute(self.dbconn, '(SELECT -1::int4 i, NULL::geometry(Point) g)', 'i', -1, 4294967295)
173-
test_query_attribute(self.dbconn, '(SELECT -2::int2 i, NULL::geometry(Point) g)', 'i', -2, 4294967294)
174-
test_query_attribute(self.dbconn, '(SELECT -3::int8 i, NULL::geometry(Point) g)', 'i', -3, 1)
171+
172+
def test(dbconn, query, att, val, fidval):
173+
table = query.replace('"', '\\"')
174+
uri = '%s table="%s" (g) key=\'%s\'' % (dbconn, table, att)
175+
ql = QgsVectorLayer(uri, "t", "postgres")
176+
test_layer(ql, att, val, fidval)
177+
# now with estimated metadata
178+
uri += ' estimatedmetadata="true"'
179+
test_layer(ql, att, val, fidval)
180+
test(self.dbconn, '(SELECT -1::int4 i, NULL::geometry(Point) g)', 'i', -1, 4294967295)
181+
test(self.dbconn, '(SELECT -2::int2 i, NULL::geometry(Point) g)', 'i', -2, 4294967294)
182+
test(self.dbconn, '(SELECT -3::int8 i, NULL::geometry(Point) g)', 'i', -3, 1)
175183

176184
def testPktIntInsert(self):
177185
vl = QgsVectorLayer('{} table="qgis_test"."{}" key="pk" sql='.format(self.dbconn, 'bikes_view'), "bikes_view", "postgres")

0 commit comments

Comments
 (0)
Please sign in to comment.