From 39db35c3ffce0cb43630de7e2934cb7450db1eec Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Fri, 19 Aug 2016 17:05:28 +0200 Subject: [PATCH] Send notification when snasphot is restored Ref https://github.com/GNS3/gns3-gui/issues/1417 --- docs/notifications.rst | 6 ++++++ gns3server/controller/snapshot.py | 1 + tests/controller/test_snapshot.py | 1 + 3 files changed, 8 insertions(+) diff --git a/docs/notifications.rst b/docs/notifications.rst index 0e1ed6fd..e0430723 100644 --- a/docs/notifications.rst +++ b/docs/notifications.rst @@ -142,6 +142,12 @@ Project has been closed. .. literalinclude:: api/notifications/project.closed.json +snapshot.restored +-------------------------- + +Snapshot has been restored + +.. literalinclude:: api/notifications/project.snapshot_restored.json log.error --------- diff --git a/gns3server/controller/snapshot.py b/gns3server/controller/snapshot.py index 300de15b..c30d836a 100644 --- a/gns3server/controller/snapshot.py +++ b/gns3server/controller/snapshot.py @@ -79,6 +79,7 @@ class Snapshot: yield from self._project.delete_on_computes() # We don't send close notif to clients because the close / open dance is purely internal yield from self._project.close(ignore_notification=True) + self._project.controller.notification.emit("snapshot.restored", self.__json__()) shutil.rmtree(os.path.join(self._project.path, "project-files")) with open(self._path, "rb") as f: project = yield from import_project(self._project.controller, self._project.id, f, location=self._project.path) diff --git a/tests/controller/test_snapshot.py b/tests/controller/test_snapshot.py index 7f999ae7..cc6c5ec4 100644 --- a/tests/controller/test_snapshot.py +++ b/tests/controller/test_snapshot.py @@ -94,6 +94,7 @@ def test_restore(project, controller, async_run): with patch("gns3server.config.Config.get_section_config", return_value={"local": True}): async_run(snapshot.restore()) + assert "snapshot.restored" in [c[0][0] for c in controller.notification.emit.call_args_list] # project.closed notification should not be send when restoring snapshots assert "project.closed" not in [c[0][0] for c in controller.notification.emit.call_args_list]