Ejemplo n.º 1
0
def test_method_delete_link(normalized_topology_example, capsys):
    norm_top = task_22_1b.Topology(normalized_topology_example)
    delete_link_result = norm_top.delete_link(("R3", "Eth0/0"),
                                              ("SW1", "Eth0/3"))
    assert None == delete_link_result, "The delete_link method should return None"

    assert ("R3",
            "Eth0/0") not in norm_top.topology, "The link was not deleted"

    norm_top.delete_link(("R5", "Eth0/0"), ("R3", "Eth0/2"))
    assert ("R3",
            "Eth0/2") not in norm_top.topology, "The link was not deleted"

    norm_top.delete_link(("R8", "Eth0/2"), ("R9", "Eth0/1"))
    stdout, err = capsys.readouterr()
    link_msg = "There is no such link"
    assert (
        link_msg in stdout
    ), "When deleting a nonexistent connection, the message 'There is no such link' was not printed"
Ejemplo n.º 2
0
def test_method_delete_link(normalized_topology_example, capsys):
    """Проверка работы метода delete_link"""
    norm_top = task_22_1b.Topology(normalized_topology_example)
    delete_link_result = norm_top.delete_link(("R3", "Eth0/0"), ("SW1", "Eth0/3"))
    assert delete_link_result == None, "Метод delete_link не должен ничего возвращать"

    assert ("R3", "Eth0/0") not in norm_top.topology, "Соединение не было удалено"

    # проверка удаления зеркального линка
    norm_top.delete_link(("R5", "Eth0/0"), ("R3", "Eth0/2"))
    assert ("R3", "Eth0/2") not in norm_top.topology, "Соединение не было удалено"

    # проверка удаления несуществующего линка
    norm_top.delete_link(("R8", "Eth0/2"), ("R9", "Eth0/1"))
    out, err = capsys.readouterr()
    link_msg = "Такого соединения нет"
    assert (
        link_msg in out
    ), "При удалении несуществующего соединения, не было выведено сообщение 'Такого соединения нет'"
Ejemplo n.º 3
0
def test_method_delete_link_created(topology_with_dupl_links,
                                    normalized_topology_example):
    norm_top = task_22_1b.Topology(normalized_topology_example)
    check_attr_or_method(norm_top, method="delete_link")
Ejemplo n.º 4
0
def test_attr_topology(topology_with_dupl_links):
    """Checking that the Topology object has a topology attribute"""
    top_with_data = task_22_1b.Topology(topology_with_dupl_links)
    check_attr_or_method(top_with_data, attr="topology")
Ejemplo n.º 5
0
def test_method_delete_link_created(
    topology_with_dupl_links, normalized_topology_example
):
    """Проверяем, что в объекте Topology есть метод delete_link"""
    norm_top = task_22_1b.Topology(normalized_topology_example)
    check_attr_or_method(norm_top, method="delete_link")
Ejemplo n.º 6
0
def test_attr_topology(topology_with_dupl_links):
    """Проверяем, что в объекте Topology есть атрибут topology"""
    top_with_data = task_22_1b.Topology(topology_with_dupl_links)
    check_attr_or_method(top_with_data, attr="topology")