1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Send node.updated event and tests are green

Fix #524
This commit is contained in:
Julien Duponchelle 2016-05-16 21:12:32 +02:00
parent cb70cfecd7
commit a496aaab9e
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
3 changed files with 7 additions and 7 deletions

View File

@ -105,9 +105,7 @@ class BaseNode:
def status(self, status): def status(self, status):
self._node_status = status self._node_status = status
if status in ("started", "stopped", "suspended"): self.project.emit("node.updated", self)
self.project.emit("node.{status}".format(status=status), {"node_id": self.id})
self.project.emit("node.updated", self) # FIXME: should we send this when we just start/stop/suspend a node?
@property @property
def command_line(self): def command_line(self):

View File

@ -121,14 +121,14 @@ class Project:
if compute not in self._project_created_on_compute: if compute not in self._project_created_on_compute:
# For a local server we send the project path # For a local server we send the project path
if compute.id == "local": if compute.id == "local":
yield from compute.post("/projects", { yield from compute.post("/projects", data={
"name": self._name, "name": self._name,
"project_id": self._id, "project_id": self._id,
"temporary": self._temporary, "temporary": self._temporary,
"path": self._path "path": self._path
}) })
else: else:
yield from compute.post("/projects", { yield from compute.post("/projects", data={
"name": self._name, "name": self._name,
"project_id": self._id, "project_id": self._id,
"temporary": self._temporary "temporary": self._temporary

View File

@ -90,7 +90,7 @@ def test_add_node_local(async_run):
node = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"})) node = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"}))
compute.post.assert_any_call('/projects', { compute.post.assert_any_call('/projects', data={
"name": project._name, "name": project._name,
"project_id": project._id, "project_id": project._id,
"temporary": project._temporary, "temporary": project._temporary,
@ -98,6 +98,7 @@ def test_add_node_local(async_run):
}) })
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id), compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
data={'node_id': node.id, data={'node_id': node.id,
'console_type': 'telnet',
'startup_config': 'test.cfg', 'startup_config': 'test.cfg',
'name': 'test'}) 'name': 'test'})
assert compute in project._project_created_on_compute assert compute in project._project_created_on_compute
@ -117,13 +118,14 @@ def test_add_node_non_local(async_run):
node = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"})) node = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"}))
compute.post.assert_any_call('/projects', { compute.post.assert_any_call('/projects', data={
"name": project._name, "name": project._name,
"project_id": project._id, "project_id": project._id,
"temporary": project._temporary "temporary": project._temporary
}) })
compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id), compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id),
data={'node_id': node.id, data={'node_id': node.id,
'console_type': 'telnet',
'startup_config': 'test.cfg', 'startup_config': 'test.cfg',
'name': 'test'}) 'name': 'test'})
assert compute in project._project_created_on_compute assert compute in project._project_created_on_compute