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

Fix Deleted node are still return by the API

Fix #529
This commit is contained in:
Julien Duponchelle 2016-05-17 13:11:43 +02:00
parent 342bcdb5b6
commit ce0d715895
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
3 changed files with 27 additions and 2 deletions

View File

@ -140,6 +140,12 @@ class Project:
return node
return self._nodes[node_id]
@asyncio.coroutine
def delete_node(self, node_id):
node = self.get_node(node_id)
del self._nodes[node.id]
yield from node.delete()
def get_node(self, node_id):
"""
Return the node or raise a 404 if the node is unknown

View File

@ -260,6 +260,5 @@ class NodeHandler:
description="Delete a node instance")
def delete(request, response):
project = Controller.instance().get_project(request.match_info["project_id"])
node = project.get_node(request.match_info["node_id"])
yield from node.destroy()
yield from project.delete_node(request.match_info["node_id"])
response.set_status(204)

View File

@ -89,6 +89,7 @@ def test_add_node_local(async_run):
compute.post = AsyncioMagicMock(return_value=response)
node = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"}))
assert node.id in project._nodes
compute.post.assert_any_call('/projects', data={
"name": project._name,
@ -131,6 +132,25 @@ def test_add_node_non_local(async_run):
assert compute in project._project_created_on_compute
def test_delete_node(async_run):
"""
For a local server we send the project path
"""
compute = MagicMock()
project = Project()
response = MagicMock()
response.json = {"console": 2048}
compute.post = AsyncioMagicMock(return_value=response)
node = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"}))
assert node.id in project._nodes
async_run(project.delete_node(node.id))
assert node.id not in project._nodes
compute.delete.assert_any_call('/projects/{}/vpcs/nodes/{}'.format(project.id, node.id))
def test_getVM(async_run):
compute = MagicMock()
project = Project()