From 16c2305b3326e661ac1fba1e4c44fa1a78262866 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 15 Aug 2016 12:06:26 +0200 Subject: [PATCH] Send a project closed event when project close Ref #602 --- docs/notifications.rst | 9 +++++++++ gns3server/controller/project.py | 1 + tests/controller/test_project.py | 2 ++ 3 files changed, 12 insertions(+) diff --git a/docs/notifications.rst b/docs/notifications.rst index 81dd1472..4739bb82 100644 --- a/docs/notifications.rst +++ b/docs/notifications.rst @@ -126,6 +126,15 @@ Drawing has been deleted. .. literalinclude:: api/notifications/drawing.deleted.json +project.closed +--------------- + +Project has been closed. + +.. literalinclude:: api/notifications/project.closed.json + + + log.error --------- diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py index 890625a4..50df8da3 100644 --- a/gns3server/controller/project.py +++ b/gns3server/controller/project.py @@ -445,6 +445,7 @@ class Project: yield from compute.post("/projects/{}/close".format(self._id)) self._cleanPictures() self._status = "closed" + self.controller.notification.emit("project.closed", self.__json__()) def _cleanPictures(self): """ diff --git a/tests/controller/test_project.py b/tests/controller/test_project.py index eb046c7f..3ec1b187 100644 --- a/tests/controller/test_project.py +++ b/tests/controller/test_project.py @@ -332,8 +332,10 @@ def test_open_close(async_run, controller): assert project.status == "closed" async_run(project.open()) assert project.status == "opened" + controller._notification = MagicMock() async_run(project.close()) assert project.status == "closed" + controller.notification.emit.assert_any_call("project.closed", project.__json__()) def test_is_running(project, async_run, node):