Пример #1
0
    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())
Пример #2
0
    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())
Пример #3
0
 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'])
Пример #4
0
    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())
Пример #5
0
 def test_command_info(self):
     i = inspect(app=self.app)
     self.assertTrue(
         i.get_command_info(
             'ping',
             help=True,
             color=i.colored.red,
         ))
Пример #6
0
 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,
     ))
Пример #7
0
    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()
Пример #8
0
    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)
Пример #9
0
 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)
Пример #10
0
 def test_epilog(self):
     assert inspect(app=self.app).epilog
Пример #11
0
 def test_epilog(self):
     self.assertTrue(inspect(app=self.app).epilog)
Пример #12
0
 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,
     ))
Пример #13
0
 def test_usage(self):
     self.assertTrue(inspect(app=self.app).usage('foo'))
Пример #14
0
 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)
Пример #15
0
 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)
Пример #16
0
 def test_usage(self):
     assert inspect(app=self.app).usage('foo')
Пример #17
0
 def test_usage(self):
     assert inspect(app=self.app).usage('foo')
Пример #18
0
 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)
Пример #19
0
 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)
Пример #20
0
 def test_epilog(self):
     assert inspect(app=self.app).epilog