def test_reamaining_throttle_empty(self, sleep): q = models.TaskQueue(rate_limit=3600) q.throttle(timedelta(seconds=2)) self.assertFalse(sleep.called)
def test_reamaining_throttle_empty(self, sleep): q = models.TaskQueue(max_tasks_per_hour=3600) q.throttle(timedelta(seconds=1)) self.assertFalse(sleep.called)
def test_throttle(self, sleep): q = models.TaskQueue(rate_limit=60) q.throttle(timedelta(seconds=1)) sleep.assert_called_with(59)
def test_time_interval(self): q = models.TaskQueue(rate_limit=1800) self.assertEqual(q.time_interval.total_seconds(), 2)
def test_no_throttling(self, sleep): q = models.TaskQueue() q.throttle(timedelta(seconds=1)) self.assertFalse(sleep.called)