def test_execute(self): x = CeleryCommand(app=self.app) Help = x.commands['help'] = Mock() help = Help.return_value = Mock() x.execute('fooox', ['a']) help.run_from_argv.assert_called_with(x.prog_name, [], command='help') help.reset() x.execute('help', ['help']) help.run_from_argv.assert_called_with(x.prog_name, [], command='help') Dummy = x.commands['dummy'] = Mock() dummy = Dummy.return_value = Mock() exc = dummy.run_from_argv.side_effect = Error( 'foo', status='EX_FAILURE', ) x.on_error = Mock(name='on_error') help.reset() x.execute('dummy', ['dummy']) x.on_error.assert_called_with(exc) dummy.run_from_argv.assert_called_with( x.prog_name, [], command='dummy', ) help.run_from_argv.assert_called_with( x.prog_name, [], command='help', ) exc = dummy.run_from_argv.side_effect = x.UsageError('foo') x.on_usage_error = Mock() x.execute('dummy', ['dummy']) x.on_usage_error.assert_called_with(exc)
def test_handle_argv(self): x = CeleryCommand(app=self.app) x.execute = Mock() x.handle_argv('celery', []) x.execute.assert_called_with('help', ['help']) x.handle_argv('celery', ['start', 'foo']) x.execute.assert_called_with('start', ['start', 'foo'])
def test_handle_argv(self): x = CeleryCommand(app=self.app) x.execute = Mock() x.handle_argv("celery", []) x.execute.assert_called_with("help", ["help"]) x.handle_argv("celery", ["start", "foo"]) x.execute.assert_called_with("start", ["start", "foo"])
def test_short_and_long_arguments_be_the_same(self): for arg in "--app", "-A": appstr = '.'.join([__name__, 'APP']) x = CeleryCommand(app=self.app) x.execute = Mock() with pytest.raises(SystemExit): x.execute_from_commandline(['celery', arg, appstr, 'worker']) assert x.execute.called assert x.execute.call_args[0] assert x.execute.call_args[0][0] == "worker"
def test_execute(self): x = CeleryCommand(app=self.app) Help = x.commands["help"] = Mock() help = Help.return_value = Mock() x.execute("fooox", ["a"]) help.run_from_argv.assert_called_with(x.prog_name, [], command="help") help.reset() x.execute("help", ["help"]) help.run_from_argv.assert_called_with(x.prog_name, [], command="help") Dummy = x.commands["dummy"] = Mock() dummy = Dummy.return_value = Mock() dummy.run_from_argv.side_effect = Error("foo", status="EX_FAILURE") help.reset() x.execute("dummy", ["dummy"]) dummy.run_from_argv.assert_called_with(x.prog_name, [], command="dummy") help.run_from_argv.assert_called_with(x.prog_name, [], command="help") exc = dummy.run_from_argv.side_effect = x.UsageError("foo") x.on_usage_error = Mock() x.execute("dummy", ["dummy"]) x.on_usage_error.assert_called_with(exc)
def test_execute(self): x = CeleryCommand(app=self.app) Help = x.commands['help'] = Mock() help = Help.return_value = Mock() x.execute('fooox', ['a']) help.run_from_argv.assert_called_with(x.prog_name, ['help']) help.reset() x.execute('help', ['help']) help.run_from_argv.assert_called_with(x.prog_name, ['help']) Dummy = x.commands['dummy'] = Mock() dummy = Dummy.return_value = Mock() dummy.run_from_argv.side_effect = Error('foo', status='EX_FAILURE') help.reset() x.execute('dummy', ['dummy']) dummy.run_from_argv.assert_called_with(x.prog_name, ['dummy']) help.run_from_argv.assert_called_with(x.prog_name, ['dummy'])
def test_execute(self): x = CeleryCommand(app=self.app) Help = x.commands["help"] = Mock() help = Help.return_value = Mock() x.execute("fooox", ["a"]) help.run_from_argv.assert_called_with(x.prog_name, ["help"]) help.reset() x.execute("help", ["help"]) help.run_from_argv.assert_called_with(x.prog_name, ["help"]) Dummy = x.commands["dummy"] = Mock() dummy = Dummy.return_value = Mock() dummy.run_from_argv.side_effect = Error("foo", status="EX_FAILURE") help.reset() x.execute("dummy", ["dummy"]) dummy.run_from_argv.assert_called_with(x.prog_name, ["dummy"]) help.run_from_argv.assert_called_with(x.prog_name, ["dummy"])