Exemplo n.º 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')
Exemplo n.º 2
0
    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)
Exemplo n.º 3
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')
Exemplo n.º 4
0
 def test_accessed(self):
     throttle_1 = BaseThrottle()
     self.assertEqual(throttle_1.accessed('foobaz'), None)
Exemplo n.º 5
0
 def test_should_be_throttled(self):
     throttle_1 = BaseThrottle()
     self.assertEqual(throttle_1.should_be_throttled('foobaz'), False)
Exemplo n.º 6
0
 def test_accessed(self):
     throttle_1 = BaseThrottle()
     self.assertEqual(throttle_1.accessed('foobaz'), None)
Exemplo n.º 7
0
 def test_should_be_throttled(self):
     throttle_1 = BaseThrottle()
     self.assertEqual(throttle_1.should_be_throttled('foobaz'), False)