models: Remove unused module
[git-cola.git] / test / test_cola_cmdfactory.py
blobc667f0bcd8c66f900e97e9f88d3584e468ff7ece
1 import unittest
3 from cola import cmdfactory
5 class UserInputWrapper(object):
6 def __init__(self):
7 self.callbacks = {
8 'hello': self._hello,
9 'echo': self._echo,
11 def _hello(self):
12 return 'world'
14 def _echo(self, *args, **opts):
15 return args, opts
18 class CommandFactoryTestCase(unittest.TestCase):
19 def setUp(self):
20 self.factory = cmdfactory.CommandFactory()
21 self.factory.add_command_wrapper(UserInputWrapper())
23 def test_prompt_user_hello_world(self):
24 self.assertEquals(self.factory.prompt_user('hello'), 'world')
26 def test_prompt_user_echo(self):
27 args = (42,)
28 opts = {'one': 1}
29 self.assertEquals(self.factory.prompt_user('echo', *args, **opts),
30 (args, opts))
32 def test_raises_on_unknown_callback(self):
33 self.assertRaises(NotImplementedError,
34 self.factory.prompt_user, 'unknown-callback')
37 if __name__ == '__main__':
38 unittest.main()