Esempio n. 1
0
 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)
Esempio n. 2
0
 def test_none(self):
     caller = Caller()
     ce = api.CommandDispatcher(caller)
     with self.assertRaises(RuntimeError):
         ce.exec(None)
         self.fail()
Esempio n. 3
0
 def test_command_null(self):
     caller = Caller()
     ce = api.CommandDispatcher(caller)
     with self.assertRaises(RuntimeError):
         ce.exec({'command'})
         self.fail()
Esempio n. 4
0
 def test_wrong_format(self):
     caller = Caller()
     ce = api.CommandDispatcher(caller)
     with self.assertRaises(RuntimeError):
         ce.exec({'cmd': 'd'})
         self.fail()
Esempio n. 5
0
 def test_exec_missing_args(self):
     caller = Caller()
     ce = api.CommandDispatcher(caller)
     with self.assertRaises(TypeError):
         ce.exec({'command': 'one'})
         self.fail()
Esempio n. 6
0
 def test_command_not_found(self):
     caller = Caller()
     ce = api.CommandDispatcher(caller)
     with self.assertRaises(NameError):
         ce.exec({'command': 'missing'})
         self.fail()
Esempio n. 7
0
 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)
Esempio n. 8
0
 def test_exec(self):
     caller = Caller()
     ce = api.CommandDispatcher(caller)
     ce.exec({'command': 'foo'})
     self.assertEqual(True, caller.foo_called)
Esempio n. 9
0
 def test_init(self):
     caller = Caller()
     ce = api.CommandDispatcher(caller)
     self.assertTrue(len(ce.strategies) == 3)