diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-08-02 09:54:23 -0700 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2018-08-02 20:33:47 +0100 |
commit | ceaad927ca0e4509abea0c02d7af02b6406b55dd (patch) | |
tree | a740592663878764a4d297a0d50a9fe3fa46f462 /tests | |
parent | 29eb19863eccedec0d5a6e41a1ab8f9b7cce66b4 (diff) |
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).
Diffstat (limited to 'tests')
-rw-r--r-- | tests/commands/global_test.py | 25 |
1 files changed, 24 insertions, 1 deletions
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() |