Example #1
0
 def test_dont_use_pylibmc_client(self):
     from beaker.ext.memcached import _load_client
     load_mock = mock.Mock()
     load_mock.return_value = _load_client('memcache')
     with mock.patch('beaker.ext.memcached._load_client', load_mock):
         cache = Cache('test', data_dir='./cache', url=mc_url, type="ext:memcached")
         assert not isinstance(cache.namespace, memcached.PyLibMCNamespaceManager)
         assert isinstance(cache.namespace, memcached.MemcachedNamespaceManager)
Example #2
0
    def test_dont_use_pylibmc_client(self):
        from beaker.ext.memcached import _load_client

        load_mock = mock.Mock()
        load_mock.return_value = _load_client("memcache")
        with mock.patch("beaker.ext.memcached._load_client", load_mock):
            cache = Cache("test", data_dir="./cache", url=mc_url, type="ext:memcached")
            assert not isinstance(cache.namespace, memcached.PyLibMCNamespaceManager)
            assert isinstance(cache.namespace, memcached.MemcachedNamespaceManager)
Example #3
0
from beaker.cache import clsmap, Cache, CacheManager, util
from beaker.middleware import CacheMiddleware, SessionMiddleware
from beaker.exceptions import InvalidCacheBackendError
from beaker.util import parse_cache_config_options
from nose import SkipTest
import unittest

try:
    from webtest import TestApp
except ImportError:
    TestApp = None

try:
    from beaker.ext import memcached
    client = memcached._load_client()
except InvalidCacheBackendError:
    raise SkipTest("an appropriate memcached backend is not installed")

mc_url = '127.0.0.1:11211'

c =client.Client([mc_url])
c.set('x', 'y')
if not c.get('x'):
    raise SkipTest("Memcached is not running at %s" % mc_url)

def teardown():
    import shutil
    shutil.rmtree('./cache', True)

def simple_session_app(environ, start_response):
Example #4
0
import mock

from beaker.cache import Cache, CacheManager, util
from beaker.middleware import CacheMiddleware, SessionMiddleware
from beaker.exceptions import InvalidCacheBackendError
from beaker.util import parse_cache_config_options
import unittest

try:
    from webtest import TestApp as WebTestApp
except ImportError:
    WebTestApp = None

try:
    from beaker.ext import memcached
    client = memcached._load_client()
except InvalidCacheBackendError:
    raise unittest.SkipTest(
        "an appropriate memcached backend is not installed")

mc_url = '127.0.0.1:11211'

c = client.Client([mc_url])
c.set('x', 'y')
if not c.get('x'):
    raise unittest.SkipTest("Memcached is not running at %s" % mc_url)


def teardown_module():
    import shutil
    shutil.rmtree('./cache', True)