Exemple #1
0
 def test_five_retries(self):
     # (Five retries because RepeatRecord.max_possible_tries is 6)
     for last_checked, now, expected_interval_hours in [
         (None, fromisoformat("2020-01-01 00:00:00"), 1),
         (fromisoformat("2020-01-01 00:00:00"), fromisoformat("2020-01-01 01:00:00"), 3),
         (fromisoformat("2020-01-01 01:00:00"), fromisoformat("2020-01-01 04:00:00"), 9),
         (fromisoformat("2020-01-01 04:00:00"), fromisoformat("2020-01-01 13:00:00"), 27),
         (fromisoformat("2020-01-01 13:00:00"), fromisoformat("2020-01-02 16:00:00"), 81),
     ]:
         interval = _get_retry_interval(last_checked, now)
         self.assertEqual(interval, timedelta(hours=expected_interval_hours))
Exemple #2
0
 def test_three_times_interval(self):
     last_checked = fromisoformat("2020-01-01 00:00:00")
     now = fromisoformat("2020-01-01 01:00:00")
     interval = _get_retry_interval(last_checked, now)
     self.assertEqual(interval, timedelta(hours=3))
Exemple #3
0
 def test_max_interval(self):
     last_checked = fromisoformat("2020-01-01 00:00:00")
     now = fromisoformat("2020-02-01 00:00:00")
     interval = _get_retry_interval(last_checked, now)
     self.assertEqual(interval, MAX_RETRY_WAIT)
Exemple #4
0
 def test_no_last_checked(self):
     last_checked = None
     now = fromisoformat("2020-01-01 00:05:00")
     interval = _get_retry_interval(last_checked, now)
     self.assertEqual(interval, MIN_RETRY_WAIT)