def test_call(self): self.cmd.run = Mock() self.cmd.run.return_value = None self.assertEqual(self.cmd(), EX_OK) self.cmd.run.side_effect = Error('error', EX_FAILURE) self.assertEqual(self.cmd(), EX_FAILURE)
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='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"])
def test_Error_repr(self): x = Error('something happened') self.assertIsNotNone(x.status) self.assertTrue(x.reason) self.assertTrue(str(x))