コード例 #1
0
ファイル: test_threads.py プロジェクト: xuziyan001/celery
 def test_on_apply(self):
     with mock.module("threadpool"):
         x = TaskPool(app=self.app)
         x.on_start()
         callback = Mock()
         accept_callback = Mock()
         target = Mock()
         req = x.on_apply(target, args=(1, 2), kwargs={"a": 10}, callback=callback, accept_callback=accept_callback)
         x.WorkRequest.assert_called_with(apply_target, (target, (1, 2), {"a": 10}, callback, accept_callback))
         x._pool.putRequest.assert_called_with(req)
         x._pool._results_queue.queue.clear.assert_called_with()
コード例 #2
0
ファイル: test_threads.py プロジェクト: zhangzewen/celery
 def test_on_apply(self):
     with mock_module('threadpool'):
         x = TaskPool(app=self.app)
         x.on_start()
         callback = Mock()
         accept_callback = Mock()
         target = Mock()
         req = x.on_apply(target, args=(1, 2), kwargs={'a': 10},
                          callback=callback,
                          accept_callback=accept_callback)
         x.WorkRequest.assert_called_with(
             apply_target,
             (target, (1, 2), {'a': 10}, callback, accept_callback),
         )
         x._pool.putRequest.assert_called_with(req)
         x._pool._results_queue.queue.clear.assert_called_with()
コード例 #3
0
ファイル: test_threads.py プロジェクト: zzkristy/celery
 def test_on_stop(self):
     with mock.module('threadpool'):
         x = TaskPool(app=self.app)
         x.on_start()
         x.on_stop()
         x._pool.dismissWorkers.assert_called_with(x.limit, do_join=True)
コード例 #4
0
ファイル: test_threads.py プロジェクト: zzkristy/celery
 def test_on_start(self):
     with mock.module('threadpool'):
         x = TaskPool(app=self.app)
         x.on_start()
         self.assertTrue(x._pool)
         self.assertIsInstance(x._pool.workRequests, NullDict)
コード例 #5
0
ファイル: test_threads.py プロジェクト: zzkristy/celery
 def test_with_threadpool(self):
     with mock.module('threadpool'):
         x = TaskPool(app=self.app)
         self.assertTrue(x.ThreadPool)
         self.assertTrue(x.WorkRequest)
コード例 #6
0
ファイル: test_threads.py プロジェクト: zzkristy/celery
    def test_without_threadpool(self):

        with mock.mask_modules('threadpool'):
            with self.assertRaises(ImportError):
                TaskPool(app=self.app)
コード例 #7
0
ファイル: test_threads.py プロジェクト: 1995rishi/flaskmap
 def test_on_stop(self):
     with mock_module('threadpool'):
         x = TaskPool()
         x.on_start()
         x.on_stop()
         x._pool.dismissWorkers.assert_called_with(x.limit, do_join=True)
コード例 #8
0
ファイル: test_threads.py プロジェクト: 1995rishi/flaskmap
 def test_on_start(self):
     with mock_module('threadpool'):
         x = TaskPool()
         x.on_start()
         self.assertTrue(x._pool)
         self.assertIsInstance(x._pool.workRequests, NullDict)
コード例 #9
0
 def test_on_stop(self):
     with mock_module("threadpool"):
         x = TaskPool()
         x.on_start()
         x.on_stop()
         x._pool.dismissWorkers.assert_called_with(x.limit, do_join=True)
コード例 #10
0
 def test_on_start(self):
     with mock_module("threadpool"):
         x = TaskPool()
         x.on_start()
         self.assertTrue(x._pool)
         self.assertIsInstance(x._pool.workRequests, NullDict)
コード例 #11
0
 def test_with_threadpool(self):
     with mock_module("threadpool"):
         x = TaskPool()
         self.assertTrue(x.ThreadPool)
         self.assertTrue(x.WorkRequest)
コード例 #12
0
    def test_without_threadpool(self):

        with mask_modules("threadpool"):
            with self.assertRaises(ImportError):
                TaskPool()
コード例 #13
0
ファイル: test_threads.py プロジェクト: xuziyan001/celery
 def test_on_stop(self):
     with mock.module("threadpool"):
         x = TaskPool(app=self.app)
         x.on_start()
         x.on_stop()
         x._pool.dismissWorkers.assert_called_with(x.limit, do_join=True)
コード例 #14
0
ファイル: test_threads.py プロジェクト: xuziyan001/celery
 def test_on_start(self):
     with mock.module("threadpool"):
         x = TaskPool(app=self.app)
         x.on_start()
         self.assertTrue(x._pool)
         self.assertIsInstance(x._pool.workRequests, NullDict)