Example #1
0
def test_server_select_local_server_and_remote_local_disallowed(main_window, remote_server, local_server):

    with patch("gns3.qt.QtWidgets.QInputDialog.getItem", return_value=(remote_server.name(), True)) as mock:
        server = server_select(main_window, allow_local_server=False)

        assert not mock.called
        assert server == remote_server
Example #2
0
def test_server_select_local_server_and_remote_user_cancel(main_window, remote_server, local_server):

    with patch("gns3.qt.QtWidgets.QInputDialog.getItem", return_value=(local_server.name(), False)) as mock:
        server = server_select(main_window)

        assert mock.called
        args, kwargs = mock.call_args
        assert server is None
Example #3
0
def test_server_select_local_server_and_remote_select_local(main_window, remote_server, local_server):

    with patch("gns3.qt.QtWidgets.QInputDialog.getItem", return_value=(local_server.name(), True)) as mock:
        server = server_select(main_window)

        assert mock.called
        args, kwargs = mock.call_args
        assert args[3] == [local_server.name(), remote_server.name()]
        assert server.id() == local_server.id()
Example #4
0
def test_server_select_local_server_and_gns3_vm_select_vm(main_window, gns3vm_server, local_server):

    with patch("gns3.qt.QtWidgets.QInputDialog.getItem", return_value=("GNS3 VM", True)) as mock:
        server = server_select(main_window)

        assert mock.called
        args, kwargs = mock.call_args
        assert args[3] == ["Local server (http://127.0.0.1:8000)", "GNS3 VM (http://unset:8000)"]
        assert server == gns3vm_server
Example #5
0
def test_server_select_local_server_and_remote_select_remote(main_window, remote_server, local_server):

    with patch("gns3.qt.QtWidgets.QInputDialog.getItem", return_value=(remote_server.url(), True)) as mock:
        server = server_select(main_window)

        assert mock.called
        args, kwargs = mock.call_args
        assert args[3] == ["Local server (http://127.0.0.1:8000)", remote_server.url()]
        assert server == remote_server
Example #6
0
def test_server_select_local_server_local_disallow(main_window, local_server):
    """
    With only local server we don't show the list of server
    """

    with patch("gns3.qt.QtWidgets.QInputDialog.getItem") as mock:
        with pytest.raises(ValueError):
            server = server_select(main_window, allow_local_server=False)

            assert not mock.called
Example #7
0
def test_server_select_local_server(main_window, local_server):
    """
    With only local server we don't show the list of server
    """

    with patch("gns3.qt.QtWidgets.QInputDialog.getItem") as mock:
        server = server_select(main_window)

        assert not mock.called
        assert server == local_server
Example #8
0
def test_server_select_local_server_local_disallow(main_window, local_server):
    """
    With only local server we don't show the list of server
    """

    with patch("gns3.qt.QtWidgets.QMessageBox.critical"):
        with patch("gns3.qt.QtWidgets.QInputDialog.getItem") as mock:
            server = server_select(main_window, allow_local_server=False)
            assert not mock.called
            assert server is None
Example #9
0
def test_server_select_local_server(main_window, local_server):
    """
    With only local server we don't show the list of server
    """

    with patch("gns3.qt.QtWidgets.QInputDialog.getItem") as mock:
        server = server_select(main_window)

        assert not mock.called
        assert server == local_server
Example #10
0
def test_server_select_local_server_local_disallow(main_window, local_server):
    """
    With only local server we don't show the list of server
    """

    with patch("gns3.qt.QtWidgets.QInputDialog.getItem") as mock:
        with pytest.raises(ValueError):
            server = server_select(main_window, allow_local_server=False)

            assert not mock.called
Example #11
0
def test_server_select_node_type(main_window, remote_server, local_server):
    """
    If only one server support this node type select it by default
    """

    remote_server.setCapabilities({"node_types": ["dynamips", "nat"]})
    local_server.setCapabilities({"node_types": ["dynamips", "cloud"]})
    with patch("gns3.qt.QtWidgets.QInputDialog.getItem", return_value=(local_server.name(), True)) as mock:
        server = server_select(main_window, node_type="nat")

        assert not mock.called
        assert server == remote_server