def test_function_return_value_from_single_device( three_routers_from_devices_yaml, r1_r2_r3_test_connection, tmpdir, device, command_dict, ): """ Проверка работы функции """ device_ip = device["host"] commands = command_dict[device_ip] ssh = create_ssh_connect(device) output = "" for command in commands: output += f"{ssh.find_prompt()}{command}\n{ssh.send_command(command)}\n" ssh.disconnect() dest_filename = tmpdir.mkdir("test_tasks").join("task_19_3.txt") return_value = task_19_3a.send_command_to_devices( devices=[device], commands_dict=command_dict, filename=dest_filename, limit=3, ) assert return_value == None, "Функция должна возвращать None" dest_file_content = dest_filename.read().strip() assert strip_empty_lines(output) == strip_empty_lines( dest_file_content), f"В итоговом файле нет вывода с {device_ip}"
def test_function_return_value_from_single_device( three_routers_from_devices_yaml, r1_r2_r3_test_connection, tmpdir, device, command_dict, ): """ Function check """ device_ip = device["host"] command = command_dict[device_ip] ssh = create_ssh_connect(device) output = f"{ssh.find_prompt()}{command}\n{ssh.send_command(command)}\n" ssh.disconnect() dest_filename = tmpdir.mkdir("test_tasks").join("task_19_3.txt") return_value = task_19_3.send_command_to_devices( devices=[device], commands_dict=command_dict, filename=dest_filename, limit=3, ) assert return_value == None, "The function must return None" dest_file_content = dest_filename.read().strip() assert strip_empty_lines(output) == strip_empty_lines( dest_file_content ), f"Output file does not have output from {device_ip}"
def test_function_return_value_from_single_device(tmpdir, device, command): """ Проверка работы функции """ ssh = create_ssh_connect(device) output = f"{ssh.find_prompt()}{command}\n{ssh.send_command(command)}\n" ssh.disconnect() dest_filename = tmpdir.mkdir("test_tasks").join("task_20_2.txt") return_value = task_20_2.send_show_command_to_devices( devices=[device], command=command, filename=dest_filename, limit=3, ) assert return_value == None, "Функция должна возвращать None" dest_file_content = dest_filename.read().strip() assert strip_empty_lines(output) == strip_empty_lines( dest_file_content), f"В итоговом файле нет вывода с {device['host']}"
def test_function_return_value_from_single_device( three_routers_from_devices_yaml, r1_r2_r3_test_connection, tmpdir, device, command): """ Проверка работы функции """ ssh = create_ssh_connect(device) correct_output = strip_empty_lines( f"{ssh.find_prompt()}{command}\n{ssh.send_command(command)}\n") ssh.disconnect() dest_filename = tmpdir.mkdir("test_tasks").join("task_19_2.txt") return_value = task_19_2.send_show_command_to_devices( devices=[device], command=command, filename=dest_filename, limit=3, ) assert None == return_value, "Функция должна возвращать None" dest_file_content = strip_empty_lines(dest_filename.read().strip()) assert (correct_output == dest_file_content ), f"В итоговом файле нет вывода с {device['host']}"
def test_function_return_value_from_single_device( three_routers_from_devices_yaml, r1_r2_r3_test_connection, tmpdir, device, command): """ Function check """ ssh = create_ssh_connect(device) correct_output = strip_empty_lines( f"{ssh.find_prompt()}{command}\n{ssh.send_command(command)}\n") ssh.disconnect() dest_filename = tmpdir.mkdir("test_tasks").join("task_19_2.txt") return_value = task_19_2.send_show_command_to_devices( devices=[device], command=command, filename=dest_filename, limit=3, ) assert None == return_value, "The function must return None" dest_file_content = strip_empty_lines(dest_filename.read().strip()) assert (correct_output == dest_file_content ), f"Output file does not have output from {device['host']}"