mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-19 04:35:14 +02:00
Fix creation of link when reloading a project
Fix https://github.com/GNS3/gns3-gui/issues/1457
This commit is contained in:
8 files changed
+192
-107
No files matched your search
@@ -338,77 +338,6 @@ def test_stop_vm(controller, async_run):
|
||||
assert mock.called
|
||||
|
||||
|
||||
def test_load_project(controller, async_run, tmpdir):
|
||||
data = {
|
||||
"name": "Experience",
|
||||
"project_id": "c8d07a5a-134f-4c3f-8599-e35eac85eb17",
|
||||
"revision": 5,
|
||||
"type": "topology",
|
||||
"version": "2.0.0dev1",
|
||||
"topology": {
|
||||
"drawings": [],
|
||||
"computes": [
|
||||
{
|
||||
"compute_id": "my_remote",
|
||||
"host": "127.0.0.1",
|
||||
"name": "My remote",
|
||||
"port": 3080,
|
||||
"protocol": "http",
|
||||
}
|
||||
],
|
||||
"links": [
|
||||
{
|
||||
"link_id": "c44331d2-2da4-490d-9aad-7f5c126ae271",
|
||||
"nodes": [
|
||||
{"node_id": "c067b922-7f77-4680-ac00-0226c6583598", "adapter_number": 0, "port_number": 0},
|
||||
{"node_id": "50d66d7b-0dd7-4e9f-b720-6eb621ae6543", "adapter_number": 0, "port_number": 0},
|
||||
],
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"compute_id": "my_remote",
|
||||
"name": "PC2",
|
||||
"node_id": "c067b922-7f77-4680-ac00-0226c6583598",
|
||||
"node_type": "vpcs",
|
||||
"properties": {
|
||||
"startup_script": "set pcname PC2\n",
|
||||
"startup_script_path": "startup.vpc"
|
||||
},
|
||||
},
|
||||
{
|
||||
"compute_id": "my_remote",
|
||||
"name": "PC1",
|
||||
"node_id": "50d66d7b-0dd7-4e9f-b720-6eb621ae6543",
|
||||
"node_type": "vpcs",
|
||||
"properties": {
|
||||
"startup_script": "set pcname PC1\n",
|
||||
"startup_script_path": "startup.vpc"
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
with open(str(tmpdir / "test.gns3"), "w+") as f:
|
||||
json.dump(data, f)
|
||||
controller.add_compute = AsyncioMagicMock()
|
||||
controller._computes["my_remote"] = MagicMock()
|
||||
|
||||
with asyncio_patch("gns3server.controller.node.Node.create") as mock_node_create:
|
||||
project = async_run(controller.load_project(str(tmpdir / "test.gns3")))
|
||||
|
||||
assert project._topology_file() == str(tmpdir / "test.gns3")
|
||||
controller.add_compute.assert_called_with(compute_id='my_remote', host='127.0.0.1', name='My remote', port=3080, protocol='http')
|
||||
project = controller.get_project('c8d07a5a-134f-4c3f-8599-e35eac85eb17')
|
||||
assert project.name == "Experience"
|
||||
assert project.path == str(tmpdir)
|
||||
link = project.get_link("c44331d2-2da4-490d-9aad-7f5c126ae271")
|
||||
assert len(link.nodes) == 2
|
||||
|
||||
node1 = project.get_node("50d66d7b-0dd7-4e9f-b720-6eb621ae6543")
|
||||
assert node1.name == "PC1"
|
||||
|
||||
|
||||
def test_get_free_project_name(controller, async_run):
|
||||
|
||||
async_run(controller.add_project(project_id=str(uuid.uuid4()), name="Test"))
|
||||
|
||||
Reference in new issue
Block a user