Beispiel #1
0
 def test_convert_identifier_to_key(self):
     throttle_1 = BaseThrottle()
     self.assertEqual(throttle_1.convert_identifier_to_key(''), '_accesses')
     self.assertEqual(throttle_1.convert_identifier_to_key('alnum10'), 'alnum10_accesses')
     self.assertEqual(throttle_1.convert_identifier_to_key('Mr. Pants'), 'Mr.Pants_accesses')
     self.assertEqual(throttle_1.convert_identifier_to_key('Mr_Pants'), 'Mr_Pants_accesses')
     self.assertEqual(throttle_1.convert_identifier_to_key('%^@@$&!a'), 'a_accesses')
    def test_init(self):
        throttle_1 = BaseThrottle()
        self.assertEqual(throttle_1.throttle_at, 150)
        self.assertEqual(throttle_1.timeframe, 3600)
        self.assertEqual(throttle_1.expiration, 604800)

        throttle_2 = BaseThrottle(throttle_at=50,
                                  timeframe=60 * 30,
                                  expiration=1)
        self.assertEqual(throttle_2.throttle_at, 50)
        self.assertEqual(throttle_2.timeframe, 1800)
        self.assertEqual(throttle_2.expiration, 1)
 def test_convert_identifier_to_key(self):
     throttle_1 = BaseThrottle()
     self.assertEqual(throttle_1.convert_identifier_to_key(''), '_accesses')
     self.assertEqual(throttle_1.convert_identifier_to_key('alnum10'),
                      'alnum10_accesses')
     self.assertEqual(throttle_1.convert_identifier_to_key('Mr. Pants'),
                      'Mr.Pants_accesses')
     self.assertEqual(throttle_1.convert_identifier_to_key('Mr_Pants'),
                      'Mr_Pants_accesses')
     self.assertEqual(throttle_1.convert_identifier_to_key('%^@@$&!a'),
                      'a_accesses')
Beispiel #4
0
 def test_accessed(self):
     throttle_1 = BaseThrottle()
     self.assertEqual(throttle_1.accessed('foobaz'), None)
Beispiel #5
0
 def test_should_be_throttled(self):
     throttle_1 = BaseThrottle()
     self.assertEqual(throttle_1.should_be_throttled('foobaz'), False)
 def test_accessed(self):
     throttle_1 = BaseThrottle()
     self.assertEqual(throttle_1.accessed('foobaz'), None)
 def test_should_be_throttled(self):
     throttle_1 = BaseThrottle()
     self.assertEqual(throttle_1.should_be_throttled('foobaz'), False)