@@ -39,6 +39,7 @@ def test_representValue(self):
39
39
fieldFormatter = QgsValueMapFieldFormatter ()
40
40
41
41
# Tests with different value types occurring in the value map
42
+ # old style config (pre 3.0)
42
43
config = {'map' : {'two' : '2' , 'twoandhalf' : '2.5' , 'NULL text' : 'NULL' ,
43
44
'nothing' : self .VALUEMAP_NULL_TEXT }}
44
45
self .assertEqual (fieldFormatter .representValue (layer , 0 , config , None , 2 ), 'two' )
@@ -48,6 +49,20 @@ def test_representValue(self):
48
49
self .assertEqual (fieldFormatter .representValue (layer , 3 , config , None , None ), 'nothing' )
49
50
self .assertEqual (fieldFormatter .representValue (layer , 4 , config , None , None ), 'nothing' )
50
51
self .assertEqual (fieldFormatter .representValue (layer , 5 , config , None , None ), 'nothing' )
52
+
53
+ # new style config (post 3.0)
54
+ config = {'map' : [{'two' : '2' },
55
+ {'twoandhalf' : '2.5' },
56
+ {'NULL text' : 'NULL' },
57
+ {'nothing' : self .VALUEMAP_NULL_TEXT }]}
58
+ self .assertEqual (fieldFormatter .representValue (layer , 0 , config , None , 2 ), 'two' )
59
+ self .assertEqual (fieldFormatter .representValue (layer , 1 , config , None , 2.5 ), 'twoandhalf' )
60
+ self .assertEqual (fieldFormatter .representValue (layer , 2 , config , None , 'NULL' ), 'NULL text' )
61
+ # Tests with null values of different types, if value map contains null
62
+ self .assertEqual (fieldFormatter .representValue (layer , 3 , config , None , None ), 'nothing' )
63
+ self .assertEqual (fieldFormatter .representValue (layer , 4 , config , None , None ), 'nothing' )
64
+ self .assertEqual (fieldFormatter .representValue (layer , 5 , config , None , None ), 'nothing' )
65
+
51
66
# Tests with fallback display for different value types
52
67
config = {}
53
68
self .assertEqual (fieldFormatter .representValue (layer , 0 , config , None , 2 ), '(2)' )
0 commit comments