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

Fixes not known category in Appliances (Fixes #1156)

This commit is contained in:
ziajka 2017-08-07 10:00:46 +02:00
parent 3caba334c0
commit 3a1fd892ac
2 changed files with 26 additions and 1 deletions

View File

@ -73,12 +73,16 @@ class Appliance:
""" """
Appliance data (a hash) Appliance data (a hash)
""" """
try:
category = ID_TO_CATEGORY[self._data["category"]]
except KeyError:
category = self._data["category"]
return { return {
"appliance_id": self._id, "appliance_id": self._id,
"node_type": self._data["node_type"], "node_type": self._data["node_type"],
"name": self._data["name"], "name": self._data["name"],
"default_name_format": self._data.get("default_name_format", "{name}-{0}"), "default_name_format": self._data.get("default_name_format", "{name}-{0}"),
"category": ID_TO_CATEGORY[self._data["category"]], "category": category,
"symbol": self._data.get("symbol", ":/symbols/computer.svg"), "symbol": self._data.get("symbol", ":/symbols/computer.svg"),
"compute_id": self.compute_id, "compute_id": self.compute_id,
"builtin": self._builtin "builtin": self._builtin

View File

@ -39,6 +39,27 @@ def test_appliance_json():
} }
def test_appliance_json_with_not_known_category():
a = Appliance(None, {
"node_type": "qemu",
"name": "Test",
"default_name_format": "{name}-{0}",
"category": 'Not known',
"symbol": "qemu.svg",
"server": "local"
})
assert a.__json__() == {
"appliance_id": a.id,
"node_type": "qemu",
"builtin": False,
"name": "Test",
"default_name_format": "{name}-{0}",
"category": "Not known",
"symbol": "qemu.svg",
"compute_id": "local"
}
def test_appliance_fix_linked_base(): def test_appliance_fix_linked_base():
""" """
Version of the gui before 2.1 use linked_base and the server Version of the gui before 2.1 use linked_base and the server