File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,35 @@ def testRemoveColumns(self):
91
91
92
92
self .assertEqual (self .am .columnCount (), 1 )
93
93
94
+ def testEdit (self ):
95
+ fid = 2
96
+ field_idx = 1
97
+ new_value = 333
98
+
99
+ # get the same feature from model and layer
100
+ feature = self .layer .getFeature (fid )
101
+ model_index = self .am .idToIndex (fid )
102
+ feature_model = self .am .feature (model_index )
103
+
104
+ # check that feature from layer and model are sync
105
+ self .assertEqual (feature .attribute (field_idx ), feature_model .attribute (field_idx ))
106
+
107
+ # change attribute value for a feature and commit
108
+ self .layer .startEditing ()
109
+ self .layer .changeAttributeValue (fid , field_idx , new_value )
110
+ self .layer .commitChanges ()
111
+
112
+ # check the feature in layer is good
113
+ feature = self .layer .getFeature (fid )
114
+ self .assertEqual (feature .attribute (field_idx ), new_value )
115
+
116
+ # get the same feature from model and layer
117
+ model_index = self .am .idToIndex (fid )
118
+ feature_model = self .am .feature (model_index )
119
+
120
+ # check that index from layer and model are sync
121
+ self .assertEqual (feature .attribute (field_idx ), feature_model .attribute (field_idx ))
122
+
94
123
95
124
if __name__ == '__main__' :
96
125
unittest .main ()
You can’t perform that action at this time.
0 commit comments