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