Esempio n. 1
0
 def test_memcache(self, mask_modules):
     with self.mock_memcache():
         with conftest.reset_modules('celery.backends.cache'):
             from celery.backends import cache
             cache._imp = [None]
             assert (cache.get_best_memcache()[0]().__module__ ==
                     'memcache')
Esempio n. 2
0
 def test_cached(self):
     with self.mock_pylibmc():
         with conftest.reset_modules('celery.backends.cache'):
             from celery.backends import cache
             cache._imp = [None]
             cache.get_best_memcache()[0](behaviors={'foo': 'bar'})
             assert cache._imp[0]
             cache.get_best_memcache()[0]()
Esempio n. 3
0
 def test_pylibmc_bytes_key(self):
     with conftest.reset_modules('celery.backends.cache'):
         with self.mock_pylibmc():
             from celery.backends import cache
             cache._imp = [None]
             task_id, result = str_to_bytes(uuid()), 42
             b = cache.CacheBackend(backend='memcache', app=self.app)
             b.store_result(task_id, result, state=states.SUCCESS)
             assert b.get_result(task_id) == result
Esempio n. 4
0
 def test_no_implementations(self, mask_modules):
     with conftest.reset_modules('celery.backends.cache'):
         from celery.backends import cache
         cache._imp = [None]
         with pytest.raises(ImproperlyConfigured):
             cache.get_best_memcache()
Esempio n. 5
0
 def test_pylibmc(self):
     with self.mock_pylibmc():
         with conftest.reset_modules('celery.backends.cache'):
             from celery.backends import cache
             cache._imp = [None]
             assert cache.get_best_memcache()[0].__module__ == 'pylibmc'