mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Update and delete VM on controller
This commit is contained in:
5 files changed
+156
-11
No files matched your search
@@ -86,6 +86,24 @@ def test_create(vm, compute, project, async_run):
|
||||
assert vm._properties == {"startup_script": "echo test"}
|
||||
|
||||
|
||||
def test_update(vm, compute, project, async_run):
|
||||
response = MagicMock()
|
||||
response.json = {"console": 2048}
|
||||
compute.put = AsyncioMagicMock(return_value=response)
|
||||
|
||||
async_run(vm.update(console=2048, console_type="vnc", properties={"startup_script" :"echo test"}, name="demo"))
|
||||
data = {
|
||||
"console": 2048,
|
||||
"console_type": "vnc",
|
||||
"vm_id": vm.id,
|
||||
"startup_script": "echo test",
|
||||
"name": "demo"
|
||||
}
|
||||
compute.put.assert_called_with("/projects/{}/vpcs/vms".format(vm.project.id), data=data)
|
||||
assert vm._console == 2048
|
||||
assert vm._properties == {"startup_script": "echo test"}
|
||||
|
||||
|
||||
def test_start(vm, compute, project, async_run):
|
||||
|
||||
compute.post = AsyncioMagicMock()
|
||||
@@ -139,6 +157,11 @@ def test_create_without_console(vm, compute, project, async_run):
|
||||
assert vm._properties == {"test_value": "success", "startup_script": "echo test"}
|
||||
|
||||
|
||||
def test_delete(vm, compute, async_run):
|
||||
async_run(vm.destroy())
|
||||
compute.delete.assert_called_with("/projects/{}/vpcs/vms/{}".format(vm.project.id, vm.id))
|
||||
|
||||
|
||||
def test_post(vm, compute, async_run):
|
||||
async_run(vm.post("/test", {"a": "b"}))
|
||||
compute.post.assert_called_with("/projects/{}/vpcs/vms/{}/test".format(vm.project.id, vm.id), data={"a": "b"})
|
||||
|
||||
@@ -72,6 +72,24 @@ def test_create_vm(http_controller, tmpdir, project, compute):
|
||||
assert "name" not in response.json["properties"]
|
||||
|
||||
|
||||
def test_update_vm(http_controller, tmpdir, project, compute, vm):
|
||||
response = MagicMock()
|
||||
response.json = {"console": 2048}
|
||||
compute.put = AsyncioMagicMock(return_value=response)
|
||||
|
||||
response = http_controller.put("/projects/{}/vms/{}".format(project.id, vm.id), {
|
||||
"name": "test",
|
||||
"vm_type": "vpcs",
|
||||
"compute_id": "example.com",
|
||||
"properties": {
|
||||
"startup_script": "echo test"
|
||||
}
|
||||
}, example=True)
|
||||
assert response.status == 201
|
||||
assert response.json["name"] == "test"
|
||||
assert "name" not in response.json["properties"]
|
||||
|
||||
|
||||
def test_start_vm(http_controller, tmpdir, project, compute, vm):
|
||||
response = MagicMock()
|
||||
compute.post = AsyncioMagicMock()
|
||||
@@ -106,3 +124,11 @@ def test_reload_vm(http_controller, tmpdir, project, compute, vm):
|
||||
response = http_controller.post("/projects/{}/vms/{}/reload".format(project.id, vm.id), example=True)
|
||||
assert response.status == 201
|
||||
assert response.json["name"] == vm.name
|
||||
|
||||
|
||||
def test_delete_vm(http_controller, tmpdir, project, compute, vm):
|
||||
response = MagicMock()
|
||||
compute.post = AsyncioMagicMock()
|
||||
|
||||
response = http_controller.delete("/projects/{}/vms/{}".format(project.id, vm.id), example=True)
|
||||
assert response.status == 201
|
||||
Reference in new issue
Block a user