Ejemplo n.º 1
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().__module__,
                              'pylibmc')
Ejemplo n.º 2
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()
Ejemplo n.º 3
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()
Ejemplo n.º 4
0
 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()
Ejemplo n.º 5
0
 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()
Ejemplo n.º 6
0
 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")
Ejemplo n.º 7
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()
Ejemplo n.º 8
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()
Ejemplo n.º 9
0
 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")
Ejemplo n.º 10
0
 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')
Ejemplo n.º 11
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')
             b.store_result(task_id, result, status=states.SUCCESS)
             self.assertEqual(b.get_result(task_id), result)
Ejemplo n.º 12
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')
             b.store_result(task_id, result, status=states.SUCCESS)
             self.assertEqual(b.get_result(task_id), result)
Ejemplo n.º 13
0
 def test_memcache_unicode_key(self):
     with self.mock_memcache():
         with reset_modules('celery.backends.cache'):
             with mask_modules('pylibmc'):
                 from celery.backends import cache
                 cache._imp = [None]
                 task_id, result = string(uuid()), 42
                 b = cache.CacheBackend(backend='memcache')
                 b.store_result(task_id, result, status=states.SUCCESS)
                 self.assertEqual(b.get_result(task_id), result)
Ejemplo n.º 14
0
 def test_memcache_unicode_key(self):
     with self.mock_memcache():
         with reset_modules("celery.backends.cache"):
             with mask_modules("pylibmc"):
                 from celery.backends import cache
                 cache._imp = [None]
                 task_id, result = unicode(uuid()), 42
                 b = cache.CacheBackend(backend='memcache')
                 b.store_result(task_id, result, status=states.SUCCESS)
                 self.assertEqual(b.get_result(task_id), result)
Ejemplo n.º 15
0
 def test_process_name_wo_mp(self):
     with mask_modules("multiprocessing"):
         with reset_modules("celery.apps.worker"):
             from celery.apps.worker import get_process_name
             self.assertIsNone(get_process_name())
Ejemplo n.º 16
0
 def test_cpu_count_no_mp(self):
     with mask_modules("multiprocessing"):
         with reset_modules("celery.apps.worker"):
             from celery.apps.worker import cpu_count
             self.assertEqual(cpu_count(), 2)
Ejemplo n.º 17
0
 def test_no_multiprocessing(self):
     with mask_modules("multiprocessing"):
         with reset_modules("celery.apps.worker"):
             from celery.apps.worker import multiprocessing
             self.assertIsNone(multiprocessing)
Ejemplo n.º 18
0
 def test_no_multiprocessing(self):
     with mask_modules("multiprocessing"):
         with reset_modules("celery.apps.worker"):
             from celery.apps.worker import multiprocessing
             self.assertIsNone(multiprocessing)
Ejemplo n.º 19
0
 def test_process_name_wo_mp(self):
     with mask_modules("multiprocessing"):
         with reset_modules("celery.apps.worker"):
             from celery.apps.worker import get_process_name
             self.assertIsNone(get_process_name())
Ejemplo n.º 20
0
 def test_cpu_count_no_mp(self):
     with mask_modules("multiprocessing"):
         with reset_modules("celery.apps.worker"):
             from celery.apps.worker import cpu_count
             self.assertEqual(cpu_count(), 2)