Skip to content
Permalink
Browse files

Add unit tests

  • Loading branch information
pblottiere committed Mar 27, 2018
1 parent 2cb1f43 commit dd6f98fe24e786ce45964074204abc070d7e5e41
Showing with 23 additions and 1 deletion.
  1. +23 −1 tests/src/python/test_qgsrulebasedrenderer.py
@@ -40,7 +40,8 @@
QgsRendererCategory,
QgsCategorizedSymbolRenderer,
QgsGraduatedSymbolRenderer,
QgsRendererRange
QgsRendererRange,
QgsRenderContext
)
from qgis.testing import start_app, unittest
from utilities import unitTestDataPath
@@ -101,6 +102,27 @@ def testDisabledElse(self):

assert result

def testWillRenderFeature(self):
vl = self.mapsettings.layers()[0]
ft = vl.getFeature(0) # 'id' = 1
renderer = vl.renderer()

ctx = QgsRenderContext.fromMapSettings(self.mapsettings)
ctx.expressionContext().setFeature(ft)

renderer.rootRule().children()[0].setActive(False)
renderer.rootRule().children()[1].setActive(True)
renderer.rootRule().children()[2].setActive(True)

renderer.startRender(ctx, vl.fields()) # build mActiveChlidren

rendered = renderer.willRenderFeature(ft, ctx)
renderer.rootRule().children()[0].setActive(True)
assert rendered == False

rendered = renderer.willRenderFeature(ft, ctx)
assert rendered == True

def testRefineWithCategories(self):
# Test refining rule with categories (refs #10815)

0 comments on commit dd6f98f

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