Beispiel #1
0
 def test_throttle(self):
     from datetime import datetime
     from datetime import timedelta
     queue = self._make_one()
     user = '******'
     now = datetime(2010, 5, 12, 2, 42)
     self.failIf(queue.is_throttled(user, now))
     queue.throttle(user, now + timedelta(minutes=5))
     self.failUnless(queue.is_throttled(user, now))
     now += timedelta(minutes=6)
     self.failIf(queue.is_throttled(user, now))
     now += timedelta(minutes=6)
     self.failIf(queue.is_throttled(user, now))
Beispiel #2
0
 def test_throttle(self):
     from datetime import datetime
     from datetime import timedelta
     queue = self._make_one()
     user = '******'
     now = datetime(2010, 5, 12, 2, 42)
     self.failIf(queue.is_throttled(user, now))
     queue.throttle(user, now + timedelta(minutes=5))
     self.failUnless(queue.is_throttled(user, now))
     now += timedelta(minutes=6)
     self.failIf(queue.is_throttled(user, now))
     now += timedelta(minutes=6)
     self.failIf(queue.is_throttled(user, now))
Beispiel #3
0
 def test_throttle_with_headers(self):
     from datetime import datetime
     from datetime import timedelta
     queue = self._make_one()
     user = '******'
     now = datetime(2010, 5, 12, 2, 42)
     headers = dict(A='foo', B='bar')
     self.failIf(queue.is_throttled(user, now, headers))
     queue.throttle(user, now + timedelta(minutes=5), headers)
     self.failUnless(queue.is_throttled(user, now, headers))
     self.failIf(queue.is_throttled(user, now))
     now += timedelta(minutes=6)
     self.failIf(queue.is_throttled(user, now, headers))
     now += timedelta(minutes=6)
     self.failIf(queue.is_throttled(user, now, headers))
Beispiel #4
0
 def test_throttle_with_headers(self):
     from datetime import datetime
     from datetime import timedelta
     queue = self._make_one()
     user = '******'
     now = datetime(2010, 5, 12, 2, 42)
     headers = dict(A='foo', B='bar')
     self.failIf(queue.is_throttled(user, now, headers))
     queue.throttle(user, now + timedelta(minutes=5), headers)
     self.failUnless(queue.is_throttled(user, now, headers))
     self.failIf(queue.is_throttled(user, now))
     now += timedelta(minutes=6)
     self.failIf(queue.is_throttled(user, now, headers))
     now += timedelta(minutes=6)
     self.failIf(queue.is_throttled(user, now, headers))