コード例 #1
0
ファイル: test_serialization.py プロジェクト: screeley/celery
 def test_no_cpickle(self):
     from celery.tests.utils import mask_modules
     del(sys.modules["celery.serialization"])
     with mask_modules("cPickle"):
         from celery.serialization import pickle
         import pickle as orig_pickle
         self.assertTrue(pickle.dumps is orig_pickle.dumps)
コード例 #2
0
ファイル: test_cache.py プロジェクト: FreakTheMighty/celery
 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
ファイル: test_database.py プロジェクト: kornholi/celery
    def test_missing_SQLAlchemy_raises_ImproperlyConfigured(self):

        def with_SQLAlchemy_masked(_val):
            from celery.backends.database import _sqlalchemy_installed
            self.assertRaises(ImproperlyConfigured, _sqlalchemy_installed)

        execute_context(mask_modules("sqlalchemy"), with_SQLAlchemy_masked)
コード例 #5
0
ファイル: test_redis.py プロジェクト: aaronelliotross/celery
 def test_tyrant_None_if_tyrant_not_installed(self):
     from celery.tests.utils import mask_modules
     prev = sys.modules.pop("celery.backends.pyredis")
     with mask_modules("redis"):
         from celery.backends.pyredis import redis
         self.assertTrue(redis is None)
     sys.modules["celery.backends.pyredis"] = prev
コード例 #6
0
ファイル: test_cache.py プロジェクト: FreakTheMighty/celery
 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")
コード例 #7
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')
コード例 #8
0
ファイル: test_redis.py プロジェクト: WoLpH/celery
 def test_redis_None_if_redis_not_installed(self):
     prev = sys.modules.pop("celery.backends.redis")
     try:
         with mask_modules("redis"):
             from celery.backends.redis import redis
             self.assertIsNone(redis)
     finally:
         sys.modules["celery.backends.redis"] = prev
コード例 #9
0
 def test_no_cpickle(self):
     from celery.tests.utils import mask_modules
     prev = sys.modules.pop("billiard.serialization")
     with mask_modules("cPickle"):
         from billiard.serialization import pickle
         import pickle as orig_pickle
         self.assertTrue(pickle.dumps is orig_pickle.dumps)
     sys.modules["billiard.serialization"] = prev
コード例 #10
0
 def test_no_cpickle(self):
     prev = sys.modules.pop('celery.utils.serialization', None)
     try:
         with mask_modules('cPickle'):
             from celery.utils.serialization import pickle
             import pickle as orig_pickle
             self.assertIs(pickle.dumps, orig_pickle.dumps)
     finally:
         sys.modules['celery.utils.serialization'] = prev
コード例 #11
0
 def test_no_cpickle(self):
     prev = sys.modules.pop("celery.utils.serialization", None)
     try:
         with mask_modules("cPickle"):
             from celery.utils.serialization import pickle
             import pickle as orig_pickle
             self.assertIs(pickle.dumps, orig_pickle.dumps)
     finally:
         sys.modules["celery.utils.serialization"] = prev
コード例 #12
0
 def test_memcache_bytes_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 = 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
ファイル: test_cache.py プロジェクト: sunliwen/celery
 def test_memcache_bytes_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 = 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)
コード例 #14
0
 def test_tyrant_None_if_tyrant_not_installed(self):
     prev = sys.modules.pop("celery.backends.pyredis")
     try:
         def with_redis_masked(_val):
             from celery.backends.pyredis import redis
             self.assertIsNone(redis)
         context = mask_modules("redis")
         execute_context(context, with_redis_masked)
     finally:
         sys.modules["celery.backends.pyredis"] = prev
コード例 #15
0
ファイル: test_redis.py プロジェクト: kornholi/celery
    def test_redis_None_if_redis_not_installed(self):
        prev = sys.modules.pop("celery.backends.pyredis")
        try:

            def with_redis_masked(_val):
                from celery.backends.pyredis import redis
                self.assertIsNone(redis)
            context = mask_modules("redis")
            execute_context(context, with_redis_masked)
        finally:
            sys.modules["celery.backends.pyredis"] = prev
コード例 #16
0
ファイル: test_utils.py プロジェクト: maximbo/celery
 def test_gen_unique_id_without_ctypes(self):
     from celery.tests.utils import mask_modules
     old_utils = sys.modules.pop("celery.utils")
     try:
         with mask_modules("ctypes"):
             from celery.utils import ctypes, gen_unique_id
             self.assertTrue(ctypes is None)
             uuid = gen_unique_id()
             self.assertTrue(uuid)
             self.assertTrue(isinstance(uuid, basestring))
     finally:
         sys.modules["celery.utils"] = old_utils
    def test_no_implementations(self):
        def with_no_memcache_libs():
            sys.modules.pop("celery.backends.cache", None)
            from celery.backends import cache
            self.assertRaises(ImproperlyConfigured, cache.get_best_memcache)

        context = mask_modules("pylibmc", "memcache")
        context.__enter__()
        try:
            with_no_memcache_libs()
        finally:
            context.__exit__(None, None, None)
コード例 #18
0
ファイル: test_serialization.py プロジェクト: kmike/celery
    def test_no_cpickle(self):
        prev = sys.modules.pop("billiard.serialization")
        try:
            def with_cPickle_masked(_val):
                from billiard.serialization import pickle
                import pickle as orig_pickle
                self.assertIs(pickle.dumps, orig_pickle.dumps)

            context = mask_modules("cPickle")
            execute_context(context, with_cPickle_masked)

        finally:
            sys.modules["billiard.serialization"] = prev
コード例 #19
0
ファイル: test_cache.py プロジェクト: aleszoulek/celery
    def test_no_implementations(self):

        def with_no_memcache_libs():
            sys.modules.pop("celery.backends.cache", None)
            from celery.backends import cache
            self.assertRaises(ImproperlyConfigured, cache.get_best_memcache)

        context = mask_modules("pylibmc", "memcache")
        context.__enter__()
        try:
            with_no_memcache_libs()
        finally:
            context.__exit__(None, None, None)
コード例 #20
0
ファイル: test_serialization.py プロジェクト: kornholi/celery
    def test_no_cpickle(self):
        prev = sys.modules.pop("celery.utils.serialization", None)
        try:

            def with_cPickle_masked(_val):
                from celery.utils.serialization import pickle
                import pickle as orig_pickle
                self.assertIs(pickle.dumps, orig_pickle.dumps)

            context = mask_modules("cPickle")
            execute_context(context, with_cPickle_masked)

        finally:
            sys.modules["celery.utils.serialization"] = prev
    def test_memcache(self):
        def with_no_pylibmc():
            sys.modules.pop("celery.backends.cache", None)
            from celery.backends import cache
            self.assertEqual(cache.get_best_memcache().__module__, "memcache")

        context = mask_modules("pylibmc")
        context.__enter__()
        try:
            memcache = self.mock_memcache()
            memcache.next()
            with_no_pylibmc()
            memcache.next()
        finally:
            context.__exit__(None, None, None)
コード例 #22
0
ファイル: test_cache.py プロジェクト: aleszoulek/celery
    def test_memcache(self):

        def with_no_pylibmc():
            sys.modules.pop("celery.backends.cache", None)
            from celery.backends import cache
            self.assertEqual(cache.get_best_memcache().__module__, "memcache")

        context = mask_modules("pylibmc")
        context.__enter__()
        try:
            memcache = self.mock_memcache()
            memcache.next()
            with_no_pylibmc()
            memcache.next()
        finally:
            context.__exit__(None, None, None)
コード例 #23
0
ファイル: test_utils.py プロジェクト: jokar/minion
    def test_gen_unique_id_without_ctypes(self):
        old_utils = sys.modules.pop("celery.utils")

        def with_ctypes_masked(_val):
            from celery.utils import ctypes, gen_unique_id

            self.assertIsNone(ctypes)
            uuid = gen_unique_id()
            self.assertTrue(uuid)
            self.assertIsInstance(uuid, basestring)

        try:
            context = mask_modules("ctypes")
            execute_context(context, with_ctypes_masked)
        finally:
            sys.modules["celery.utils"] = old_utils
コード例 #24
0
    def test_gen_unique_id_without_ctypes(self):
        old_utils = sys.modules.pop("celery.utils")

        def with_ctypes_masked(_val):
            from celery.utils import ctypes, gen_unique_id

            self.assertIsNone(ctypes)
            uuid = gen_unique_id()
            self.assertTrue(uuid)
            self.assertIsInstance(uuid, basestring)

        try:
            context = mask_modules("ctypes")
            execute_context(context, with_ctypes_masked)
        finally:
            sys.modules["celery.utils"] = old_utils
コード例 #25
0
ファイル: test_celeryd.py プロジェクト: ivirabyan/celery
 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)
コード例 #26
0
    def test_missing_SQLAlchemy_raises_ImproperlyConfigured(self):
        def with_SQLAlchemy_masked(_val):
            from celery.backends.database import _sqlalchemy_installed
            self.assertRaises(ImproperlyConfigured, _sqlalchemy_installed)

        execute_context(mask_modules("sqlalchemy"), with_SQLAlchemy_masked)
コード例 #27
0
 def test_missing_SQLAlchemy_raises_ImproperlyConfigured(self):
     with mask_modules('sqlalchemy'):
         from celery.backends.database import _sqlalchemy_installed
         with self.assertRaises(ImproperlyConfigured):
             _sqlalchemy_installed()
コード例 #28
0
ファイル: test_database.py プロジェクト: avinash011/celery
 def test_missing_SQLAlchemy_raises_ImproperlyConfigured(self):
     with mask_modules("sqlalchemy"):
         from celery.backends.database import _sqlalchemy_installed
         with self.assertRaises(ImproperlyConfigured):
             _sqlalchemy_installed()
コード例 #29
0
ファイル: test_celeryd.py プロジェクト: WoLpH/celery
 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())
コード例 #30
0
ファイル: test_celeryd.py プロジェクト: ivirabyan/celery
 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())
コード例 #31
0
ファイル: test_celeryd.py プロジェクト: ivirabyan/celery
 def test_no_multiprocessing(self):
     with mask_modules("multiprocessing"):
         with reset_modules("celery.apps.worker"):
             from celery.apps.worker import multiprocessing
             self.assertIsNone(multiprocessing)
コード例 #32
0
ファイル: test_threads.py プロジェクト: Crowdbooster/celery
    def test_without_threadpool(self):

        with mask_modules('threadpool'):
            with self.assertRaises(ImportError):
                TaskPool()
コード例 #33
0
    def test_without_threadpool(self):

        with mask_modules("threadpool"):
            with self.assertRaises(ImportError):
                TaskPool()
コード例 #34
0
ファイル: test_celeryd.py プロジェクト: WoLpH/celery
 def test_no_multiprocessing(self):
     with mask_modules("multiprocessing"):
         with reset_modules("celery.apps.worker"):
             from celery.apps.worker import multiprocessing
             self.assertIsNone(multiprocessing)
コード例 #35
0
ファイル: test_celeryd.py プロジェクト: WoLpH/celery
 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)
コード例 #36
0
ファイル: test_app.py プロジェクト: AdrianRibao/celery
 def test_pool_no_multiprocessing(self):
     with mask_modules("multiprocessing.util"):
         pool = self.app.pool
         self.assertIs(pool, self.app._pool)
コード例 #37
0
 def test_pool_no_multiprocessing(self):
     with mask_modules('multiprocessing.util'):
         pool = self.app.pool
         self.assertIs(pool, self.app._pool)