def test_comparison(self):
     self.assertTrue(
         limits.RateLimitItemPerSecond(1) < limits.RateLimitItemPerMinute(1)
     )
     self.assertTrue(
         limits.RateLimitItemPerMinute(1) < limits.RateLimitItemPerHour(1))
     self.assertTrue(
         limits.RateLimitItemPerHour(1) < limits.RateLimitItemPerDay(1))
     self.assertTrue(
         limits.RateLimitItemPerDay(1) < limits.RateLimitItemPerMonth(1))
     self.assertTrue(
         limits.RateLimitItemPerMonth(1) < limits.RateLimitItemPerYear(1))
Beispiel #2
0
 def test_seconds_value(self):
     self.assertEqual(limits.RateLimitItemPerHour(1).get_expiry(), 60*60)
     self.assertEqual(limits.RateLimitItemPerMinute(1).get_expiry(), 60)
     self.assertEqual(limits.RateLimitItemPerSecond(1).get_expiry(), 1)
     self.assertEqual(limits.RateLimitItemPerDay(1).get_expiry(), 60*60*24)
     self.assertEqual(limits.RateLimitItemPerMonth(1).get_expiry(), 60*60*24*30)
     self.assertEqual(limits.RateLimitItemPerYear(1).get_expiry(), 60*60*24*30*12)
Beispiel #3
0
 def test_singles(self):
     for rl_string in ["1 per hour", "1/HOUR", "1/Hour"]:
         self.assertEqual(
             parse( rl_string),
             limits.RateLimitItemPerHour(1)
         )
     for rl_string in ["1 per minute", "1/MINUTE", "1/Minute"]:
         self.assertEqual(
             parse( rl_string),
             limits.RateLimitItemPerMinute(1)
         )
     for rl_string in ["1 per second", "1/SECOND", "1 / Second"]:
         self.assertEqual(
             parse( rl_string),
             limits.RateLimitItemPerSecond(1)
         )
     for rl_string in ["1 per day", "1/DAY", "1 / Day"]:
         self.assertEqual(
             parse( rl_string),
             limits.RateLimitItemPerDay(1)
         )
     for rl_string in ["1 per month", "1/MONTH", "1 / Month"]:
         self.assertEqual(
             parse( rl_string),
             limits.RateLimitItemPerMonth(1)
         )
     for rl_string in ["1 per year", "1/Year", "1 / year"]:
         self.assertEqual(
             parse( rl_string),
             limits.RateLimitItemPerYear(1)
         )
Beispiel #4
0
 def test_representation(self):
     self.assertTrue("1 per 1 hour" in str(limits.RateLimitItemPerHour(1)))
     self.assertTrue("1 per 1 minute" in str(limits.RateLimitItemPerMinute(1)))
     self.assertTrue("1 per 1 second" in str(limits.RateLimitItemPerSecond(1)))
     self.assertTrue("1 per 1 day" in str(limits.RateLimitItemPerDay(1)))
     self.assertTrue("1 per 1 month" in str(limits.RateLimitItemPerMonth(1)))
     self.assertTrue("1 per 1 year" in str(limits.RateLimitItemPerYear(1)))