Ejemplo n.º 1
0
 def test_delta(self):
     tracker = Tracker()
     for attempt in range(tracker.backoff.max_attempts):
         if attempt == 0:
             assert tracker.delta() == timedelta()
             continue
         tracker.attempt()
         assert tracker.delta() == tracker.backoff.deltas[attempt]
         assert tracker.delta() == timedelta(seconds=2**attempt)
     # Should cap at max_attempts to highest delta
     tracker.attempts = tracker.backoff.max_attempts + 20
     assert tracker.delta() == timedelta(
         seconds=2**tracker.backoff.max_attempts)
Ejemplo n.º 2
0
 def test_expires_overflow(self):
     tracker = Tracker()
     tracker.attempts = 15
     tracker.last_attempt = datetime.max
     assert tracker.expires() == datetime.max