def test_manager_execute_from_command_line(self): obj1 = base.Manager() obj1.register_command("str to int", MyCommand, int) # Случай 1: len(args) <= 1 obj1.execute_from_command_line(('star point', )) # Случай 2: имени нет в словаре команд obj1.execute_from_command_line(('star point', "str to float")) # Случай 3: имя есть в словаре команд self.assertTrue( obj1.execute_from_command_line(('star point', 'str to int', '222')) == 222)
def test_manager_register_command(self): obj1 = base.Manager() obj1.register_command("str to int", MyCommand, int) self.assertTrue("str to int" in obj1.commands)
def test_manager_execute_command(self): obj1 = base.Manager() obj1.register_command("str to int", MyCommand, int) obj1.execute_command("str to int", "221") with self.assertRaises(KeyError): obj1.execute_command("str to float", 2.88)
def test_manager_init(self): obj1 = base.Manager() self.assertTrue(obj1.commands == {})