def test_cumulative_counter_after_rolling_and_reset2(): _time = MockedTime() counter = RollingNumber(20, 2, _time=_time) event = RollingNumberEvent.SUCCESS assert counter.cumulative_sum(event) == 0 counter.increment(event) counter.increment(event) counter.increment(event) # Iterate over 20 buckets on a queue sized for 2 for i in range(20): _time.increment(counter.buckets_size_in_milliseconds()) # simulate a reset occurring every once in a while # so we ensure the absolute sum is handling it okay if i == 5 or i == 15: counter.reset() # No increments during the loop, just some before and after counter.increment(event) counter.increment(event) # Cumulative count should be 5 regardless of buckets rolling assert counter.cumulative_sum(event) == 5
def test_cumulative_counter_after_rolling_and_reset2(): time = MockedTime() counter = RollingNumber(time, 20, 2) event = RollingNumberEvent.SUCCESS assert counter.cumulative_sum(event) == 0 counter.increment(event) counter.increment(event) counter.increment(event) # Iterate over 20 buckets on a queue sized for 2 for i in range(20): time.increment(counter.buckets_size_in_milliseconds()) # simulate a reset occurring every once in a while # so we ensure the absolute sum is handling it okay if i == 5 or i == 15: counter.reset() # No increments during the loop, just some before and after counter.increment(event) counter.increment(event) # Cumulative count should be 5 regardless of buckets rolling assert counter.cumulative_sum(event) == 5
def test_cumulative_counter_after_rolling_and_reset(): _time = MockedTime() counter = RollingNumber(20, 2, _time=_time) event = RollingNumberEvent.SUCCESS assert counter.cumulative_sum(event) == 0 # Iterate over 20 buckets on a queue sized for 2 for i in range(20): counter.increment(event) _time.increment(counter.buckets_size_in_milliseconds()) assert len(counter.values(event)) == 2 counter.value_of_latest_bucket(event) # simulate a reset occurring every once in a while # so we ensure the absolute sum is handling it okay if i == 5 or i == 15: counter.reset() # Cumulative count should be 20 (for the number of loops above) regardless # of buckets rolling assert counter.cumulative_sum(event) == 20
def test_cumulative_counter_after_rolling_and_reset(): time = MockedTime() counter = RollingNumber(time, 20, 2) event = RollingNumberEvent.SUCCESS assert counter.cumulative_sum(event) == 0 # Iterate over 20 buckets on a queue sized for 2 for i in range(20): counter.increment(event) time.increment(counter.buckets_size_in_milliseconds()) assert len(counter.values(event)) == 2 counter.value_of_latest_bucket(event) # simulate a reset occurring every once in a while # so we ensure the absolute sum is handling it okay if i == 5 or i == 15: counter.reset() # Cumulative count should be 20 (for the number of loops above) regardless # of buckets rolling assert counter.cumulative_sum(event) == 20