Skip to content

Commit

Permalink
Add test for filter expression on non provider fields
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Nov 2, 2015
1 parent dddd043 commit 353c0db
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions tests/src/python/test_qgsvectorlayer.py
Expand Up @@ -159,7 +159,7 @@ def checkBefore():
checkAfter()
assert layer.dataProvider().featureCount() == 1

#DELETE FEATURE
# DELETE FEATURE

def test_DeleteFeature(self):
layer = createLayerWithOnePoint()
Expand Down Expand Up @@ -258,7 +258,7 @@ def checkAfter2():

assert layer.dataProvider().featureCount() == 0

#CHANGE ATTRIBUTE
# CHANGE ATTRIBUTE

def test_ChangeAttribute(self):
layer = createLayerWithOnePoint()
Expand Down Expand Up @@ -347,8 +347,8 @@ def checkBefore():
assert layer.commitChanges()
checkAfter()

#print "COMMIT ERRORS:"
#for item in list(layer.commitErrors()): print item
# print "COMMIT ERRORS:"
# for item in list(layer.commitErrors()): print item

# CHANGE GEOMETRY

Expand Down Expand Up @@ -471,8 +471,8 @@ def checkBefore():
assert layer.commitChanges()
checkAfter()

#print "COMMIT ERRORS:"
#for item in list(layer.commitErrors()): print item
# print "COMMIT ERRORS:"
# for item in list(layer.commitErrors()): print item

# ADD ATTRIBUTE

Expand Down Expand Up @@ -517,7 +517,7 @@ def checkAfter():
assert f2[1] == 123
assert f2[2] is None

#for nt in layer.dataProvider().nativeTypes():
# for nt in layer.dataProvider().nativeTypes():
# print (nt.mTypeDesc, nt.mTypeName, nt.mType, nt.mMinLen,
# nt.mMaxLen, nt.mMinPrec, nt.mMaxPrec)
assert layer.dataProvider().supportedType(fld1)
Expand Down Expand Up @@ -591,8 +591,8 @@ def checkAfter():
layer.commitChanges()
checkAfter()

#print "COMMIT ERRORS:"
#for item in list(layer.commitErrors()): print item
# print "COMMIT ERRORS:"
# for item in list(layer.commitErrors()): print item

def test_AddAttributeAfterChangeValue(self):
pass # not interesting to test...?
Expand Down Expand Up @@ -634,7 +634,7 @@ def checkBefore():

def checkAfterOneDelete():
flds = layer.pendingFields()
#for fld in flds: print "FLD", fld.name()
# for fld in flds: print "FLD", fld.name()
assert len(flds) == 2
assert flds[0].name() == "fldint"
assert flds[1].name() == "flddouble"
Expand All @@ -654,7 +654,7 @@ def checkAfterOneDelete():
def checkAfterTwoDeletes():
assert layer.pendingAllAttributesList() == [0]
flds = layer.pendingFields()
#for fld in flds: print "FLD", fld.name()
# for fld in flds: print "FLD", fld.name()
assert len(flds) == 1
assert flds[0].name() == "flddouble"

Expand Down Expand Up @@ -976,6 +976,19 @@ def test_ExpressionField(self):

assert(layer.pendingFields().count() == cnt)

def test_ExpressionFilter(self):
layer = createLayerWithOnePoint()

idx = layer.addExpressionField('5', QgsField('test', QVariant.LongLong))

features = layer.getFeatures(QgsFeatureRequest().setFilterExpression('"test" = 6'))

assert(len(list(features)) == 0)

features = layer.getFeatures(QgsFeatureRequest().setFilterExpression('"test" = 5'))

assert(len(list(features)) == 1)

def onLayerTransparencyChanged(self, tr):
self.transparencyTest = tr

Expand Down

0 comments on commit 353c0db

Please sign in to comment.