Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix broken conditional styles tests
  • Loading branch information
NathanW2 committed Aug 25, 2015
1 parent 704ce96 commit b5362b0
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions tests/src/python/test_qgsconditionalstyle.py
Expand Up @@ -26,13 +26,14 @@


class TestPyQgsConditionalStyle(TestCase):
def new_feature(self):
def new_context(self):
feature = QgsFeature()
fields = QgsFields()
fields.append(QgsField("testfield", QVariant.Int))
feature.setFields(fields, True)
feature["testfield"] = 20
return feature
context = QgsExpressionContextUtils.createFeatureBasedContext(feature, fields)
return context

def test_MatchesReturnsTrueForSimpleMatch(self):
style = QgsConditionalStyle("@value > 10")
Expand All @@ -45,13 +46,8 @@ def test_MatchesReturnsTrueForComplexMatch(self):
assert style.matches(20, context)

def test_MatchesTrueForFields(self):
feature = QgsFeature()
fields = QgsFields()
fields.append(QgsField("testfield", QVariant.Int))
feature.setFields(fields, True)
feature["testfield"] = 20
style = QgsConditionalStyle('"testfield" = @value')
context = QgsExpressionContextUtils.createFeatureBasedContext(feature, fields)
context = self.new_context()
assert style.matches(20, context)

def test_MatchingStylesReturnsListOfCorrectStyles(self):
Expand All @@ -65,7 +61,8 @@ def test_MatchingStylesReturnsListOfCorrectStyles(self):
style = QgsConditionalStyle("@value < 5")
style.setName("3")
styles.append(style)
out = QgsConditionalStyle.matchingConditionalStyles(styles, 20, self.new_feature())
context = self.new_context()
out = QgsConditionalStyle.matchingConditionalStyles(styles, 20, context)
assert len(out) == 2
out[0].name() == "1"
out[1].name() == "2"
Expand Down

0 comments on commit b5362b0

Please sign in to comment.