From ceaad927ca0e4509abea0c02d7af02b6406b55dd Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 2 Aug 2018 09:54:23 -0700 Subject: tests: Add a couple of tests for the CallCommand class This basically just tests that a synchronous and an asynchronous function work, (the async doesn't yet). --- tests/commands/global_test.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/commands/global_test.py b/tests/commands/global_test.py index 88c7bc99..1122b3f7 100644 --- a/tests/commands/global_test.py +++ b/tests/commands/global_test.py @@ -172,7 +172,6 @@ class TestComposeCommand(unittest.TestCase): pass - class TestExternalCommand(unittest.TestCase): @utilities.async_test @@ -243,3 +242,27 @@ class TestExternalCommand(unittest.TestCase): cmd = g_commands.ExternalCommand(u'false', refocus=False, spawn=True) await cmd.apply(ui) ui.notify.assert_called_once_with('', priority='error') + + +class TestCallCommand(unittest.TestCase): + + def test_synchronous_call(self): + ui = mock.Mock() + cmd = g_commands.CallCommand('ui()') + cmd.apply(ui) + ui.assert_called_once() + + @unittest.expectedFailure + def test_async_call(self): + async def func(obj): + obj() + + ui = mock.Mock() + hooks = mock.Mock() + hooks.ui = None + hooks.func = func + + with mock.patch('alot.commands.globals.settings.hooks', hooks): + cmd = g_commands.CallCommand('hooks.func(ui)') + cmd.apply(ui) + ui.assert_called_once() -- cgit v1.2.3