Skip to content

Commit 7376e6f

Browse files
committed
Add tests
1 parent eacc506 commit 7376e6f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tests/src/python/test_db_manager_spatialite.py

+14
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ def testConnect(self):
109109
pass
110110
self.assertFalse(connection_succeeded, 'exception should have been raised')
111111

112+
def testExecuteRegExp(self):
113+
"""This test checks for REGEXP syntax support, which is enabled in Qgis.utils' spatialite_connection()"""
114+
115+
connection_name = 'testListLayer'
116+
plugin = createDbPlugin('spatialite')
117+
uri = QgsDataSourceUri()
118+
uri.setDatabase(self.test_spatialite)
119+
self.assertTrue(plugin.addConnection(connection_name, uri))
120+
121+
connection = createDbPlugin('spatialite', connection_name)
122+
connection.connect()
123+
db = connection.database()
124+
db.connector._execute(None, 'SELECT \'ABC\' REGEXP \'[CBA]\'')
125+
112126
def testListLayer(self):
113127
connection_name = 'testListLayer'
114128
plugin = createDbPlugin('spatialite')

tests/src/python/test_provider_spatialite.py

+10
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,16 @@ def testCreateAttributeIndex(self):
701701
self.assertEqual(set(indexed_columns), set(['name', 'number']))
702702
con.close()
703703

704+
def testSubsetStringRegexp(self):
705+
"""Check that the provider supports the REGEXP syntax"""
706+
707+
testPath = "dbname=%s table='test_filter' (geometry) key='id'" % self.dbname
708+
vl = QgsVectorLayer(testPath, 'test', 'spatialite')
709+
self.assertTrue(vl.isValid())
710+
vl.setSubsetString('"name" REGEXP \'[txe]\'')
711+
self.assertEqual(vl.featureCount(), 4)
712+
del(vl)
713+
704714
def testSubsetStringExtent_bug17863(self):
705715
"""Check that the extent is correct when applied in the ctor and when
706716
modified after a subset string is set """

0 commit comments

Comments
 (0)