keystone/tests/test_backend_memcache.py

34 lines
930 B
Python
Raw Normal View History

from keystone import test
from keystone.token.backends import memcache as token_memcache
class MemcacheClient(object):
"""Replicates a tiny subset of memcached client interface."""
def __init__(self, *args, **kwargs):
"""Ignores the passed in args."""
self.cache = {}
def get(self, key):
"""Retrieves the value for a key or None."""
return self.cache.get(key)
def set(self, key, value):
"""Sets the value for a key."""
self.cache[key] = value
return True
def delete(self, key):
try:
del self.cache[key]
except KeyError:
#NOTE(bcwaldon): python-memcached always returns the same value
pass
class MemcacheToken(test.TestCase):
def setUp(self):
super(MemcacheToken, self).setUp()
fake_client = MemcacheClient()
self.token_api = token_memcache.Token(client=fake_client)