1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 03:08:14 +00:00

Fix tests.

This commit is contained in:
grossmj 2018-11-13 15:40:18 +08:00
parent f91d3c9dbb
commit cebb56387a
4 changed files with 12 additions and 65 deletions

View File

@ -95,6 +95,8 @@ class Appliance:
return self._builtin
def update(self, **kwargs):
#TODO: do not update appliance_id, builtin or appliance_type
self._settings.update(kwargs)
def __json__(self):

View File

@ -30,7 +30,7 @@ def test_appliance_json():
})
assert a.__json__() == {
"appliance_id": a.id,
"node_type": "qemu",
"appliance_type": "qemu",
"builtin": False,
"name": "Test",
"default_name_format": "{name}-{0}",
@ -53,7 +53,7 @@ def test_appliance_json_with_not_known_category():
})
assert a.__json__() == {
"appliance_id": a.id,
"node_type": "qemu",
"appliance_type": "qemu",
"builtin": False,
"name": "Test",
"default_name_format": "{name}-{0}",
@ -76,7 +76,7 @@ def test_appliance_json_with_platform():
})
assert a.__json__() == {
"appliance_id": a.id,
"node_type": "dynamips",
"appliance_type": "dynamips",
"builtin": False,
"name": "Test",
"default_name_format": "{name}-{0}",
@ -101,5 +101,5 @@ def test_appliance_fix_linked_base():
"server": "local",
"linked_base": True
})
assert a.data["linked_clone"]
assert "linked_base" not in a.data
assert a.settings["linked_clone"]
assert "linked_base" not in a.settings

View File

@ -506,25 +506,15 @@ def test_appliance_templates(controller, async_run, tmpdir):
def test_load_appliances(controller):
controller._settings = {
"Qemu": {
"vms": [
{
"name": "Test",
"node_type": "qemu",
"category": "router"
}
]
}
}
controller._settings = {}
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 "VPCS" in [appliance.name for appliance in controller.appliances.values()]
for appliance in controller.appliances.values():
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
for appliance in controller.appliances.values():
@ -540,52 +530,6 @@ def test_load_appliances(controller):
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):
controller._computes["local"] = AsyncioMagicMock()
node_mock = AsyncioMagicMock()

View File

@ -216,7 +216,8 @@ def test_add_node_from_appliance(async_run, controller):
"server": "local",
"name": "Test",
"default_name_format": "{name}-{0}",
"node_type": "vpcs",
"appliance_type": "vpcs",
"builtin": False,
"properties": {
"a": 1
}