From cc6f4c0510e70ef03a0331c700ea691e4425c99b Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 21 Mar 2017 13:35:02 +0100 Subject: [PATCH] Add a modification uuid to settings returned by the server Ref #1949 --- gns3server/controller/__init__.py | 2 ++ tests/controller/test_controller.py | 3 ++- tests/handlers/api/controller/test_settings.py | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gns3server/controller/__init__.py b/gns3server/controller/__init__.py index 7540fca0..d7ae7d49 100644 --- a/gns3server/controller/__init__.py +++ b/gns3server/controller/__init__.py @@ -18,6 +18,7 @@ import os import sys import json +import uuid import socket import asyncio import aiohttp @@ -253,6 +254,7 @@ class Controller: @settings.setter def settings(self, val): self._settings = val + self._settings["modification_uuid"] = str(uuid.uuid4()) # We add a modification id to the settings it's help the gui to detect changes self.save() self.notification.emit("settings.updated", val) diff --git a/tests/controller/test_controller.py b/tests/controller/test_controller.py index 80f0a00b..f31fa999 100644 --- a/tests/controller/test_controller.py +++ b/tests/controller/test_controller.py @@ -195,7 +195,8 @@ def test_import_remote_gns3vm_1_x(controller, controller_config_path, async_run) def test_settings(controller): controller._notification = MagicMock() controller.settings = {"a": 1} - controller._notification.emit.assert_called_with("settings.updated", {"a": 1}) + controller._notification.emit.assert_called_with("settings.updated", controller.settings) + assert controller.settings["modification_uuid"] is not None def test_load_projects(controller, projects_dir, async_run): diff --git a/tests/handlers/api/controller/test_settings.py b/tests/handlers/api/controller/test_settings.py index 2bc52f39..a87df472 100644 --- a/tests/handlers/api/controller/test_settings.py +++ b/tests/handlers/api/controller/test_settings.py @@ -29,4 +29,5 @@ def test_settings(http_controller): assert response.status == 201 response = http_controller.get('/settings', example=True) assert response.status == 200 - assert response.json == query + assert response.json["test"] is True + assert response.json["modification_uuid"] is not None