mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Merge pull request #2055 from GNS3/remove-qemu-binaries-requirement
Remove Qemu binary requirement
This commit is contained in:
6 files changed
+27
-95
No files matched your search
@@ -351,34 +351,6 @@ async def test_qemu_delete_nio(app: FastAPI, compute_client: AsyncClient, qemu_v
|
||||
assert response.status_code == status.HTTP_204_NO_CONTENT
|
||||
|
||||
|
||||
async def test_qemu_list_binaries(app: FastAPI, compute_client: AsyncClient) -> None:
|
||||
|
||||
ret = [{"path": "/tmp/1", "version": "2.2.0"},
|
||||
{"path": "/tmp/2", "version": "2.1.0"}]
|
||||
|
||||
with asyncio_patch("gns3server.compute.qemu.Qemu.binary_list", return_value=ret) as mock:
|
||||
response = await compute_client.get(app.url_path_for("compute:get_qemu_binaries"))
|
||||
assert mock.called_with(None)
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.json() == ret
|
||||
|
||||
|
||||
# async def test_qemu_list_binaries_filter(app: FastAPI, compute_client: AsyncClient, vm: dict) -> None:
|
||||
#
|
||||
# ret = [
|
||||
# {"path": "/tmp/x86_64", "version": "2.2.0"},
|
||||
# {"path": "/tmp/alpha", "version": "2.1.0"},
|
||||
# {"path": "/tmp/i386", "version": "2.1.0"}
|
||||
# ]
|
||||
#
|
||||
# with asyncio_patch("gns3server.compute.qemu.Qemu.binary_list", return_value=ret) as mock:
|
||||
# response = await compute_client.get(app.url_path_for("compute:get_qemu_binaries"),
|
||||
# json={"archs": ["i386"]})
|
||||
# assert response.status_code == status.HTTP_200_OK
|
||||
# assert mock.called_with(["i386"])
|
||||
# assert response.json() == ret
|
||||
|
||||
|
||||
async def test_images(app: FastAPI, compute_client: AsyncClient, fake_qemu_vm) -> None:
|
||||
|
||||
response = await compute_client.get(app.url_path_for("compute:get_qemu_images"))
|
||||
|
||||
@@ -82,29 +82,29 @@ async def test_binary_list(monkeypatch, tmpdir):
|
||||
assert {"path": os.path.join(os.environ["PATH"], "hello"), "version": version} not in qemus
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_img_binary_list(monkeypatch, tmpdir):
|
||||
|
||||
monkeypatch.setenv("PATH", str(tmpdir))
|
||||
files_to_create = ["qemu-img", "qemu-io", "qemu-system-x86", "qemu-system-x42", "qemu-kvm", "hello"]
|
||||
|
||||
for file_to_create in files_to_create:
|
||||
path = os.path.join(os.environ["PATH"], file_to_create)
|
||||
with open(path, "w+") as f:
|
||||
f.write("1")
|
||||
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
|
||||
with asyncio_patch("gns3server.compute.qemu.subprocess_check_output", return_value="qemu-img version 2.2.0, Copyright (c) 2004-2008 Fabrice Bellard") as mock:
|
||||
qemus = await Qemu.img_binary_list()
|
||||
|
||||
version = "2.2.0"
|
||||
|
||||
assert {"path": os.path.join(os.environ["PATH"], "qemu-img"), "version": version} in qemus
|
||||
assert {"path": os.path.join(os.environ["PATH"], "qemu-io"), "version": version} not in qemus
|
||||
assert {"path": os.path.join(os.environ["PATH"], "qemu-system-x86"), "version": version} not in qemus
|
||||
assert {"path": os.path.join(os.environ["PATH"], "qemu-kvm"), "version": version} not in qemus
|
||||
assert {"path": os.path.join(os.environ["PATH"], "qemu-system-x42"), "version": version} not in qemus
|
||||
assert {"path": os.path.join(os.environ["PATH"], "hello"), "version": version} not in qemus
|
||||
# @pytest.mark.asyncio
|
||||
# async def test_img_binary_list(monkeypatch, tmpdir):
|
||||
#
|
||||
# monkeypatch.setenv("PATH", str(tmpdir))
|
||||
# files_to_create = ["qemu-img", "qemu-io", "qemu-system-x86", "qemu-system-x42", "qemu-kvm", "hello"]
|
||||
#
|
||||
# for file_to_create in files_to_create:
|
||||
# path = os.path.join(os.environ["PATH"], file_to_create)
|
||||
# with open(path, "w+") as f:
|
||||
# f.write("1")
|
||||
# os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
#
|
||||
# with asyncio_patch("gns3server.compute.qemu.subprocess_check_output", return_value="qemu-img version 2.2.0, Copyright (c) 2004-2008 Fabrice Bellard") as mock:
|
||||
# qemus = await Qemu.img_binary_list()
|
||||
#
|
||||
# version = "2.2.0"
|
||||
#
|
||||
# assert {"path": os.path.join(os.environ["PATH"], "qemu-img"), "version": version} in qemus
|
||||
# assert {"path": os.path.join(os.environ["PATH"], "qemu-io"), "version": version} not in qemus
|
||||
# assert {"path": os.path.join(os.environ["PATH"], "qemu-system-x86"), "version": version} not in qemus
|
||||
# assert {"path": os.path.join(os.environ["PATH"], "qemu-kvm"), "version": version} not in qemus
|
||||
# assert {"path": os.path.join(os.environ["PATH"], "qemu-system-x42"), "version": version} not in qemus
|
||||
# assert {"path": os.path.join(os.environ["PATH"], "hello"), "version": version} not in qemus
|
||||
|
||||
|
||||
def test_get_legacy_vm_workdir():
|
||||
|
||||
Reference in new issue
Block a user