From 997e0ad6ee821a1690bd445ef6068e9f775e4610 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 10 Jan 2023 11:22:12 +0800 Subject: [PATCH] Fix more tests --- tests/compute/qemu/test_qemu_vm.py | 7 +++++-- tests/handlers/api/compute/test_nat.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/compute/qemu/test_qemu_vm.py b/tests/compute/qemu/test_qemu_vm.py index 55e9e954..5465d720 100644 --- a/tests/compute/qemu/test_qemu_vm.py +++ b/tests/compute/qemu/test_qemu_vm.py @@ -60,7 +60,7 @@ def fake_qemu_binary(monkeypatch, tmpdir): monkeypatch.setenv("PATH", str(tmpdir)) if sys.platform.startswith("win"): - bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64w.EXE") + bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64w.exe") else: bin_path = os.path.join(os.environ["PATH"], "qemu-system-x86_64") with open(bin_path, "w+") as f: @@ -859,7 +859,10 @@ def test_get_qemu_img(vm, tmpdir): open(str(tmpdir / "qemu-system-x86_64"), "w+").close() open(str(tmpdir / "qemu-img"), "w+").close() vm._qemu_path = str(tmpdir / "qemu-system-x86_64") - assert vm._get_qemu_img() == str(tmpdir / "qemu-img") + if sys.platform.startswith("win"): + assert vm._get_qemu_img() == str(tmpdir / "qemu-img.EXE") + else: + assert vm._get_qemu_img() == str(tmpdir / "qemu-img") # def test_get_qemu_img_not_exist(vm, tmpdir): diff --git a/tests/handlers/api/compute/test_nat.py b/tests/handlers/api/compute/test_nat.py index 425ed271..87bf4e75 100644 --- a/tests/handlers/api/compute/test_nat.py +++ b/tests/handlers/api/compute/test_nat.py @@ -74,9 +74,9 @@ async def test_nat_nio_update_udp(compute_api, vm): "rhost": "127.0.0.1" } - await compute_api.post("/projects/{project_id}/nat/nodes/{node_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), params) + await compute_api.post("/projects/{project_id}/nat/nodes/{node_id}/adapters/0/ports/1/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), params) params["filters"] = {} - response = await compute_api.put("/projects/{project_id}/nat/nodes/{node_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), params) + response = await compute_api.put("/projects/{project_id}/nat/nodes/{node_id}/adapters/0/ports/1/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), params) assert response.status == 201, response.body.decode() assert response.route == r"/projects/{project_id}/nat/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.json["type"] == "nio_udp"