Example #1
0
 def test_old_repeater_no_records(self):
     four_months = timedelta(days=120)
     rep = FormRepeater(
         domain=DOMAIN,
         url='https://server.example.com/api/',
         started_at=datetime.utcnow() - four_months,
     )
     self.assertTrue(rep.is_connection_working())
Example #2
0
 def test_newish_repeater_too_many_failed_records(self):
     two_months = timedelta(days=60)
     rep = FormRepeater(
         domain=DOMAIN,
         url='https://server.example.com/api/',
         started_at=datetime.utcnow() - two_months,
         failure_streak=AUTOPAUSE_THRESHOLD + 1,
     )
     self.assertFalse(rep.is_connection_working())
Example #3
0
 def test_new_repeater(self):
     rep = FormRepeater(
         domain=DOMAIN,
         url='https://server.example.com/api/',
     )
     a_moment_ago = datetime.utcnow() - rep.started_at
     self.assertLess(a_moment_ago, timedelta(milliseconds=1))
     self.assertIsNone(rep.last_success_at)
     self.assertEqual(rep.failure_streak, 0)
     self.assertTrue(rep.is_connection_working())
Example #4
0
 def test_old_repeater_recent_success(self):
     two_months = timedelta(days=60)
     four_months = timedelta(days=120)
     rep = FormRepeater(
         domain=DOMAIN,
         url='https://server.example.com/api/',
         started_at=datetime.utcnow() - four_months,
         failure_streak=AUTOPAUSE_THRESHOLD,
         last_success_at=datetime.utcnow() - two_months,
     )
     self.assertTrue(rep.is_connection_working())