Example #1
0
def test_function_return_value():
    trunk_vlans_mapping = {
        "FastEthernet0/1": [10, 20, 30],
        "FastEthernet0/2": [11, 30],
        "FastEthernet0/4": [17],
    }
    template_trunk_mode = [
        "switchport mode trunk",
        "switchport trunk native vlan 999",
        "switchport trunk allowed vlan",
    ]
    correct_return_value = [
        "interface FastEthernet0/1",
        "switchport mode trunk",
        "switchport trunk native vlan 999",
        "switchport trunk allowed vlan 10,20,30",
        "interface FastEthernet0/2",
        "switchport mode trunk",
        "switchport trunk native vlan 999",
        "switchport trunk allowed vlan 11,30",
        "interface FastEthernet0/4",
        "switchport mode trunk",
        "switchport trunk native vlan 999",
        "switchport trunk allowed vlan 17",
    ]

    return_value = task_9_2.generate_trunk_config(
        trunk_vlans_mapping, template_trunk_mode
    )
    assert return_value != None, "Функция ничего не возвращает"
    assert type(return_value) == list, "Функция должна возвращать список"
    assert (
        return_value == correct_return_value
    ), "Функция возвращает неправильное значение"
def test_function_return_value_different_args():
    """
    Checking the function with different arguments
    """
    trunk_vlans_mapping = {
        "FastEthernet0/11": [101, 120, 130],
        "FastEthernet0/12": [101, 130],
    }
    template_trunk_mode = [
        "switchport mode trunk",
        "switchport trunk allowed vlan",
    ]
    correct_return_value = [
        "interface FastEthernet0/11",
        "switchport mode trunk",
        "switchport trunk allowed vlan 101,120,130",
        "interface FastEthernet0/12",
        "switchport mode trunk",
        "switchport trunk allowed vlan 101,130",
    ]

    return_value = task_9_2.generate_trunk_config(
        trunk_vlans_mapping, template_trunk_mode
    )
    assert return_value != None, "The function returns None"
    assert (
        type(return_value) == list
    ), f"The function should return a list, instead it returns a {type(return_value).__name__}"
    assert (
        return_value == correct_return_value
    ), "Function returns wrong value"
Example #3
0
def test_function_return_value_different_args():
    """
    Проверка работы функции с другими аргументами
    """
    trunk_vlans_mapping = {
        "FastEthernet0/11": [101, 120, 130],
        "FastEthernet0/12": [101, 130],
    }
    template_trunk_mode = [
        "switchport mode trunk",
        "switchport trunk allowed vlan",
    ]
    correct_return_value = [
        "interface FastEthernet0/11",
        "switchport mode trunk",
        "switchport trunk allowed vlan 101,120,130",
        "interface FastEthernet0/12",
        "switchport mode trunk",
        "switchport trunk allowed vlan 101,130",
    ]

    return_value = task_9_2.generate_trunk_config(trunk_vlans_mapping,
                                                  template_trunk_mode)
    assert return_value is not None, "Функция ничего не возвращает"
    assert (
        type(return_value) == list
    ), f"По заданию функция должна возвращать список, а возвращает {type(return_value).__name__}"
    assert (correct_return_value == return_value
            ), "Функция возвращает неправильное значение"
Example #4
0
def test_function_return_value():
    trunk_vlans_mapping = {
        'FastEthernet0/1': [10, 20, 30],
        'FastEthernet0/2': [11, 30],
        'FastEthernet0/4': [17]
    }
    template_trunk_mode = [
        'switchport mode trunk', 'switchport trunk native vlan 999',
        'switchport trunk allowed vlan'
    ]
    correct_return_value = ['interface FastEthernet0/1',
                            'switchport mode trunk',
                            'switchport trunk native vlan 999',
                            'switchport trunk allowed vlan 10,20,30',
                            'interface FastEthernet0/2',
                            'switchport mode trunk',
                            'switchport trunk native vlan 999',
                            'switchport trunk allowed vlan 11,30',
                            'interface FastEthernet0/4',
                            'switchport mode trunk',
                            'switchport trunk native vlan 999',
                            'switchport trunk allowed vlan 17']

    return_value = task_9_2.generate_trunk_config(trunk_vlans_mapping, template_trunk_mode)
    assert return_value != None, "Функция ничего не возвращает"
    assert type(return_value) == list, "Функция должна возвращать список"
    assert return_value == correct_return_value, "Функция возвращает неправильное значение"
def test_function_return_value():
    """
    Function check
    """
    trunk_vlans_mapping = {
        "FastEthernet0/1": [10, 20, 30],
        "FastEthernet0/2": [11, 30],
        "FastEthernet0/4": [17],
    }
    template_trunk_mode = [
        "switchport mode trunk",
        "switchport trunk native vlan 999",
        "switchport trunk allowed vlan",
    ]
    correct_return_value = [
        "interface FastEthernet0/1",
        "switchport mode trunk",
        "switchport trunk native vlan 999",
        "switchport trunk allowed vlan 10,20,30",
        "interface FastEthernet0/2",
        "switchport mode trunk",
        "switchport trunk native vlan 999",
        "switchport trunk allowed vlan 11,30",
        "interface FastEthernet0/4",
        "switchport mode trunk",
        "switchport trunk native vlan 999",
        "switchport trunk allowed vlan 17",
    ]

    return_value = task_9_2.generate_trunk_config(
        trunk_vlans_mapping, template_trunk_mode
    )
    assert return_value != None, "The function returns None"
    assert (
        type(return_value) == list
    ), f"The function should return a list, instead it returns a {type(return_value).__name__}"
    assert (
        return_value == correct_return_value
    ), "Function returns wrong value"