Exemple #1
0
 def test_count_subkey(self):
     rc = RedisCounter(TEST_REDIS)
     rc.add('some_key', 10, 10)
     rc.count('some_key', 'one')
     rc.count('some_key', 'two')
     rc.count('some_key', 'two')
     self.assertEqual(rc.get('some_key', 'one'), 1)
     self.assertEqual(rc.get('some_key', 'two'), 2)
Exemple #2
0
 def test_clear(self):
     rc = RedisCounter(TEST_REDIS)
     rc.add('some_key', 5, 10)
     rc.count('some_key', 'one')
     rc.count('some_key', 'two')
     rc.count('some_key', 'three')
     rc.clear('some_key')
     #~ raise
     self.assertEqual(rc.get('some_key', 'one'), None)
     self.assertEqual(rc.get('some_key', 'two'), None)
     self.assertEqual(rc.get('some_key', 'three'), None)
Exemple #3
0
 def test_reset_key(self):
     rc = RedisCounter(TEST_REDIS)
     rc.add('some_key', 1, 10)
     rc.count('some_key')
     with self.assertRaises(CountLimit):
         rc.count('some_key')
     rc.reset('some_key')
     rc.count('some_key')
Exemple #4
0
 def test_count_weight(self):
     rc = RedisCounter(TEST_REDIS)
     rc.add('some_key', 5, 10)
     with self.assertRaises(CountLimit):
         rc.count('some_key', weight=6)
Exemple #5
0
 def test_count_key_must_exist(self):
     rc = RedisCounter(TEST_REDIS)
     with self.assertRaises(KeyNotFound):
         rc.count('some_key')
     rc.add('some_key', 10, 10)
     rc.count('some_key')