|
|
|
@ -128,6 +128,43 @@ def test_create_link_failure(http_controller, tmpdir, project, compute, async_ru
|
|
|
|
|
assert len(project.links) == 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_link(http_controller, tmpdir, project, compute, async_run):
|
|
|
|
|
response = MagicMock()
|
|
|
|
|
response.json = {"console": 2048}
|
|
|
|
|
compute.post = AsyncioMagicMock(return_value=response)
|
|
|
|
|
|
|
|
|
|
node1 = async_run(project.add_node(compute, "node1", None, node_type="qemu"))
|
|
|
|
|
node1._ports = [EthernetPort("E0", 0, 0, 3)]
|
|
|
|
|
node2 = async_run(project.add_node(compute, "node2", None, node_type="qemu"))
|
|
|
|
|
node2._ports = [EthernetPort("E0", 0, 2, 4)]
|
|
|
|
|
|
|
|
|
|
with asyncio_patch("gns3server.controller.udp_link.UDPLink.create"):
|
|
|
|
|
response = http_controller.post("/projects/{}/links".format(project.id), {
|
|
|
|
|
"nodes": [
|
|
|
|
|
{
|
|
|
|
|
"node_id": node1.id,
|
|
|
|
|
"adapter_number": 0,
|
|
|
|
|
"port_number": 3,
|
|
|
|
|
"label": {
|
|
|
|
|
"text": "Text",
|
|
|
|
|
"x": 42,
|
|
|
|
|
"y": 0
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"node_id": node2.id,
|
|
|
|
|
"adapter_number": 2,
|
|
|
|
|
"port_number": 4
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
link_id = response.json["link_id"]
|
|
|
|
|
assert response.json["nodes"][0]["label"]["x"] == 42
|
|
|
|
|
response = http_controller.get("/projects/{}/links/{}".format(project.id, link_id), example=True)
|
|
|
|
|
assert response.status == 200
|
|
|
|
|
assert response.json["nodes"][0]["label"]["x"] == 42
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_update_link_suspend(http_controller, tmpdir, project, compute, async_run):
|
|
|
|
|
response = MagicMock()
|
|
|
|
|
response.json = {"console": 2048}
|
|
|
|
@ -242,7 +279,7 @@ def test_update_link(http_controller, tmpdir, project, compute, async_run):
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"filters": filters
|
|
|
|
|
})
|
|
|
|
|
}, example=True)
|
|
|
|
|
assert response.status == 201
|
|
|
|
|
assert response.json["nodes"][0]["label"]["x"] == 64
|
|
|
|
|
assert list(project.links.values())[0].filters == filters
|
|
|
|
|