1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-15 12:59:06 +00:00

Merge pull request #1157 from GNS3/bugfix-1156

Fixes not known category in Appliances (Fixes #1156)
This commit is contained in:
Jeremy Grossmann 2017-08-07 16:46:14 +08:00 committed by GitHub
commit fc9d44011b
2 changed files with 26 additions and 1 deletions

View File

@ -73,12 +73,16 @@ class Appliance:
"""
Appliance data (a hash)
"""
try:
category = ID_TO_CATEGORY[self._data["category"]]
except KeyError:
category = self._data["category"]
return {
"appliance_id": self._id,
"node_type": self._data["node_type"],
"name": self._data["name"],
"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"),
"compute_id": self.compute_id,
"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():
"""
Version of the gui before 2.1 use linked_base and the server