From cebb56387a001c33d7e44e8c758067910db3d309 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 13 Nov 2018 15:40:18 +0800 Subject: [PATCH] Fix tests. --- gns3server/controller/appliance.py | 2 + tests/controller/test_appliance.py | 10 ++--- tests/controller/test_controller.py | 62 ++--------------------------- tests/controller/test_project.py | 3 +- 4 files changed, 12 insertions(+), 65 deletions(-) diff --git a/gns3server/controller/appliance.py b/gns3server/controller/appliance.py index 7428d859..5616bf77 100644 --- a/gns3server/controller/appliance.py +++ b/gns3server/controller/appliance.py @@ -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): diff --git a/tests/controller/test_appliance.py b/tests/controller/test_appliance.py index 810ea5e3..a30bd370 100644 --- a/tests/controller/test_appliance.py +++ b/tests/controller/test_appliance.py @@ -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 diff --git a/tests/controller/test_controller.py b/tests/controller/test_controller.py index 7bec5ac5..18e87fd6 100644 --- a/tests/controller/test_controller.py +++ b/tests/controller/test_controller.py @@ -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() diff --git a/tests/controller/test_project.py b/tests/controller/test_project.py index d73008e7..78920ce0 100644 --- a/tests/controller/test_project.py +++ b/tests/controller/test_project.py @@ -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 }