mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Merge branch '2.0' into 2.1
This commit is contained in:
335 files changed
+1000
-5777
No files matched your search
@@ -29,21 +29,29 @@ def nio():
|
||||
return NIOUDP(4242, "127.0.0.1", 4343)
|
||||
|
||||
|
||||
def test_json_with_ports(on_gns3vm, project):
|
||||
@pytest.fixture
|
||||
def manager():
|
||||
m = MagicMock()
|
||||
m.module_name = "builtins"
|
||||
return m
|
||||
|
||||
|
||||
def test_json_with_ports(on_gns3vm, project, manager):
|
||||
ports = [
|
||||
{
|
||||
"interface": "virbr0",
|
||||
"name": "virbr0",
|
||||
"port_number": 0,
|
||||
"type": "ethernet"
|
||||
"type": "ethernet",
|
||||
}
|
||||
]
|
||||
cloud = Cloud("cloud1", str(uuid.uuid4()), project, MagicMock(), ports=ports)
|
||||
cloud = Cloud("cloud1", str(uuid.uuid4()), project, manager, ports=ports)
|
||||
assert cloud.__json__() == {
|
||||
"name": "cloud1",
|
||||
"node_id": cloud.id,
|
||||
"project_id": project.id,
|
||||
"status": "stopped",
|
||||
"node_directory": cloud.working_dir,
|
||||
"ports_mapping": [
|
||||
{
|
||||
"interface": "virbr0",
|
||||
@@ -60,16 +68,17 @@ def test_json_with_ports(on_gns3vm, project):
|
||||
}
|
||||
|
||||
|
||||
def test_json_without_ports(on_gns3vm, project):
|
||||
def test_json_without_ports(on_gns3vm, project, manager):
|
||||
"""
|
||||
If no interface is provide the cloud is prefill with non special interfaces
|
||||
"""
|
||||
cloud = Cloud("cloud1", str(uuid.uuid4()), project, MagicMock(), ports=None)
|
||||
cloud = Cloud("cloud1", str(uuid.uuid4()), project, manager, ports=None)
|
||||
assert cloud.__json__() == {
|
||||
"name": "cloud1",
|
||||
"node_id": cloud.id,
|
||||
"project_id": project.id,
|
||||
"status": "stopped",
|
||||
"node_directory": cloud.working_dir,
|
||||
"ports_mapping": [
|
||||
{
|
||||
"interface": "eth0",
|
||||
|
||||
@@ -144,7 +144,7 @@ def test_termination_callback(vm, async_run):
|
||||
vm.status = "started"
|
||||
|
||||
with NotificationManager.instance().queue() as queue:
|
||||
vm._termination_callback(0)
|
||||
async_run(vm._termination_callback(0))
|
||||
assert vm.status == "stopped"
|
||||
|
||||
async_run(queue.get(0)) # Ping
|
||||
@@ -163,10 +163,10 @@ def test_termination_callback_error(vm, tmpdir, async_run):
|
||||
vm._stdout_file = str(tmpdir / "qemu.log")
|
||||
|
||||
with NotificationManager.instance().queue() as queue:
|
||||
vm._termination_callback(1)
|
||||
async_run(vm._termination_callback(1))
|
||||
assert vm.status == "stopped"
|
||||
|
||||
async_run(queue.get(0)) # Ping
|
||||
async_run(queue.get(0)) # Ping
|
||||
|
||||
(action, event, kwargs) = queue.get_nowait()
|
||||
assert action == "node.updated"
|
||||
|
||||
Reference in new issue
Block a user