def test_run(self, real): out = WhateverIO() i = inspect(app=self.app, stdout=out) with self.assertRaises(Error): i.run() with self.assertRaises(Error): i.run("help") with self.assertRaises(Error): i.run("xyzzybaz") i.run("ping") self.assertTrue(real.called) i.run("ping", destination="foo,bar") self.assertEqual(real.call_args[1]["destination"], ["foo", "bar"]) self.assertEqual(real.call_args[1]["timeout"], 0.2) callback = real.call_args[1]["callback"] callback({"foo": {"ok": "pong"}}) self.assertIn("OK", out.getvalue()) instance = real.return_value = Mock() instance.ping.return_value = None with self.assertRaises(Error): i.run("ping") out.seek(0) out.truncate() i.quiet = True i.say_chat("<-", "hello") self.assertFalse(out.getvalue())
def test_run(self, real): out = WhateverIO() i = inspect(app=self.app, stdout=out) with self.assertRaises(Error): i.run() with self.assertRaises(Error): i.run("help") with self.assertRaises(Error): i.run("xyzzybaz") i.run("ping") self.assertTrue(real.called) i.run("ping", destination="foo,bar") self.assertEqual(real.call_args[1]["destination"], ["foo", "bar"]) self.assertEqual(real.call_args[1]["timeout"], 0.2) callback = real.call_args[1]["callback"] callback({"foo": {"ok": "pong"}}) self.assertIn("OK", out.getvalue()) instance = real.return_value = Mock() instance.ping.return_value = None with self.assertRaises(Error): i.run("ping") out.seek(0) out.truncate() i.quiet = True i.say('<-', "hello") self.assertFalse(out.getvalue())
def test_do_call_method_sql_transport_type(self): self.app.connection = Mock() conn = self.app.connection.return_value = Mock(name='Connection') conn.transport.driver_type = 'sql' i = inspect(app=self.app) with self.assertRaises(i.Error): i.do_call_method(['ping'])
def test_run(self, real): out = WhateverIO() i = inspect(app=self.app, stdout=out) with self.assertRaises(Error): i.run() with self.assertRaises(Error): i.run('help') with self.assertRaises(Error): i.run('xyzzybaz') i.run('ping') real.assert_called() i.run('ping', destination='foo,bar') self.assertEqual(real.call_args[1]['destination'], ['foo', 'bar']) self.assertEqual(real.call_args[1]['timeout'], 0.2) callback = real.call_args[1]['callback'] callback({'foo': {'ok': 'pong'}}) self.assertIn('OK', out.getvalue()) with patch('celery.bin.celery.dumps') as dumps: i.run('ping', json=True) dumps.assert_called() instance = real.return_value = Mock() instance._request.return_value = None with self.assertRaises(Error): i.run('ping') out.seek(0) out.truncate() i.quiet = True i.say_chat('<-', 'hello') self.assertFalse(out.getvalue())
def test_command_info(self): i = inspect(app=self.app) self.assertTrue( i.get_command_info( 'ping', help=True, color=i.colored.red, ))
def test_list_commands_color(self): i = inspect(app=self.app) self.assertTrue(i.list_commands( help=True, color=i.colored.red, app=self.app, )) self.assertTrue(i.list_commands( help=False, color=None, app=self.app, ))
def test_say_directions(self): i = inspect(self.app) i.out = Mock() i.quiet = True i.say_chat('<-', 'hello out') i.out.assert_not_called() i.say_chat('->', 'hello in') i.out.assert_called() i.quiet = False i.out.reset_mock() i.say_chat('<-', 'hello out', 'body') i.out.assert_called()
def test_say_directions(self): i = inspect(self.app) i.out = Mock() i.quiet = True i.say_chat("<-", "hello out") self.assertFalse(i.out.called) i.say_chat("->", "hello in") self.assertTrue(i.out.called) i.quiet = False i.out.reset_mock() i.say_chat("<-", "hello out", "body") self.assertTrue(i.out.called)
def inspect(self, subcommand, no_color, quiet, *args, **arguments): inspect = command.inspect(self.celery) inspect.no_color = no_color inspect.quiet = quiet inspect.run(subcommand, *args, **arguments)
def test_epilog(self): assert inspect(app=self.app).epilog
def test_epilog(self): self.assertTrue(inspect(app=self.app).epilog)
def test_command_info(self): i = inspect(app=self.app) self.assertTrue(i.get_command_info( 'ping', help=True, color=i.colored.red, app=self.app, ))
def test_usage(self): self.assertTrue(inspect(app=self.app).usage('foo'))
def test_conf(self): i = inspect(app=self.app) i.call = Mock(name='call') i.conf(with_defaults=True, foo=1) i.call.assert_called_with('conf', True, foo=1)
def test_objgraph(self): i = inspect(app=self.app) i.call = Mock(name='call') i.objgraph('Message', foo=1) i.call.assert_called_with('objgraph', 'Message', foo=1)
def test_usage(self): assert inspect(app=self.app).usage('foo')