Skip to content

Commit

Permalink
Add additional decodeUri tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Aug 16, 2018
1 parent 8a117af commit 3b861f2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/src/python/test_provider_spatialite.py
Expand Up @@ -20,7 +20,8 @@
import shutil
import tempfile

from qgis.core import (QgsVectorLayer,
from qgis.core import (QgsProviderRegistry,
QgsVectorLayer,
QgsVectorDataProvider,
QgsPointXY,
QgsFeature,
Expand Down Expand Up @@ -742,6 +743,15 @@ def _lessdigits(s):
self.assertEqual(subSet_vl.featureCount(), 8)
self.assertEqual(_lessdigits(subSet_vl.extent().toString()), unfiltered_extent)

def testDecodeUri(self):
"""Check that the provider URI decoding returns expected values"""

filename = '/home/to/path/test.db'
uri = 'dbname=\'{}\' table="test" (geometry) sql='.format(filename)
registry = QgsProviderRegistry.instance()
components = registry.decodeUri('spatialite', uri)
self.assertEqual(components['path'], filename)


if __name__ == '__main__':
unittest.main()
8 changes: 8 additions & 0 deletions tests/src/python/test_qgsdelimitedtextprovider.py
Expand Up @@ -820,6 +820,14 @@ def test_042_no_detect_types_csvt(self):
requests = None
self.runTest(filename, requests, **params)

def test_043_decodeuri(self):
# URI decoding
filename = '/home/to/path/test.csv'
uri = 'file://{}?geomType=none'.format(filename)
registry = QgsProviderRegistry.instance()
components = registry.decodeUri('delimitedtext', uri)
self.assertEqual(components['path'], filename)


if __name__ == '__main__':
unittest.main()

0 comments on commit 3b861f2

Please sign in to comment.