Ejemplo n.º 1
0
    def test_delete_with_prefix_version(self, cache_name):
        cache = caches[cache_name]

        cache.set('V12', True, version=1)
        cache.set('V12', True, version=2)
        cache.set('V2', True, version=2)
        cache.set('V3', True, version=3)

        has_key = cache.has_key  # avoid lint error

        assert cache.delete_with_prefix('V', version=1) == 1
        assert not has_key('V12', version=1)
        assert has_key('V12', version=2)
        assert has_key('V2', version=2)
        assert has_key('V3', version=3)

        assert cache.delete_with_prefix('V', version=2) == 2
        assert not has_key('V12', version=1)
        assert not has_key('V12', version=2)
        assert not has_key('V2', version=2)
        assert has_key('V3', version=3)

        assert cache.delete_with_prefix('V', version=3) == 1
        assert not has_key('V12', version=1)
        assert not has_key('V12', version=2)
        assert not has_key('V2', version=2)
        assert not has_key('V3', version=3)
Ejemplo n.º 2
0
    def test_delete_with_prefix_version(self, cache_name):
        cache = caches[cache_name]

        cache.set("V12", True, version=1)
        cache.set("V12", True, version=2)
        cache.set("V2", True, version=2)
        cache.set("V3", True, version=3)

        has_key = cache.has_key  # avoid lint error

        assert cache.delete_with_prefix("V", version=1) == 1
        assert not has_key("V12", version=1)
        assert has_key("V12", version=2)
        assert has_key("V2", version=2)
        assert has_key("V3", version=3)

        assert cache.delete_with_prefix("V", version=2) == 2
        assert not has_key("V12", version=1)
        assert not has_key("V12", version=2)
        assert not has_key("V2", version=2)
        assert has_key("V3", version=3)

        assert cache.delete_with_prefix("V", version=3) == 1
        assert not has_key("V12", version=1)
        assert not has_key("V12", version=2)
        assert not has_key("V2", version=2)
        assert not has_key("V3", version=3)
Ejemplo n.º 3
0
    def test_delete_with_prefix(self, cache_name):
        cache = caches[cache_name]

        # Check it runs on an empty cache
        assert cache.delete_with_prefix("") == 0
        assert cache.delete_with_prefix("K") == 0

        cache.set("A1", True)
        cache.set("A2", True)
        cache.set("K2", True)
        cache.set("K44", True)

        assert cache.keys_with_prefix("") == {"A1", "A2", "K2", "K44"}
        assert cache.delete_with_prefix("A") == 2
        assert cache.keys_with_prefix("") == {"K2", "K44"}
        assert cache.delete_with_prefix("A") == 0
        assert cache.keys_with_prefix("") == {"K2", "K44"}
        assert cache.delete_with_prefix("K") == 2
        assert cache.keys_with_prefix("K") == set()
        assert cache.keys_with_prefix("") == set()
Ejemplo n.º 4
0
    def test_delete_with_prefix(self, cache_name):
        cache = caches[cache_name]

        # Check it runs on an empty cache
        assert cache.delete_with_prefix('') == 0
        assert cache.delete_with_prefix('K') == 0

        cache.set('A1', True)
        cache.set('A2', True)
        cache.set('K2', True)
        cache.set('K44', True)

        assert cache.keys_with_prefix('') == {'A1', 'A2', 'K2', 'K44'}
        assert cache.delete_with_prefix('A') == 2
        assert cache.keys_with_prefix('') == {'K2', 'K44'}
        assert cache.delete_with_prefix('A') == 0
        assert cache.keys_with_prefix('') == {'K2', 'K44'}
        assert cache.delete_with_prefix('K') == 2
        assert cache.keys_with_prefix('K') == set()
        assert cache.keys_with_prefix('') == set()
Ejemplo n.º 5
0
    def test_delete_with_prefix(self, cache_name):
        cache = caches[cache_name]

        # Check it runs on an empty cache
        assert cache.delete_with_prefix('') == 0
        assert cache.delete_with_prefix('K') == 0

        cache.set('A1', True)
        cache.set('A2', True)
        cache.set('K2', True)
        cache.set('K44', True)

        assert cache.keys_with_prefix('') == {'A1', 'A2', 'K2', 'K44'}
        assert cache.delete_with_prefix('A') == 2
        assert cache.keys_with_prefix('') == {'K2', 'K44'}
        assert cache.delete_with_prefix('A') == 0
        assert cache.keys_with_prefix('') == {'K2', 'K44'}
        assert cache.delete_with_prefix('K') == 2
        assert cache.keys_with_prefix('K') == set()
        assert cache.keys_with_prefix('') == set()
Ejemplo n.º 6
0
 def test_delete_with_prefix_with_no_reverse_works(self):
     cache.set_many({"K1": "value", "K2": "value2", "B2": "Anothervalue"})
     assert cache.delete_with_prefix("K") == 2
     assert cache.get_many(["K1", "K2", "B2"]) == {"B2": "Anothervalue"}
Ejemplo n.º 7
0
 def test_delete_with_prefix_with_no_reverse_works(self):
     cache.set_many({'K1': 'value', 'K2': 'value2', 'B2': 'Anothervalue'})
     assert cache.delete_with_prefix('K') == 2
     assert cache.get_many(['K1', 'K2', 'B2']) == {'B2': 'Anothervalue'}
Ejemplo n.º 8
0
 def test_delete_with_prefix_with_no_reverse_works(self):
     cache.set_many({'K1': 'value', 'K2': 'value2', 'B2': 'Anothervalue'})
     assert cache.delete_with_prefix('K') == 2
     assert cache.get_many(['K1', 'K2', 'B2']) == {'B2': 'Anothervalue'}