def test_exec_tow_args(self): caller = Caller() ce = api.CommandDispatcher(caller) ce.exec({'command': 'two', 'args': ['test1', 'test2']}) self.assertEqual(True, caller.two_called) self.assertEqual('test1', caller.arg1) self.assertEqual('test2', caller.arg2)
def test_none(self): caller = Caller() ce = api.CommandDispatcher(caller) with self.assertRaises(RuntimeError): ce.exec(None) self.fail()
def test_command_null(self): caller = Caller() ce = api.CommandDispatcher(caller) with self.assertRaises(RuntimeError): ce.exec({'command'}) self.fail()
def test_wrong_format(self): caller = Caller() ce = api.CommandDispatcher(caller) with self.assertRaises(RuntimeError): ce.exec({'cmd': 'd'}) self.fail()
def test_exec_missing_args(self): caller = Caller() ce = api.CommandDispatcher(caller) with self.assertRaises(TypeError): ce.exec({'command': 'one'}) self.fail()
def test_command_not_found(self): caller = Caller() ce = api.CommandDispatcher(caller) with self.assertRaises(NameError): ce.exec({'command': 'missing'}) self.fail()
def test_exec_with_simple_args(self): caller = Caller() ce = api.CommandDispatcher(caller) ce.exec({'command': 'one', 'args': 'test'}) self.assertEqual(True, caller.one_called) self.assertEqual('test', caller.arg1)
def test_exec(self): caller = Caller() ce = api.CommandDispatcher(caller) ce.exec({'command': 'foo'}) self.assertEqual(True, caller.foo_called)
def test_init(self): caller = Caller() ce = api.CommandDispatcher(caller) self.assertTrue(len(ce.strategies) == 3)