diff options
author | Lucas Hoffmann <l-m-h@web.de> | 2017-01-17 09:47:06 +0100 |
---|---|---|
committer | Lucas Hoffmann <l-m-h@web.de> | 2017-01-18 00:26:31 +0100 |
commit | dc2a0172d9cfc5d31eb2efbd1812d135c9dc579a (patch) | |
tree | d30a3c79623a36f8d911602631bc45ce088836d9 | |
parent | bb622547de69958e257c64c255a3632f829553fd (diff) |
Port old doctests to unittest: alot.commands.__init__
-rw-r--r-- | alot/commands/__init__.py | 12 | ||||
-rw-r--r-- | tests/commands/__init__.py | 0 | ||||
-rw-r--r-- | tests/commands/init_test.py | 28 |
3 files changed, 28 insertions, 12 deletions
diff --git a/alot/commands/__init__.py b/alot/commands/__init__.py index 05ce3424..47315fc3 100644 --- a/alot/commands/__init__.py +++ b/alot/commands/__init__.py @@ -53,10 +53,6 @@ def lookup_command(cmdname, mode): :type mode: str :rtype: (:class:`Command`, :class:`~argparse.ArgumentParser`, dict(str->dict)) - - >>> (cmd, parser, kwargs) = lookup_command('save', 'thread') - >>> cmd - <class 'alot.commands.thread.SaveAttachmentCommand'> """ if cmdname in COMMANDS[mode]: return COMMANDS[mode][cmdname] @@ -155,14 +151,6 @@ def commandfactory(cmdline, mode='global'): :type cmdline: str :param mode: mode identifier :type mode: str - - >>> cmd = alot.commands.commandfactory('save --all /foo', mode='thread') - >>> cmd - <alot.commands.thread.SaveAttachmentCommand object at 0x272cf10 - >>> cmd.all - True - >>> cmd.path - u'/foo' """ # split commandname and parameters if not cmdline: diff --git a/tests/commands/__init__.py b/tests/commands/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/commands/__init__.py diff --git a/tests/commands/init_test.py b/tests/commands/init_test.py new file mode 100644 index 00000000..189ffc8e --- /dev/null +++ b/tests/commands/init_test.py @@ -0,0 +1,28 @@ +# encoding=utf-8 + +"""Test suite for alot.commands.__init__ module.""" + +import argparse +import unittest + +from alot import commands +from alot.commands import thread + + +class TestLookupCommand(unittest.TestCase): + + def test_look_up_save_attachment_command_in_thread_mode(self): + cmd, parser, kwargs = commands.lookup_command('save', 'thread') + # TODO do some more tests with these return values + self.assertEqual(cmd, thread.SaveAttachmentCommand) + self.assertIsInstance(parser, argparse.ArgumentParser) + self.assertDictEqual(kwargs, {}) + + +class TestCommandFactory(unittest.TestCase): + + def test_create_save_attachment_command_with_arguments(self): + cmd = commands.commandfactory('save --all /foo', mode='thread') + self.assertIsInstance(cmd, thread.SaveAttachmentCommand) + self.assertTrue(cmd.all) + self.assertEqual(cmd.path, u'/foo') |