def send_commands(device, *, show=None, config=None): if show != None and config != None: raise ValueError() elif show != None: return c0.send_show_command(device, show) else: return c1.send_config_commands(device, config)
def send_commands(device, *, config=None, show=None): if show and config: raise ValueError("Only one of the show/config arguments can be passed") elif show: return send_show_command(device, show) elif config: return send_config_commands(device, config)
def send_commands(device, *, config=None, show=None): if show and config: raise ValueError('Можно передавать только один из аргументов show/config') elif show: return send_show_command(device, show) elif config: return send_config_commands(device, config)
def send_commands(device, *, show=None, config=None): if show and not config: return send_show_command(device, show) elif not show and config: return send_config_commands(device, config) elif show and config: raise ValueError( 'Функция работает только с одним типом команд (show/config)')
def send_commands(device, *, show=None, config=None): if show and config: raise ValueError( 'Можно передавать только один вспомогательный параметр') elif show: return send_show_command(device, show) elif config: return send_config_commands(device, config)
def send_commands(device, *, show='', config=''): result = None if show and config: raise ValueError( "Only show or config available. Not a both at same time") elif show: result = send_show_command(device, show) elif config: result = send_config_commands(device, config) return result
def test_function_return_value_different_args(r1_test_connection, first_router_from_devices_yaml): """ Проверка работы функции с другими аргументами """ test_commands = [ "interface Loopback 100", "ip address 10.1.1.100 255.255.255.255", ] correct_return_value = r1_test_connection.send_config_set(test_commands) return_value = task_18_2.send_config_commands( first_router_from_devices_yaml, test_commands) assert return_value != None, "Функция ничего не возвращает" assert ( type(return_value) == str ), f"По заданию функция должна возвращать строку, а возвращает {type(return_value).__name__}" assert strip_empty_lines(return_value) == strip_empty_lines( correct_return_value), "Функция возвращает неправильное значение"
def test_function_return_value_different_args(r1_test_connection, first_router_from_devices_yaml): """ Checking the function with different arguments """ test_commands = [ "interface Loopback 100", "ip address 10.1.1.100 255.255.255.255", ] correct_return_value = r1_test_connection.send_config_set(test_commands) return_value = task_18_2.send_config_commands( first_router_from_devices_yaml, test_commands) assert return_value != None, "The function returns None" assert ( type(return_value) == str ), f"The function must return string, and it returns a {type(return_value).__name__}" assert strip_empty_lines(return_value) == strip_empty_lines( correct_return_value), "Function returns wrong value"
def test_function_return_value(r1_test_connection, first_router_from_devices_yaml): """ Проверка работы функции """ test_commands = [ "logging 10.255.255.1", "logging buffered 20010", "no logging console", ] correct_return_value = r1_test_connection.send_config_set(test_commands) return_value = task_18_2.send_config_commands( first_router_from_devices_yaml, test_commands) assert return_value != None, "Функция ничего не возвращает" assert ( type(return_value) == str ), f"По заданию функция должна возвращать строку, а возвращает {type(return_value).__name__}" assert strip_empty_lines(return_value) == strip_empty_lines( correct_return_value), "Функция возвращает неправильное значение"
def test_function_return_value(r1_test_connection, first_router_from_devices_yaml): """ Function check """ test_commands = [ "logging 10.255.255.1", "logging buffered 20010", "no logging console", ] correct_return_value = r1_test_connection.send_config_set(test_commands) return_value = task_18_2.send_config_commands( first_router_from_devices_yaml, test_commands) assert return_value != None, "The function returns None" assert ( type(return_value) == str ), f"The function must return string, and it returns a {type(return_value).__name__}" assert strip_empty_lines(return_value) == strip_empty_lines( correct_return_value), "Function returns wrong value"
def send_commands(device, config=None, show=None): if show: return send_show_command(device, show) elif config: return send_config_commands(device, config)