API for deleting a link

This commit is contained in:
Julien Duponchelle 2016-03-14 20:54:05 +01:00
parent ed291da566
commit 8fed1d9b9f
No known key found for this signature in database
GPG Key ID: F1E2485547D4595D
3 changed files with 7 additions and 3 deletions

View File

@ -114,3 +114,7 @@ class Hypervisor:
@asyncio.coroutine
def post(self, path, data={}):
return (yield from self.httpQuery("POST", path, data))
@asyncio.coroutine
def delete(self, path):
return (yield from self.httpQuery("DELETE", path))

View File

@ -60,7 +60,7 @@ class LinkHandler:
"link_id": "UUID of the link"
},
status_codes={
201: "Link deleted",
204: "Link deleted",
400: "Invalid request"
},
description="Delete a link instance")
@ -70,5 +70,5 @@ class LinkHandler:
project = controller.getProject(request.match_info["project_id"])
link = project.getLink(request.match_info["link_id"])
yield from link.delete()
response.set_status(201)
response.set_status(204)
response.json(link)

View File

@ -79,4 +79,4 @@ def test_delete_link(http_controller, tmpdir, project, hypervisor, async_run):
project._links = {link.id: link}
with asyncio_patch("gns3server.controller.udp_link.Link.delete"):
response = http_controller.delete("/projects/{}/links/{}".format(project.id, link.id), example=True)
assert response.status == 201
assert response.status == 204