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()
def test_cached(self): with self.mock_pylibmc(): with reset_modules("celery.backends.cache"): from celery.backends import cache cache.get_best_memcache(behaviors={"foo": "bar"}) self.assertTrue(cache._imp[0]) cache.get_best_memcache()
def test_cached(self): with self.mock_pylibmc(): with mock.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]()
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(behaviors={"foo": "bar"}) self.assertTrue(cache._imp[0]) cache.get_best_memcache()
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]()
def test_pylibmc(self): pylibmc = self.mock_pylibmc() pylibmc.next() sys.modules.pop("celery.backends.cache", None) from celery.backends import cache self.assertEqual(cache.get_best_memcache().__module__, "pylibmc") pylibmc.next()
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')
def test_pylibmc(self): pylibmc = self.mock_pylibmc() pylibmc.next() from celery.backends import cache cache._imp = [None] self.assertEqual(cache.get_best_memcache().__module__, "pylibmc") pylibmc.next()
def test_pylibmc(self): with self.mock_pylibmc(): with mock.reset_modules('celery.backends.cache'): from celery.backends import cache cache._imp = [None] self.assertEqual(cache.get_best_memcache()[0].__module__, 'pylibmc')
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')
def test_pylibmc(self): with reset_modules("celery.backends.cache"): with self.mock_pylibmc(): from celery.backends import cache cache._imp = [None] self.assertEqual(cache.get_best_memcache().__module__, "pylibmc")
def test_memcache(self): with self.mock_memcache(): with reset_modules("celery.backends.cache"): with mask_modules("pylibmc"): from celery.backends import cache cache._imp = [None] self.assertEqual(cache.get_best_memcache().__module__, "memcache")
def test_memcache(self): with self.mock_memcache(): with mock.reset_modules('celery.backends.cache'): with mock.mask_modules('pylibmc'): from celery.backends import cache cache._imp = [None] assert (cache.get_best_memcache()[0]().__module__ == 'memcache')
def get_harness(pool): mc = get_best_memcache()[0](CONFIG.memcache) key = CONFIG.web._MC_KEY + pool try: i = mc.incr(key) except: i = mc.set(key, 0) harnesses = CONFIG.web.harnesses[pool] return os.path.join(config_dir, harnesses[i % len(harnesses)])
def get_harness(config, pool): """ Determine which of the set of harness should be selected for this task. """ mc = get_best_memcache()[0](config.memcache) # returns a Celery Config object, then not sure what happens, no # docs online for this Celery method. key = config.web._MC_KEY + pool try: i = mc.incr(key) except: LOG.warning("Exception in Celery Memcache, defaulting to first harness") i = mc.set(key, 0) harnesses = config.web.harnesses[pool] harness_path = os.path.join(config.dir, harnesses[i % len(harnesses)]) LOG.info("Selected the test harness: " + harness_path) return harness_path
def with_no_pylibmc(): from celery.backends import cache cache._imp = [None] self.assertEqual(cache.get_best_memcache().__module__, "memcache")
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'
def with_no_pylibmc(): sys.modules.pop("celery.backends.cache", None) from celery.backends import cache self.assertEqual(cache.get_best_memcache().__module__, "memcache")
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()