Skip to content
Permalink
Browse files

Add an empty test on truncated layers

  • Loading branch information
m-kuhn committed Jun 4, 2018
1 parent 48a796d commit 6dd26bbfce3b0f0eafdb7f0c692a19f1eb49b070
Showing with 20 additions and 0 deletions.
  1. +20 −0 tests/src/python/providertestbase.py
@@ -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"""

0 comments on commit 6dd26bb

Please sign in to comment.
You can’t perform that action at this time.