diff --git a/docs/api/examples/post_virtualbox.txt b/docs/api/examples/post_virtualbox.txt new file mode 100644 index 00000000..0f7721fa --- /dev/null +++ b/docs/api/examples/post_virtualbox.txt @@ -0,0 +1,23 @@ +curl -i -X POST 'http://localhost:8000/virtualbox' -d '{"name": "VM1", "project_uuid": "a1e920ca-338a-4e9f-b363-aa607b09dd80", "vmname": "VM1"}' + +POST /virtualbox HTTP/1.1 +{ + "name": "VM1", + "project_uuid": "a1e920ca-338a-4e9f-b363-aa607b09dd80", + "vmname": "VM1" +} + + +HTTP/1.1 200 +CONNECTION: close +CONTENT-LENGTH: 133 +CONTENT-TYPE: application/json +DATE: Thu, 08 Jan 2015 16:09:15 GMT +SERVER: Python/3.4 aiohttp/0.13.1 +X-ROUTE: /virtualbox + +{ + "name": "VM1", + "project_uuid": "a1e920ca-338a-4e9f-b363-aa607b09dd80", + "uuid": "a028124a-9a69-4b06-b673-21f7eb3d034f" +} diff --git a/docs/api/examples/post_vpcs.txt b/docs/api/examples/post_vpcs.txt index 8a72d442..d5007ba4 100644 --- a/docs/api/examples/post_vpcs.txt +++ b/docs/api/examples/post_vpcs.txt @@ -20,5 +20,5 @@ X-ROUTE: /vpcs "name": "PC TEST 1", "project_uuid": "a1e920ca-338a-4e9f-b363-aa607b09dd80", "script_file": null, - "uuid": "a4809caf-bfba-4f34-ad78-1d054c8b7e5a" + "uuid": "934f0745-0824-451e-8ad6-db0877dbf387" } diff --git a/tests/api/test_virtualbox.py b/tests/api/test_virtualbox.py index f9e0ce46..c7b8856c 100644 --- a/tests/api/test_virtualbox.py +++ b/tests/api/test_virtualbox.py @@ -17,26 +17,25 @@ from tests.api.base import server, loop, project from tests.utils import asyncio_patch +from gns3server.modules.virtualbox.virtualbox_vm import VirtualBoxVM def test_vbox_create(server, project): - with asyncio_patch("gns3server.modules.VirtualBox.create_vm", return_value="61d61bdd-aa7d-4912-817f-65a9eb54d3ab"): - response = server.post("/virtualbox", {"name": "VM1", "vmname": "VM1", "project_uuid": project.uuid}, example=False) - assert response.status == 400 - assert response.route == "/virtualbox" - assert response.json["name"] == "VM1" - assert response.json["uuid"] == "61d61bdd-aa7d-4912-817f-65a9eb54d3ab" + response = server.post("/virtualbox", {"name": "VM1", "vmname": "VM1", "project_uuid": project.uuid}, example=True) + assert response.status == 200 + assert response.route == "/virtualbox" + assert response.json["name"] == "VM1" def test_vbox_start(server): with asyncio_patch("gns3server.modules.VirtualBox.start_vm", return_value=True): - response = server.post("/virtualbox/61d61bdd-aa7d-4912-817f-65a9eb54d3ab/start", {}, example=False) + response = server.post("/virtualbox/61d61bdd-aa7d-4912-817f-65a9eb54d3ab/start", {}, example=True) assert response.status == 200 assert response.route == "/virtualbox/{uuid}/start" def test_vbox_stop(server): with asyncio_patch("gns3server.modules.VirtualBox.stop_vm", return_value=True): - response = server.post("/virtualbox/61d61bdd-aa7d-4912-817f-65a9eb54d3ab/stop", {}, example=False) + response = server.post("/virtualbox/61d61bdd-aa7d-4912-817f-65a9eb54d3ab/stop", {}, example=True) assert response.status == 200 - assert response.route == "/virtualbox/{uuid}/stop" \ No newline at end of file + assert response.route == "/virtualbox/{uuid}/stop"