mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Reload a topology work
This commit is contained in:
14 files changed
+167
-34
No files matched your search
@@ -205,6 +205,14 @@ def test_json(compute):
|
||||
"user": "test",
|
||||
"connected": True
|
||||
}
|
||||
assert compute.__json__(topology_dump=True) == {
|
||||
"compute_id": "my_compute_id",
|
||||
"name": compute.name,
|
||||
"protocol": "https",
|
||||
"host": "example.com",
|
||||
"port": 84,
|
||||
"user": "test",
|
||||
}
|
||||
|
||||
|
||||
def test_streamFile(project, async_run, compute):
|
||||
|
||||
@@ -26,7 +26,7 @@ from gns3server.controller.node import Node
|
||||
from gns3server.controller.compute import Compute
|
||||
from gns3server.controller.project import Project
|
||||
|
||||
from tests.utils import AsyncioBytesIO
|
||||
from tests.utils import AsyncioBytesIO, AsyncioMagicMock
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -54,6 +54,7 @@ def test_addNode(async_run, project, compute):
|
||||
node1 = Node(project, compute, "node1")
|
||||
|
||||
link = Link(project)
|
||||
project.dump = AsyncioMagicMock()
|
||||
async_run(link.add_node(node1, 0, 4))
|
||||
assert link._nodes == [
|
||||
{
|
||||
@@ -62,6 +63,7 @@ def test_addNode(async_run, project, compute):
|
||||
"port_number": 4
|
||||
}
|
||||
]
|
||||
assert project.dump.called
|
||||
|
||||
|
||||
def test_json(async_run, project, compute):
|
||||
@@ -90,6 +92,21 @@ def test_json(async_run, project, compute):
|
||||
"capture_file_name": None,
|
||||
"capture_file_path": None
|
||||
}
|
||||
assert link.__json__(topology_dump=True) == {
|
||||
"link_id": link.id,
|
||||
"nodes": [
|
||||
{
|
||||
"node_id": node1.id,
|
||||
"adapter_number": 0,
|
||||
"port_number": 4
|
||||
},
|
||||
{
|
||||
"node_id": node2.id,
|
||||
"adapter_number": 1,
|
||||
"port_number": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def test_start_streaming_pcap(link, async_run, tmpdir, project):
|
||||
|
||||
@@ -70,6 +70,20 @@ def test_json(node, compute):
|
||||
"symbol": node.symbol,
|
||||
"label": node.label
|
||||
}
|
||||
assert node.__json__(topology_dump=True) == {
|
||||
"compute_id": str(compute.id),
|
||||
"node_id": node.id,
|
||||
"node_type": node.node_type,
|
||||
"name": "demo",
|
||||
"console": node.console,
|
||||
"console_type": node.console_type,
|
||||
"properties": node.properties,
|
||||
"x": node.x,
|
||||
"y": node.y,
|
||||
"z": node.z,
|
||||
"symbol": node.symbol,
|
||||
"label": node.label
|
||||
}
|
||||
|
||||
|
||||
def test_init_without_uuid(project, compute):
|
||||
|
||||
@@ -228,3 +228,12 @@ def test_dump():
|
||||
with open(os.path.join(directory, p.id, "Test.gns3")) as f:
|
||||
content = f.read()
|
||||
assert "00010203-0405-0607-0809-0a0b0c0d0e0f" in content
|
||||
|
||||
|
||||
def test_open_close(async_run, controller):
|
||||
project = Project(controller=controller, status="closed")
|
||||
assert project.status == "closed"
|
||||
async_run(project.open())
|
||||
assert project.status == "opened"
|
||||
async_run(project.close())
|
||||
assert project.status == "closed"
|
||||
@@ -59,9 +59,9 @@ def test_basic_topology(tmpdir, async_run, controller):
|
||||
|
||||
topo = project_to_topology(project)
|
||||
assert len(topo["topology"]["nodes"]) == 2
|
||||
assert node1.__json__() in topo["topology"]["nodes"]
|
||||
assert topo["topology"]["links"][0] == link.__json__()
|
||||
assert topo["topology"]["computes"][0] == compute.__json__()
|
||||
assert node1.__json__(topology_dump=True) in topo["topology"]["nodes"]
|
||||
assert topo["topology"]["links"][0] == link.__json__(topology_dump=True)
|
||||
assert topo["topology"]["computes"][0] == compute.__json__(topology_dump=True)
|
||||
|
||||
|
||||
def test_load_topology(tmpdir):
|
||||
|
||||
Reference in new issue
Block a user