Skip to content

Commit

Permalink
Add some comments to provider test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed May 23, 2015
1 parent c1b520f commit 40e2845
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/src/python/providertestbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@
__revision__ = '$Format:%H$'

from qgis.core import QgsRectangle, QgsFeatureRequest, QgsGeometry, NULL
from utilities import TestCase


class ProviderTestCase(object):
'''
This is a collection of tests for vector data providers and kept generic.
To make use of it, subclass it and set self.provider to a provider you want to test.
Make sure that your provider uses the default dataset by converting one of the provided datasets from the folder
tests/testdata/provider to a dataset your provider is able to handle.
To test expression compilation, add the methods `enableCompiler()` and `disableCompiler()` to your subclass.
If these methods are present, the tests will ensure that the result of server side and client side expression
evaluation are equal.
'''
def runGetFeatureTests(self, provider):
assert len([f for f in provider.getFeatures()]) == 5
assert len([f for f in provider.getFeatures(QgsFeatureRequest().setFilterExpression('name IS NOT NULL'))]) == 4
Expand Down Expand Up @@ -62,7 +70,7 @@ def testMaxValue(self):

def testExtent(self):
reference = QgsGeometry.fromRect(
QgsRectangle(-71.1230000000000047, 66.3299999999999983, -65.3199999999999932, 78.2999999999999972))
QgsRectangle(-71.123, 66.33, -65.32, 78.3))
provider_extent = QgsGeometry.fromRect(self.provider.extent())

assert QgsGeometry.compare(provider_extent.asPolygon(), reference.asPolygon(), 0.000001)
Expand Down

0 comments on commit 40e2845

Please sign in to comment.