示例#1
0
    def test_stale_timestamp(self):
        size = 10
        step = 5
        expires = 20
        now_timestamp = 60

        window = SlidingWindow(size, step, expires=expires)
        for time in range(0, now_timestamp - expires):
            print('TIME: %r NOW TIMESTAMP: %r' % (time, now_timestamp))
            assert window.stale(time, now_timestamp) is True
示例#2
0
    def test_non_stale_timestamp(self):
        size = 10
        step = 5
        expires = 20

        now_timestamp = 60

        window = SlidingWindow(size, step, expires=expires)
        for time in range(now_timestamp - expires + 1, now_timestamp):
            assert window.stale(time, now_timestamp) is False