Skip to content

Commit

Permalink
Add test for QgsCategorizedSymbolRenderer::createCategories
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Dec 11, 2018
1 parent f324ddf commit 1d3e7d4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/src/python/test_qgscategorizedsymbolrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
QgsFeature,
QgsRenderContext,
QgsSymbol,
QgsStyle
QgsStyle,
QgsVectorLayer,
QgsEditorWidgetSetup
)
from qgis.PyQt.QtCore import QVariant
from qgis.PyQt.QtGui import QColor
Expand Down Expand Up @@ -483,6 +485,15 @@ def testFilterNeedsGeometry(self):
renderer.setClassAttribute("value - $area")
self.assertTrue(renderer.filterNeedsGeometry())

def testCategories(self):
layer = QgsVectorLayer("Point?field=fldtxt:string&field=fldint:integer", "addfeat", "memory")
layer.setEditorWidgetSetup(1, QgsEditorWidgetSetup("ValueMap", {'map': [{'One': '1'}, {'Two': '2'}]}))

result = QgsCategorizedSymbolRenderer.createCategories([1, 2, 3], QgsMarkerSymbol(), layer, 'fldint')

self.assertEqual(result[0].label(), 'One')
self.assertEqual(result[1].label(), 'Two')
self.assertEqual(result[2].label(), '(3)')

if __name__ == "__main__":
unittest.main()

0 comments on commit 1d3e7d4

Please sign in to comment.