mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-25 00:08:11 +00:00
Fix tests running on Python 3.12
This commit is contained in:
parent
4af5edbc03
commit
34ee75e1f1
@ -208,18 +208,18 @@ async def test_termination_callback_error(vm, tmpdir):
|
|||||||
|
|
||||||
async def test_reload(vm):
|
async def test_reload(vm):
|
||||||
|
|
||||||
with asyncio_patch("gns3server.compute.qemu.QemuVM._control_vm") as mock:
|
with asyncio_patch("gns3server.compute.qemu.QemuVM._control_vm") as m:
|
||||||
await vm.reload()
|
await vm.reload()
|
||||||
assert mock.called_with("system_reset")
|
m.assert_called_with("system_reset")
|
||||||
|
|
||||||
|
|
||||||
async def test_suspend(vm):
|
async def test_suspend(vm, running_subprocess_mock):
|
||||||
|
|
||||||
control_vm_result = MagicMock()
|
vm._process = running_subprocess_mock
|
||||||
control_vm_result.match.group.decode.return_value = "running"
|
with asyncio_patch("gns3server.compute.qemu.QemuVM._get_vm_status", return_value="running"):
|
||||||
with asyncio_patch("gns3server.compute.qemu.QemuVM._control_vm", return_value=control_vm_result) as mock:
|
with asyncio_patch("gns3server.compute.qemu.QemuVM._control_vm") as m:
|
||||||
await vm.suspend()
|
await vm.suspend()
|
||||||
assert mock.called_with("system_reset")
|
m.assert_called_with("stop")
|
||||||
|
|
||||||
|
|
||||||
async def test_add_nio_binding_udp(vm):
|
async def test_add_nio_binding_udp(vm):
|
||||||
@ -490,14 +490,15 @@ def test_json(vm, compute_project):
|
|||||||
assert json["project_id"] == compute_project.id
|
assert json["project_id"] == compute_project.id
|
||||||
|
|
||||||
|
|
||||||
async def test_control_vm(vm):
|
async def test_control_vm(vm, running_subprocess_mock):
|
||||||
|
|
||||||
vm._process = MagicMock()
|
vm._process = running_subprocess_mock
|
||||||
|
vm._monitor = 4242
|
||||||
reader = MagicMock()
|
reader = MagicMock()
|
||||||
writer = MagicMock()
|
writer = MagicMock()
|
||||||
with asyncio_patch("asyncio.open_connection", return_value=(reader, writer)):
|
with asyncio_patch("asyncio.open_connection", return_value=(reader, writer)):
|
||||||
res = await vm._control_vm("test")
|
res = await vm._control_vm("test")
|
||||||
assert writer.write.called_with("test")
|
writer.write.assert_called_with(b"test\n")
|
||||||
assert res is None
|
assert res is None
|
||||||
|
|
||||||
|
|
||||||
@ -514,7 +515,7 @@ async def test_control_vm_expect_text(vm, running_subprocess_mock):
|
|||||||
|
|
||||||
vm._monitor = 4242
|
vm._monitor = 4242
|
||||||
res = await vm._control_vm("test", [b"epic"])
|
res = await vm._control_vm("test", [b"epic"])
|
||||||
assert writer.write.called_with("test")
|
writer.write.assert_called_with(b"test\n")
|
||||||
|
|
||||||
assert res == "epic product"
|
assert res == "epic product"
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ async def test_qemu_list_binaries(compute_api, vm):
|
|||||||
|
|
||||||
with asyncio_patch("gns3server.compute.qemu.Qemu.binary_list", return_value=ret) as mock:
|
with asyncio_patch("gns3server.compute.qemu.Qemu.binary_list", return_value=ret) as mock:
|
||||||
response = await compute_api.get("/qemu/binaries".format(project_id=vm["project_id"]))
|
response = await compute_api.get("/qemu/binaries".format(project_id=vm["project_id"]))
|
||||||
assert mock.called_with(None)
|
mock.assert_called_with(None)
|
||||||
assert response.status == 200
|
assert response.status == 200
|
||||||
assert response.json == ret
|
assert response.json == ret
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ async def test_qemu_list_binaries_filter(compute_api, vm):
|
|||||||
with asyncio_patch("gns3server.compute.qemu.Qemu.binary_list", return_value=ret) as mock:
|
with asyncio_patch("gns3server.compute.qemu.Qemu.binary_list", return_value=ret) as mock:
|
||||||
response = await compute_api.get("/qemu/binaries".format(project_id=vm["project_id"]), body={"archs": ["i386"]})
|
response = await compute_api.get("/qemu/binaries".format(project_id=vm["project_id"]), body={"archs": ["i386"]})
|
||||||
assert response.status == 200
|
assert response.status == 200
|
||||||
assert mock.called_with(["i386"])
|
mock.assert_called_with(["i386"])
|
||||||
assert response.json == ret
|
assert response.json == ret
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user