fix(images): reconcile the image inventory with filesystem changes

This commit is contained in:
Cristi committed 2026-09-28 16:01:36 +03:00
1 parent efd6bb77fe
commit 046dff4d08
22 files changed
+1809 -335

No files matched your search

+7 -4
View File
@@ -111,14 +111,17 @@ class TestImageRoutes:
async def test_create_image(self, app: FastAPI, client: AsyncClient, images_dir) -> None:
Qemu.instance().create_disk_image = AsyncioMagicMock()
async def create_disk(path, options):
with open(path, "wb") as f:
f.write(b'QFI\xfb\x00\x00\x00')
Qemu.instance().create_disk_image = AsyncioMagicMock(side_effect=create_disk)
path = os.path.join(os.path.join(images_dir, "QEMU", "new_image.qcow2"))
with open(path, "wb+") as f:
f.write(b'QFI\xfb\x00\x00\x00')
image_name = os.path.basename(path)
response = await client.post(
app.url_path_for("create_qemu_image", image_path=image_name), json={"format": "qcow2", "size": 30})
assert response.status_code == status.HTTP_201_CREATED
assert os.path.isfile(path)
@pytest.mark.parametrize(
"image_type, fixture_name, valid_request",
@@ -473,4 +476,4 @@ class TestImageRoutes:
templates = await templates_repo.get_templates()
assert len(templates) == 1
assert templates[0].name == "Empty VM"
await templates_repo.delete_template(templates[0].template_id)
await templates_repo.delete_template(templates[0].template_id)