Add a unit test for the snapshot cache

This commit is contained in:
Mark Haines 2015-12-23 11:48:03 +00:00
parent 517fb9a023
commit 7fa71e3267
2 changed files with 62 additions and 2 deletions

View file

@ -28,14 +28,14 @@ class SnapshotCache(object):
def rotate(self, time_now_ms):
# Rotate once if the cache duration has passed since the last rotation.
if time_now_ms - self.time_last_rotated_ms > self.DURATION_MS:
if time_now_ms - self.time_last_rotated_ms >= self.DURATION_MS:
self.prev_result_cache = self.next_result_cache
self.next_result_cache = {}
self.time_last_rotated_ms += self.DURATION_MS
# Rotate again if the cache duration has passed twice since the last
# rotation.
if time_now_ms - self.time_last_rotated_ms > self.DURATION_MS:
if time_now_ms - self.time_last_rotated_ms >= self.DURATION_MS:
self.prev_result_cache = self.next_result_cache
self.next_result_cache = {}
self.time_last_rotated_ms = time_now_ms