mirror of
https://github.com/GNS3/gns3-server
synced 2025-01-11 16:41:04 +00:00
Fix tests.
This commit is contained in:
parent
89f7169589
commit
652d5788c3
@ -122,6 +122,7 @@ def test_json(node, compute):
|
|||||||
"compute_id": str(compute.id),
|
"compute_id": str(compute.id),
|
||||||
"project_id": node.project.id,
|
"project_id": node.project.id,
|
||||||
"node_id": node.id,
|
"node_id": node.id,
|
||||||
|
"appliance_id": None,
|
||||||
"node_type": node.node_type,
|
"node_type": node.node_type,
|
||||||
"name": "demo",
|
"name": "demo",
|
||||||
"console": node.console,
|
"console": node.console,
|
||||||
@ -157,6 +158,7 @@ def test_json(node, compute):
|
|||||||
assert node.__json__(topology_dump=True) == {
|
assert node.__json__(topology_dump=True) == {
|
||||||
"compute_id": str(compute.id),
|
"compute_id": str(compute.id),
|
||||||
"node_id": node.id,
|
"node_id": node.id,
|
||||||
|
"appliance_id": None,
|
||||||
"node_type": node.node_type,
|
"node_type": node.node_type,
|
||||||
"name": "demo",
|
"name": "demo",
|
||||||
"console": node.console,
|
"console": node.console,
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import uuid
|
||||||
import pytest
|
import pytest
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import zipstream
|
import zipstream
|
||||||
@ -211,7 +212,7 @@ def test_add_node_from_appliance(async_run, controller):
|
|||||||
compute.id = "local"
|
compute.id = "local"
|
||||||
project = Project(controller=controller, name="Test")
|
project = Project(controller=controller, name="Test")
|
||||||
controller._notification = MagicMock()
|
controller._notification = MagicMock()
|
||||||
controller._appliances["fakeid"] = Appliance("fakeid", {
|
appliance = Appliance(str(uuid.uuid4()), {
|
||||||
"server": "local",
|
"server": "local",
|
||||||
"name": "Test",
|
"name": "Test",
|
||||||
"default_name_format": "{name}-{0}",
|
"default_name_format": "{name}-{0}",
|
||||||
@ -219,15 +220,15 @@ def test_add_node_from_appliance(async_run, controller):
|
|||||||
"properties": {
|
"properties": {
|
||||||
"a": 1
|
"a": 1
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
controller._appliances[appliance.id] = appliance
|
||||||
controller._computes["local"] = compute
|
controller._computes["local"] = compute
|
||||||
|
|
||||||
response = MagicMock()
|
response = MagicMock()
|
||||||
response.json = {"console": 2048}
|
response.json = {"console": 2048}
|
||||||
compute.post = AsyncioMagicMock(return_value=response)
|
compute.post = AsyncioMagicMock(return_value=response)
|
||||||
|
|
||||||
node = async_run(project.add_node_from_appliance("fakeid", x=23, y=12))
|
node = async_run(project.add_node_from_appliance(appliance.id, x=23, y=12))
|
||||||
|
|
||||||
compute.post.assert_any_call('/projects', data={
|
compute.post.assert_any_call('/projects', data={
|
||||||
"name": project._name,
|
"name": project._name,
|
||||||
@ -244,7 +245,7 @@ def test_add_node_from_appliance(async_run, controller):
|
|||||||
controller.notification.emit.assert_any_call("node.created", node.__json__())
|
controller.notification.emit.assert_any_call("node.created", node.__json__())
|
||||||
|
|
||||||
# Make sure we can call twice the node creation
|
# Make sure we can call twice the node creation
|
||||||
node = async_run(project.add_node_from_appliance("fakeid", x=13, y=12))
|
node = async_run(project.add_node_from_appliance(appliance.id, x=13, y=12))
|
||||||
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
|
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
|
||||||
data={'node_id': node.id,
|
data={'node_id': node.id,
|
||||||
'name': 'Test-2',
|
'name': 'Test-2',
|
||||||
|
Loading…
Reference in New Issue
Block a user