Skip to content
Permalink
Browse files

Add a couple more tests for QgsVectorLayerSelectedFeatureSource

  • Loading branch information
nyalldawson committed Jun 5, 2017
1 parent 405c55f commit 6fed80b1e9d301522c25bb1cfbfdfb69e4fbadb9
Showing with 11 additions and 1 deletion.
  1. +1 −1 src/core/qgsvectorlayerfeatureiterator.cpp
  2. +10 −0 tests/src/python/test_qgsvectorlayer.py
@@ -1026,7 +1026,7 @@ QgsFeatureIterator QgsVectorLayerSelectedFeatureSource::getFeatures( const QgsFe
{
QgsFeatureRequest req( request );

if ( req.filterFids().isEmpty() && req.filterType() != QgsFeatureRequest::FilterFids )
if ( req.filterFids().isEmpty() && req.filterType() != QgsFeatureRequest::FilterFid )
{
req.setFilterFids( mSelectedFeatureIds );
}
@@ -2343,6 +2343,16 @@ def testQgsVectorLayerSelectedFeatureSource(self):
ids = set([f.id() for f in source.getFeatures()])
self.assertEqual(ids, {f1.id(), f3.id(), f5.id()})

# test that requesting subset of ids intersects this request with the selected ids
ids = set([f.id() for f in source.getFeatures(QgsFeatureRequest().setFilterFids([f1.id(), f2.id(), f5.id()]))])
self.assertEqual(ids, {f1.id(), f5.id()})

# test that requesting id works
ids = set([f.id() for f in source.getFeatures(QgsFeatureRequest().setFilterFid(f1.id()))])
self.assertEqual(ids, {f1.id()})
ids = set([f.id() for f in source.getFeatures(QgsFeatureRequest().setFilterFid(f5.id()))])
self.assertEqual(ids, {f5.id()})

# test that source has stored snapshot of selected features
layer.selectByIds([f2.id(), f4.id()])
self.assertEqual(source.featureCount(), 3)

0 comments on commit 6fed80b

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