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