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

Fix virtualbox test

This commit is contained in:
Julien Duponchelle 2015-01-20 23:40:03 +01:00
parent 061d3223a7
commit 3530b85b56
3 changed files with 32 additions and 10 deletions

View File

@ -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"
}

View File

@ -20,5 +20,5 @@ X-ROUTE: /vpcs
"name": "PC TEST 1", "name": "PC TEST 1",
"project_uuid": "a1e920ca-338a-4e9f-b363-aa607b09dd80", "project_uuid": "a1e920ca-338a-4e9f-b363-aa607b09dd80",
"script_file": null, "script_file": null,
"uuid": "a4809caf-bfba-4f34-ad78-1d054c8b7e5a" "uuid": "934f0745-0824-451e-8ad6-db0877dbf387"
} }

View File

@ -17,26 +17,25 @@
from tests.api.base import server, loop, project from tests.api.base import server, loop, project
from tests.utils import asyncio_patch from tests.utils import asyncio_patch
from gns3server.modules.virtualbox.virtualbox_vm import VirtualBoxVM
def test_vbox_create(server, project): 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=True)
response = server.post("/virtualbox", {"name": "VM1", "vmname": "VM1", "project_uuid": project.uuid}, example=False) assert response.status == 200
assert response.status == 400
assert response.route == "/virtualbox" assert response.route == "/virtualbox"
assert response.json["name"] == "VM1" assert response.json["name"] == "VM1"
assert response.json["uuid"] == "61d61bdd-aa7d-4912-817f-65a9eb54d3ab"
def test_vbox_start(server): def test_vbox_start(server):
with asyncio_patch("gns3server.modules.VirtualBox.start_vm", return_value=True): 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.status == 200
assert response.route == "/virtualbox/{uuid}/start" assert response.route == "/virtualbox/{uuid}/start"
def test_vbox_stop(server): def test_vbox_stop(server):
with asyncio_patch("gns3server.modules.VirtualBox.stop_vm", return_value=True): 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.status == 200
assert response.route == "/virtualbox/{uuid}/stop" assert response.route == "/virtualbox/{uuid}/stop"