1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-12 19:38:57 +00:00

Fix Compute name is lost at save

Fix #562
This commit is contained in:
Julien Duponchelle 2016-06-08 14:25:11 +02:00
parent add546158f
commit 1b530bde3f
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
4 changed files with 6 additions and 1 deletions

View File

@ -60,6 +60,7 @@ class Controller:
Save the controller configuration on disk
"""
data = {"computes": [{"host": c.host,
"name": c.name,
"port": c.port,
"protocol": c.protocol,
"user": c.user,

View File

@ -123,6 +123,7 @@ class Compute:
self._session.close()
self._connected = False
self._controller.notification.emit("compute.updated", self.__json__())
self._controller.save()
@asyncio.coroutine
def close(self):

View File

@ -223,6 +223,7 @@ def test_close(compute, async_run):
def test_update(compute, controller, async_run):
compute._controller._notification = MagicMock()
compute._controller.save = MagicMock()
compute.name = "Test"
compute.host = "example.org"
compute._connected = True
@ -231,6 +232,7 @@ def test_update(compute, controller, async_run):
assert compute.host == "example.org"
controller.notification.emit.assert_called_with("compute.updated", compute.__json__())
assert compute.connected is False
assert compute._controller.save.called
def test_forward_get(compute, async_run):

View File

@ -102,13 +102,14 @@ def test_deleteCompute(controller, controller_config_path, async_run):
def test_addComputeConfigFile(controller, controller_config_path, async_run):
async_run(controller.add_compute(compute_id="test1"))
async_run(controller.add_compute(compute_id="test1", name="Test"))
assert len(controller.computes) == 1
with open(controller_config_path) as f:
data = json.load(f)
assert data["computes"] == [
{
'compute_id': 'test1',
'name': 'Test',
'host': 'localhost',
'port': 3080,
'protocol': 'http',