Skip to content
Permalink
Browse files

Add test for QgsCategorizedSymbolRenderer::createCategories

  • Loading branch information
m-kuhn committed Dec 11, 2018
1 parent f324ddf commit 1d3e7d46d9e5eb3afcb39e5887b8a889a119689f
Showing with 12 additions and 1 deletion.
  1. +12 −1 tests/src/python/test_qgscategorizedsymbolrenderer.py
@@ -25,7 +25,9 @@
QgsFeature,
QgsRenderContext,
QgsSymbol,
QgsStyle
QgsStyle,
QgsVectorLayer,
QgsEditorWidgetSetup
)
from qgis.PyQt.QtCore import QVariant
from qgis.PyQt.QtGui import QColor
@@ -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.
You can’t perform that action at this time.