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
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
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()
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
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
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
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
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
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