Skip to content

Commit

Permalink
Add an empty test on truncated layers
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jun 4, 2018
1 parent 48a796d commit 6dd26bb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/src/python/providertestbase.py
Expand Up @@ -433,6 +433,26 @@ def testEmpty(self):
self.source.setSubsetString(None)
self.assertFalse(self.source.empty())

# If the provider supports tests on editable layers
if getattr(self, 'getEditableLayer', None):
l = self.getEditableLayer()
self.assertTrue(l.isValid())

self.assertEqual(l.hasFeatures(), QgsFeatureSource.FeaturesAvailable)

# Test that deleting some features in the edit buffer does not
# return empty, we accept FeaturesAvailable as well as
# MaybeAvailable
l.startEditing()
l.deleteFeature(next(l.getFeatures()).id())
self.assertNotEqual(l.hasFeatures(), QgsFeatureSource.NoFeaturesAvailable)
l.rollBack()

# Call truncate(), we need an empty set now
l.dataProvider().truncate()
self.assertTrue(l.dataProvider().empty())
self.assertEqual(l.dataProvider().hasFeatures(), QgsFeatureSource.NoFeaturesAvailable)

def testGetFeaturesNoGeometry(self):
""" Test that no geometry is present when fetching features without geometry"""

Expand Down

0 comments on commit 6dd26bb

Please sign in to comment.