def test_function_return_value():
    template_psecurity = [
        'switchport port-security maximum 2',
        'switchport port-security violation restrict',
        'switchport port-security'
    ]
    access_vlans_mapping = {
        'FastEthernet0/12': 10,
        'FastEthernet0/14': 11,
        'FastEthernet0/16': 17
    }
    template_access_mode = [
        'switchport mode access', 'switchport access vlan',
        'switchport nonegotiate', 'spanning-tree portfast',
        'spanning-tree bpduguard enable'
    ]
    correct_return_value_without_psecurity = [
        'interface FastEthernet0/12', 'switchport mode access',
        'switchport access vlan 10', 'switchport nonegotiate',
        'spanning-tree portfast', 'spanning-tree bpduguard enable',
        'interface FastEthernet0/14', 'switchport mode access',
        'switchport access vlan 11', 'switchport nonegotiate',
        'spanning-tree portfast', 'spanning-tree bpduguard enable',
        'interface FastEthernet0/16', 'switchport mode access',
        'switchport access vlan 17', 'switchport nonegotiate',
        'spanning-tree portfast', 'spanning-tree bpduguard enable'
    ]
    correct_return_value_with_psecurity = [
        'interface FastEthernet0/12', 'switchport mode access',
        'switchport access vlan 10', 'switchport nonegotiate',
        'spanning-tree portfast', 'spanning-tree bpduguard enable',
        'switchport port-security maximum 2',
        'switchport port-security violation restrict',
        'switchport port-security', 'interface FastEthernet0/14',
        'switchport mode access', 'switchport access vlan 11',
        'switchport nonegotiate', 'spanning-tree portfast',
        'spanning-tree bpduguard enable', 'switchport port-security maximum 2',
        'switchport port-security violation restrict',
        'switchport port-security', 'interface FastEthernet0/16',
        'switchport mode access', 'switchport access vlan 17',
        'switchport nonegotiate', 'spanning-tree portfast',
        'spanning-tree bpduguard enable', 'switchport port-security maximum 2',
        'switchport port-security violation restrict',
        'switchport port-security'
    ]

    return_value = task_9_1a.generate_access_config(access_vlans_mapping,
                                                    template_access_mode)
    assert return_value != None, "Функция ничего не возвращает"
    assert type(return_value) == list, "Функция должна возвращать список"
    assert return_value == correct_return_value_without_psecurity, "Функция возвращает неправильное значение при вызове с psecurity == None"
    return_value_with_psecurity = task_9_1a.generate_access_config(
        access_vlans_mapping, template_access_mode, template_psecurity)
    assert return_value_with_psecurity == correct_return_value_with_psecurity, "Функция возвращает неправильное значение при вызове с psecurity"
Exemple #2
0
def test_function_return_value():
    """
    Проверка работы функции
    """
    template_psecurity = [
        "switchport port-security maximum 2",
        "switchport port-security violation restrict",
        "switchport port-security",
    ]
    access_vlans_mapping = {
        "FastEthernet0/12": 10,
        "FastEthernet0/14": 11,
        "FastEthernet0/16": 17,
    }
    template_access_mode = [
        "switchport mode access",
        "switchport access vlan",
        "switchport nonegotiate",
        "spanning-tree portfast",
        "spanning-tree bpduguard enable",
    ]
    correct_return_value_without_psecurity = [
        "interface FastEthernet0/12",
        "switchport mode access",
        "switchport access vlan 10",
        "switchport nonegotiate",
        "spanning-tree portfast",
        "spanning-tree bpduguard enable",
        "interface FastEthernet0/14",
        "switchport mode access",
        "switchport access vlan 11",
        "switchport nonegotiate",
        "spanning-tree portfast",
        "spanning-tree bpduguard enable",
        "interface FastEthernet0/16",
        "switchport mode access",
        "switchport access vlan 17",
        "switchport nonegotiate",
        "spanning-tree portfast",
        "spanning-tree bpduguard enable",
    ]
    correct_return_value_with_psecurity = [
        "interface FastEthernet0/12",
        "switchport mode access",
        "switchport access vlan 10",
        "switchport nonegotiate",
        "spanning-tree portfast",
        "spanning-tree bpduguard enable",
        "switchport port-security maximum 2",
        "switchport port-security violation restrict",
        "switchport port-security",
        "interface FastEthernet0/14",
        "switchport mode access",
        "switchport access vlan 11",
        "switchport nonegotiate",
        "spanning-tree portfast",
        "spanning-tree bpduguard enable",
        "switchport port-security maximum 2",
        "switchport port-security violation restrict",
        "switchport port-security",
        "interface FastEthernet0/16",
        "switchport mode access",
        "switchport access vlan 17",
        "switchport nonegotiate",
        "spanning-tree portfast",
        "spanning-tree bpduguard enable",
        "switchport port-security maximum 2",
        "switchport port-security violation restrict",
        "switchport port-security",
    ]

    return_value = task_9_1a.generate_access_config(access_vlans_mapping,
                                                    template_access_mode)
    assert return_value != None, "Функция ничего не возвращает"
    assert (
        type(return_value) == list
    ), f"По заданию функция должна возвращать список, а возвращает {type(return_value).__name__}"
    assert (
        correct_return_value_without_psecurity == return_value
    ), "Функция возвращает неправильное значение при вызове с psecurity == None"

    return_value_with_psecurity = task_9_1a.generate_access_config(
        access_vlans_mapping, template_access_mode, template_psecurity)
    assert (
        correct_return_value_with_psecurity == return_value_with_psecurity
    ), "Функция возвращает неправильное значение при вызове с psecurity"
Exemple #3
0
def test_function_return_value():
    """
    Function check
    """
    template_psecurity = [
        "switchport port-security maximum 2",
        "switchport port-security violation restrict",
        "switchport port-security",
    ]
    access_vlans_mapping = {
        "FastEthernet0/12": 10,
        "FastEthernet0/14": 11,
        "FastEthernet0/16": 17,
    }
    template_access_mode = [
        "switchport mode access",
        "switchport access vlan",
        "switchport nonegotiate",
        "spanning-tree portfast",
        "spanning-tree bpduguard enable",
    ]
    correct_return_value_without_psecurity = [
        "interface FastEthernet0/12",
        "switchport mode access",
        "switchport access vlan 10",
        "switchport nonegotiate",
        "spanning-tree portfast",
        "spanning-tree bpduguard enable",
        "interface FastEthernet0/14",
        "switchport mode access",
        "switchport access vlan 11",
        "switchport nonegotiate",
        "spanning-tree portfast",
        "spanning-tree bpduguard enable",
        "interface FastEthernet0/16",
        "switchport mode access",
        "switchport access vlan 17",
        "switchport nonegotiate",
        "spanning-tree portfast",
        "spanning-tree bpduguard enable",
    ]
    correct_return_value_with_psecurity = [
        "interface FastEthernet0/12",
        "switchport mode access",
        "switchport access vlan 10",
        "switchport nonegotiate",
        "spanning-tree portfast",
        "spanning-tree bpduguard enable",
        "switchport port-security maximum 2",
        "switchport port-security violation restrict",
        "switchport port-security",
        "interface FastEthernet0/14",
        "switchport mode access",
        "switchport access vlan 11",
        "switchport nonegotiate",
        "spanning-tree portfast",
        "spanning-tree bpduguard enable",
        "switchport port-security maximum 2",
        "switchport port-security violation restrict",
        "switchport port-security",
        "interface FastEthernet0/16",
        "switchport mode access",
        "switchport access vlan 17",
        "switchport nonegotiate",
        "spanning-tree portfast",
        "spanning-tree bpduguard enable",
        "switchport port-security maximum 2",
        "switchport port-security violation restrict",
        "switchport port-security",
    ]

    return_value = task_9_1a.generate_access_config(access_vlans_mapping,
                                                    template_access_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 (
        correct_return_value_without_psecurity == return_value
    ), "The function returns an incorrect value when called with psecurity == None"
    return_value_with_psecurity = task_9_1a.generate_access_config(
        access_vlans_mapping, template_access_mode, template_psecurity)
    assert (
        correct_return_value_with_psecurity == return_value_with_psecurity
    ), "The function returns an incorrect value when called with psecurity"