def test_function_return_value(r1_test_connection, first_router_from_devices_yaml): """ Проверка работы функции """ show_command = "sh ip int br" cfg_commands = [ "logging 10.255.255.1", "logging buffered 20010", "no logging console", ] correct_return_value_show = r1_test_connection.send_command(show_command) correct_return_value_cfg = r1_test_connection.send_config_set(cfg_commands) return_value_show = task_18_3.send_commands(first_router_from_devices_yaml, show=show_command) return_value_cfg = task_18_3.send_commands(first_router_from_devices_yaml, config=cfg_commands) assert return_value_show != None, "Функция ничего не возвращает" assert ( type(return_value_show) == str ), f"По заданию функция должна возвращать строку, а возвращает {type(return_value).__name__}" assert strip_empty_lines(correct_return_value_show) == strip_empty_lines( return_value_show ), "Функция возвращает неправильное значение при передаче команды show" assert strip_empty_lines(correct_return_value_cfg) == strip_empty_lines( return_value_cfg ), "Функция возвращает неправильное значение при передаче конфигурационных команд"
def test_function_return_value(r1_test_connection, first_router_from_devices_yaml): """ Function check """ show_command = "sh ip int br" cfg_commands = [ "logging 10.255.255.1", "logging buffered 20010", "no logging console", ] correct_return_value_show = r1_test_connection.send_command(show_command) correct_return_value_cfg = r1_test_connection.send_config_set(cfg_commands) return_value_show = task_18_3.send_commands( first_router_from_devices_yaml, show=show_command ) return_value_cfg = task_18_3.send_commands( first_router_from_devices_yaml, config=cfg_commands ) assert return_value_show != None, "The function returns None" assert ( type(return_value_show) == str ), f"The function must return string, and it returns a {type(return_value).__name__}" assert strip_empty_lines(correct_return_value_show) == strip_empty_lines( return_value_show ), "Function returns wrong value for show command" assert strip_empty_lines(correct_return_value_cfg) == strip_empty_lines( return_value_cfg ), "Function returns wrong value config commands"
def test_function_params(r1_test_connection, first_router_from_devices_yaml): show_command = "sh ip int br" cfg_commands = ["logging buffered 20010"] with pytest.raises(TypeError) as excinfo: # if show/config arguments are not passed as keyword arguments, # a TypeError exception should be raised task_18_3.send_commands(first_router_from_devices_yaml, show_command) with pytest.raises(ValueError) as excinfo: # If both show and config are passed, a ValueError exception should be raised task_18_3.send_commands( first_router_from_devices_yaml, show=show_command, config=cfg_commands )
def test_function_params(r1_test_connection, first_router_from_devices_yaml): """ Проверка параметров """ show_command = "sh ip int br" cfg_commands = ["logging buffered 20010"] with pytest.raises(TypeError) as excinfo: # если аргументы show/config передаются не как ключевые, # должно генерироваться исключение TypeError task_18_3.send_commands(first_router_from_devices_yaml, show_command) with pytest.raises(ValueError) as excinfo: # Если передаются оба аргумента и show и config, # должно генерироваться исключение ValueError task_18_3.send_commands(first_router_from_devices_yaml, show=show_command, config=cfg_commands)