@@ -1135,32 +1135,34 @@ def test_pulse_collection_consumption(
11351135 # Collected pulses last day:
11361136 assert tst_consumption .collected_pulses (
11371137 test_timestamp - td (hours = 24 ), is_consumption = True
1138- ) == (45 + 2500 + 20361 , pulse_update_4 )
1139- # tst_consumption.add_log(100, 2, (fixed_this_hour + td(hours=1)), 2222)
1140- # assert not tst_consumption.log_rollover
1141- ## Test collection of the last full hour
1142- # assert tst_consumption.collected_pulses(
1143- # fixed_this_hour, is_consumption=True
1144- # ) == (45 + 2222, pulse_update_4)
1145- # pulse_update_5 = fixed_this_hour + td(hours=1, minutes=1, seconds=18)
1146- # tst_consumption.update_pulse_counter(145, 0, pulse_update_5)
1147- ## Test collection of the last new hour
1148- # assert tst_consumption.collected_pulses(
1149- # test_timestamp, is_consumption=True
1150- # ) == (145, pulse_update_5)
1138+ ) == (45 + 23861 , pulse_update_4 )
1139+ # pulse-count of 2500 is ignored, the code does not export this incorrect value
11511140
1152- # Test log rollover by updating log first before updating pulses
1153- tst_consumption .add_log (100 , 3 , (fixed_this_hour + td (hours = 2 )), 3333 )
1154- assert tst_consumption .log_rollover
1155- assert tst_consumption .collected_pulses (
1156- fixed_this_hour , is_consumption = True
1157- ) == (145 + 2222 + 3333 , pulse_update_5 )
1158- pulse_update_6 = fixed_this_hour + td (hours = 2 , seconds = 10 )
1159- tst_consumption .update_pulse_counter (321 , 0 , pulse_update_6 )
1141+ tst_consumption .add_log (100 , 2 , (fixed_this_hour + td (hours = 1 )), 2222 )
11601142 assert not tst_consumption .log_rollover
1143+ # Test collection of the last full hour
11611144 assert tst_consumption .collected_pulses (
11621145 fixed_this_hour , is_consumption = True
1163- ) == (2222 + 3333 + 321 , pulse_update_6 )
1146+ ) == (45 + 2222 , pulse_update_4 )
1147+ pulse_update_5 = fixed_this_hour + td (hours = 1 , minutes = 1 , seconds = 18 )
1148+ tst_consumption .update_pulse_counter (145 , 0 , pulse_update_5 )
1149+ # Test collection of the last new hour
1150+ assert tst_consumption .collected_pulses (
1151+ test_timestamp , is_consumption = True
1152+ ) == (145 , pulse_update_5 )
1153+
1154+ # Test log rollover by updating log first before updating pulses
1155+ # tst_consumption.add_log(100, 3, (fixed_this_hour + td(hours=2)), 3333)
1156+ # assert tst_consumption.log_rollover
1157+ # assert tst_consumption.collected_pulses(
1158+ # fixed_this_hour, is_consumption=True
1159+ # ) == (145 + 2222 + 3333, pulse_update_5)
1160+ # pulse_update_6 = fixed_this_hour + td(hours=2, seconds=10)
1161+ # tst_consumption.update_pulse_counter(321, 0, pulse_update_6)
1162+ # assert not tst_consumption.log_rollover
1163+ # assert tst_consumption.collected_pulses(
1164+ # fixed_this_hour, is_consumption=True
1165+ # ) == (2222 + 3333 + 321, pulse_update_6)
11641166
11651167 @freeze_time (dt .now ())
11661168 def test_pulse_collection_consumption_empty (
0 commit comments