Example #1
0
 def test_no_implementations(self):
     with mask_modules('pylibmc', 'memcache'):
         with reset_modules('celery.backends.cache'):
             from celery.backends import cache
             cache._imp = [None]
             with self.assertRaises(ImproperlyConfigured):
                 cache.get_best_memcache()
Example #2
0
 def test_pylibmc(self):
     with self.mock_pylibmc():
         with reset_modules('celery.backends.cache'):
             from celery.backends import cache
             cache._imp = [None]
             self.assertEqual(cache.get_best_memcache()[0].__module__,
                              'pylibmc')
Example #3
0
 def test_cached(self):
     with self.mock_pylibmc():
         with reset_modules('celery.backends.cache'):
             from celery.backends import cache
             cache._imp = [None]
             cache.get_best_memcache()[0](behaviors={'foo': 'bar'})
             self.assertTrue(cache._imp[0])
             cache.get_best_memcache()[0]()
Example #4
0
 def test_pylibmc_bytes_key(self):
     with 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, status=states.SUCCESS)
             self.assertEqual(b.get_result(task_id), result)