def test_class_inheritance(first_router_from_devices_yaml): ssh = task_24_2a.MyNetmiko(**first_router_from_devices_yaml) ssh.disconnect() assert isinstance( ssh, CiscoIosSSH), "MyNetmiko class must inherit from CiscoIosSSH" check_attr_or_method(ssh, method="send_command") check_attr_or_method(ssh, method="_check_error_in_command")
def test_class_inheritance(first_router_from_devices_yaml): r1 = task_24_2a.MyNetmiko(**first_router_from_devices_yaml) r1.disconnect() assert isinstance( r1, CiscoIosSSH), "Класс MyNetmiko должен наследовать CiscoIosSSH" check_attr_or_method(r1, method="send_command") check_attr_or_method(r1, method="_check_error_in_command")
def test_errors(first_router_from_devices_yaml, command, error): r1 = task_24_2a.MyNetmiko(**first_router_from_devices_yaml) with pytest.raises(task_24_2a.ErrorInCommand) as excinfo: return_value = r1.send_command(command) r1.disconnect() assert error in str( excinfo ), "Метод send_config_commands должен генерировать исключение, когда команда выполнена с ошибкой"
def test_errors(first_router_from_devices_yaml, command, error): r1 = task_24_2a.MyNetmiko(**first_router_from_devices_yaml) with pytest.raises(task_24_2a.ErrorInCommand) as excinfo: return_value = r1.send_command(command) r1.disconnect() assert error in str( excinfo ), "send_command method should raise an exception when the command is executed with an error"
def test_errors(first_router_from_devices_yaml, command, error): ssh = task_24_2a.MyNetmiko(**first_router_from_devices_yaml) output = ssh.send_command("sh run | i hostname") assert ( "hostname" in output ), "After creating an instance of the class, you must connect to the equipment and switch to enable mode" with pytest.raises(task_24_2a.ErrorInCommand) as excinfo: return_value = ssh.send_command(command) ssh.disconnect() assert error in str( excinfo ), "send_command method should raise an exception when the command is executed with an error"
def test_errors(first_router_from_devices_yaml, command, error): ssh = task_24_2a.MyNetmiko(**first_router_from_devices_yaml) output = ssh.send_command("sh run | i hostname") assert ( "hostname" in output ), "При создании экземпляра класса должно создаваться подключение и переход в режим enable" with pytest.raises(task_24_2a.ErrorInCommand) as excinfo: return_value = ssh.send_command(command) ssh.disconnect() assert error in str( excinfo ), "Метод send_config_commands должен генерировать исключение, когда команда выполнена с ошибкой"