|
13 | 13 | __revision__ = '$Format:%H$'
|
14 | 14 |
|
15 | 15 | from qgis.core import QgsRectangle, QgsFeatureRequest, QgsGeometry, NULL
|
16 |
| -from utilities import TestCase |
17 |
| - |
18 | 16 |
|
19 | 17 | class ProviderTestCase(object):
|
| 18 | + ''' |
| 19 | + This is a collection of tests for vector data providers and kept generic. |
| 20 | + To make use of it, subclass it and set self.provider to a provider you want to test. |
| 21 | + Make sure that your provider uses the default dataset by converting one of the provided datasets from the folder |
| 22 | + tests/testdata/provider to a dataset your provider is able to handle. |
| 23 | +
|
| 24 | + To test expression compilation, add the methods `enableCompiler()` and `disableCompiler()` to your subclass. |
| 25 | + If these methods are present, the tests will ensure that the result of server side and client side expression |
| 26 | + evaluation are equal. |
| 27 | + ''' |
20 | 28 | def runGetFeatureTests(self, provider):
|
21 | 29 | assert len([f for f in provider.getFeatures()]) == 5
|
22 | 30 | assert len([f for f in provider.getFeatures(QgsFeatureRequest().setFilterExpression('name IS NOT NULL'))]) == 4
|
@@ -62,7 +70,7 @@ def testMaxValue(self):
|
62 | 70 |
|
63 | 71 | def testExtent(self):
|
64 | 72 | reference = QgsGeometry.fromRect(
|
65 |
| - QgsRectangle(-71.1230000000000047, 66.3299999999999983, -65.3199999999999932, 78.2999999999999972)) |
| 73 | + QgsRectangle(-71.123, 66.33, -65.32, 78.3)) |
66 | 74 | provider_extent = QgsGeometry.fromRect(self.provider.extent())
|
67 | 75 |
|
68 | 76 | assert QgsGeometry.compare(provider_extent.asPolygon(), reference.asPolygon(), 0.000001)
|
|
0 commit comments