def test_function_return_value(capsys, first_router_wrong_ip): return_value = task_19_1b.send_show_command(first_router_wrong_ip, "sh ip int br") correct_stdout = "Connection to device timed-out" out, err = capsys.readouterr() assert out != "", "Сообщение об ошибке не выведено на stdout" assert correct_stdout in out, "Выведено неправильное сообщение об ошибке"
def send_commands(device, show = False, config = False): with netmiko.ConnectHandler(**device) as ssh: ssh.enable() if show: return send_show_command(device, show) else: return send_config_commands(device, config)
def send_commands(device, show=None, config=None): if show: result = send_show_command(device, show) elif config: result = send_config_commands(device, config) else: result = None return result
def test_function_return_value(capsys, first_router_wrong_ip): """ Проверка работы функции """ return_value = task_19_1b.send_show_command(first_router_wrong_ip, "sh ip int br") correct_stdout1 = "Connection to device timed-out" correct_stdout2 = "connection to device failed" out, err = capsys.readouterr() assert out != "", "Сообщение об ошибке не выведено на stdout" assert correct_stdout1 in out or correct_stdout2 in out, "Выведено неправильное сообщение об ошибке"
def send_commands(device, show=None, config=None): if show: return send_show_command(device, show) else: return send_config_commands(device, config)