示例#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')
示例#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()
示例#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()
示例#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()
示例#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()
示例#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")
示例#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()
示例#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()
示例#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")
示例#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')
示例#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)
示例#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)
示例#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)
示例#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)
示例#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())
示例#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)
示例#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)
示例#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)
示例#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())
示例#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)