def test_setup_concurrency_very_early(self): x = WorkerCommand() x.run = Mock() with self.assertRaises(ImportError): x.execute_from_commandline(['celeryd', '-P', 'xyzybox'])
def test_parse_options(self): cmd = WorkerCommand() cmd.app = current_app opts, args = cmd.parse_options('celeryd', ['--concurrency=512']) self.assertEqual(opts.concurrency, 512)
def test_windows_B_option(self): celery = Celery(set_as_current=False) celery.IS_WINDOWS = True with self.assertRaises(SystemExit): WorkerCommand(app=celery).run(beat=True)
def test_no_loglevel(self): app = Celery(set_as_current=False) app.Worker = Mock() WorkerCommand(app=app).run(loglevel=None)
def test_unknown_loglevel(self): with self.assertRaises(SystemExit): WorkerCommand(app=self.app).run(loglevel='ALIEN') worker1 = self.Worker(loglevel=0xFFFF) self.assertEqual(worker1.loglevel, 0xFFFF)
def worker(self): from celery.bin.celeryd import WorkerCommand return WorkerCommand(app=current_celery())
def test_invalid_loglevel_gives_error(self): x = WorkerCommand(app=Celery(set_as_current=False)) with self.assertRaises(SystemExit): x.run(loglevel='GRIM_REAPER')
def command(self): from celery.bin.celeryd import WorkerCommand w = WorkerCommand() w.execute_from_commandline(['celeryd'] + sys.argv[3:])
def update_parser(self, args): from celery.bin.celeryd import WorkerCommand w = WorkerCommand() w.setup_app_from_commandline(['celeryd']) for x in w.get_options(): self.parser.add_option(x)
def worker(self): from celery.bin.celeryd import WorkerCommand return WorkerCommand(app=Celery(self.app))
def worker_main(self, argv=None): """Run :program:`celeryd` using `argv`. Uses :data:`sys.argv` if `argv` is not specified.""" from celery.bin.celeryd import WorkerCommand return WorkerCommand(app=self).execute_from_commandline(argv)
def test_parse_options(self): cmd = WorkerCommand() opts, args = cmd.parse_options("celeryd", ["--concurrency=512"]) self.assertEqual(opts.concurrency, 512)