@@ -202,3 +202,40 @@ def test_json_log_metric_handler_discharge_with_accumulate(mocker):
202
202
# Accumulating metric should be reset to 0, non-accumulating should remain
203
203
assert handler .metrics [accumulating_metric ] == 0
204
204
assert handler .metrics [non_accumulating_metric ] == 7
205
+
206
+
207
+ def test_json_log_metric_handler_discharge_with_accumulate_and_decrement (mocker ):
208
+ """Test that JsonLogMetricHandler does not decrement accumulating metrics"""
209
+ handler = JsonLogMetricHandler ()
210
+
211
+ accumulating_metric = Metric ("test_accumulate" , accumulate = True )
212
+ non_accumulating_metric = Metric ("test_no_accumulate" , accumulate = False )
213
+
214
+ handler .increment (accumulating_metric , 10 )
215
+ handler .decrement (accumulating_metric , 7 )
216
+
217
+ handler .increment (non_accumulating_metric , 10 )
218
+ handler .decrement (non_accumulating_metric , 7 )
219
+
220
+ # Accumulating metric should be reset to 0, non-accumulating should remain
221
+ assert handler .metrics [accumulating_metric ] == 10
222
+ assert handler .metrics [non_accumulating_metric ] == 3
223
+
224
+
225
+ def test_console_metric_handler_discharge_with_accumulate_and_decrement (mocker ):
226
+ """Test that ConsoleMetricHandler does not decrement accumulating metrics"""
227
+ mock_command = mocker .Mock ()
228
+ handler = ConsoleMetricHandler (mock_command )
229
+
230
+ accumulating_metric = Metric ("test_accumulate" , accumulate = True )
231
+ non_accumulating_metric = Metric ("test_no_accumulate" , accumulate = False )
232
+
233
+ handler .increment (accumulating_metric , 10 )
234
+ handler .decrement (accumulating_metric , 7 )
235
+
236
+ handler .increment (non_accumulating_metric , 10 )
237
+ handler .decrement (non_accumulating_metric , 7 )
238
+
239
+ # Accumulating metric should be reset to 0, non-accumulating should remain
240
+ assert handler .metrics [accumulating_metric ] == 10
241
+ assert handler .metrics [non_accumulating_metric ] == 3
0 commit comments