mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-18 07:23:47 +02:00
Fix tests.
This commit is contained in:
parent
f91d3c9dbb
commit
cebb56387a
@ -95,6 +95,8 @@ class Appliance:
|
|||||||
return self._builtin
|
return self._builtin
|
||||||
|
|
||||||
def update(self, **kwargs):
|
def update(self, **kwargs):
|
||||||
|
|
||||||
|
#TODO: do not update appliance_id, builtin or appliance_type
|
||||||
self._settings.update(kwargs)
|
self._settings.update(kwargs)
|
||||||
|
|
||||||
def __json__(self):
|
def __json__(self):
|
||||||
|
@ -30,7 +30,7 @@ def test_appliance_json():
|
|||||||
})
|
})
|
||||||
assert a.__json__() == {
|
assert a.__json__() == {
|
||||||
"appliance_id": a.id,
|
"appliance_id": a.id,
|
||||||
"node_type": "qemu",
|
"appliance_type": "qemu",
|
||||||
"builtin": False,
|
"builtin": False,
|
||||||
"name": "Test",
|
"name": "Test",
|
||||||
"default_name_format": "{name}-{0}",
|
"default_name_format": "{name}-{0}",
|
||||||
@ -53,7 +53,7 @@ def test_appliance_json_with_not_known_category():
|
|||||||
})
|
})
|
||||||
assert a.__json__() == {
|
assert a.__json__() == {
|
||||||
"appliance_id": a.id,
|
"appliance_id": a.id,
|
||||||
"node_type": "qemu",
|
"appliance_type": "qemu",
|
||||||
"builtin": False,
|
"builtin": False,
|
||||||
"name": "Test",
|
"name": "Test",
|
||||||
"default_name_format": "{name}-{0}",
|
"default_name_format": "{name}-{0}",
|
||||||
@ -76,7 +76,7 @@ def test_appliance_json_with_platform():
|
|||||||
})
|
})
|
||||||
assert a.__json__() == {
|
assert a.__json__() == {
|
||||||
"appliance_id": a.id,
|
"appliance_id": a.id,
|
||||||
"node_type": "dynamips",
|
"appliance_type": "dynamips",
|
||||||
"builtin": False,
|
"builtin": False,
|
||||||
"name": "Test",
|
"name": "Test",
|
||||||
"default_name_format": "{name}-{0}",
|
"default_name_format": "{name}-{0}",
|
||||||
@ -101,5 +101,5 @@ def test_appliance_fix_linked_base():
|
|||||||
"server": "local",
|
"server": "local",
|
||||||
"linked_base": True
|
"linked_base": True
|
||||||
})
|
})
|
||||||
assert a.data["linked_clone"]
|
assert a.settings["linked_clone"]
|
||||||
assert "linked_base" not in a.data
|
assert "linked_base" not in a.settings
|
||||||
|
@ -506,25 +506,15 @@ def test_appliance_templates(controller, async_run, tmpdir):
|
|||||||
|
|
||||||
|
|
||||||
def test_load_appliances(controller):
|
def test_load_appliances(controller):
|
||||||
controller._settings = {
|
controller._settings = {}
|
||||||
"Qemu": {
|
|
||||||
"vms": [
|
|
||||||
{
|
|
||||||
"name": "Test",
|
|
||||||
"node_type": "qemu",
|
|
||||||
"category": "router"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
controller.load_appliances()
|
controller.load_appliances()
|
||||||
assert "Test" in [appliance.name for appliance in controller.appliances.values()]
|
|
||||||
assert "Cloud" in [appliance.name for appliance in controller.appliances.values()]
|
assert "Cloud" in [appliance.name for appliance in controller.appliances.values()]
|
||||||
assert "VPCS" in [appliance.name for appliance in controller.appliances.values()]
|
assert "VPCS" in [appliance.name for appliance in controller.appliances.values()]
|
||||||
|
|
||||||
for appliance in controller.appliances.values():
|
for appliance in controller.appliances.values():
|
||||||
if appliance.name == "VPCS":
|
if appliance.name == "VPCS":
|
||||||
assert appliance._data["properties"] == {"base_script_file": "vpcs_base_config.txt"}
|
assert appliance._settings["properties"] == {"base_script_file": "vpcs_base_config.txt"}
|
||||||
|
|
||||||
# UUID should not change when you run again the function
|
# UUID should not change when you run again the function
|
||||||
for appliance in controller.appliances.values():
|
for appliance in controller.appliances.values():
|
||||||
@ -540,52 +530,6 @@ def test_load_appliances(controller):
|
|||||||
assert cloud_uuid == appliance.id
|
assert cloud_uuid == appliance.id
|
||||||
|
|
||||||
|
|
||||||
def test_load_appliances_deprecated_features_default_symbol(controller):
|
|
||||||
controller._settings = {
|
|
||||||
"Qemu": {
|
|
||||||
"vms": [
|
|
||||||
{
|
|
||||||
"name": "Test",
|
|
||||||
"node_type": "qemu",
|
|
||||||
"category": "router",
|
|
||||||
"default_symbol": ":/symbols/iosv_virl.normal.svg",
|
|
||||||
"hover_symbol": ":/symbols/iosv_virl.selected.svg",
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
controller.load_appliances()
|
|
||||||
appliances = dict([(a.name, a) for a in controller.appliances.values()])
|
|
||||||
|
|
||||||
assert appliances["Test"].__json__()["symbol"] == ":/symbols/computer.svg"
|
|
||||||
assert "default_symbol" not in appliances["Test"].data.keys()
|
|
||||||
assert "hover_symbol" not in appliances["Test"].data.keys()
|
|
||||||
|
|
||||||
|
|
||||||
def test_load_appliances_deprecated_features_default_symbol_with_symbol(controller):
|
|
||||||
controller._settings = {
|
|
||||||
"Qemu": {
|
|
||||||
"vms": [
|
|
||||||
{
|
|
||||||
"name": "Test",
|
|
||||||
"node_type": "qemu",
|
|
||||||
"category": "router",
|
|
||||||
"default_symbol": ":/symbols/iosv_virl.normal.svg",
|
|
||||||
"hover_symbol": ":/symbols/iosv_virl.selected.svg",
|
|
||||||
"symbol": ":/symbols/my-symbol.svg"
|
|
||||||
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
controller.load_appliances()
|
|
||||||
appliances = dict([(a.name, a) for a in controller.appliances.values()])
|
|
||||||
|
|
||||||
assert appliances["Test"].__json__()["symbol"] == ":/symbols/my-symbol.svg"
|
|
||||||
assert "default_symbol" not in appliances["Test"].data.keys()
|
|
||||||
assert "hover_symbol" not in appliances["Test"].data.keys()
|
|
||||||
|
|
||||||
|
|
||||||
def test_autoidlepc(controller, async_run):
|
def test_autoidlepc(controller, async_run):
|
||||||
controller._computes["local"] = AsyncioMagicMock()
|
controller._computes["local"] = AsyncioMagicMock()
|
||||||
node_mock = AsyncioMagicMock()
|
node_mock = AsyncioMagicMock()
|
||||||
|
@ -216,7 +216,8 @@ def test_add_node_from_appliance(async_run, controller):
|
|||||||
"server": "local",
|
"server": "local",
|
||||||
"name": "Test",
|
"name": "Test",
|
||||||
"default_name_format": "{name}-{0}",
|
"default_name_format": "{name}-{0}",
|
||||||
"node_type": "vpcs",
|
"appliance_type": "vpcs",
|
||||||
|
"builtin": False,
|
||||||
"properties": {
|
"properties": {
|
||||||
"a": 1
|
"a": 1
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user