mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Support listing images in subdirectories
It's a part of the OVA support: https://github.com/GNS3/gns3-gui/issues/700
This commit is contained in:
1 parent
dd7f6eb021
commit
034ac392b7
11 files changed
+84
-79
No files matched your search
@@ -332,7 +332,7 @@ def test_vms(server, tmpdir, fake_iou_bin):
|
||||
with patch("gns3server.modules.IOU.get_images_directory", return_value=str(tmpdir)):
|
||||
response = server.get("/iou/vms", example=True)
|
||||
assert response.status == 200
|
||||
assert response.json == [{"filename": "iou.bin"}]
|
||||
assert response.json == [{"filename": "iou.bin", "path": "iou.bin"}]
|
||||
|
||||
|
||||
def test_upload_vm(server, tmpdir):
|
||||
|
||||
@@ -216,7 +216,7 @@ def test_vms(server, tmpdir, fake_qemu_vm):
|
||||
with patch("gns3server.modules.Qemu.get_images_directory", return_value=str(tmpdir), example=True):
|
||||
response = server.get("/qemu/vms")
|
||||
assert response.status == 200
|
||||
assert response.json == [{"filename": "linux.img"}]
|
||||
assert response.json == [{"filename": "linux.img", "path": "linux.img"}]
|
||||
|
||||
|
||||
def test_upload_vm(server, tmpdir):
|
||||
|
||||
@@ -132,8 +132,28 @@ def test_list_images(loop, qemu, tmpdir):
|
||||
|
||||
with patch("gns3server.modules.Qemu.get_images_directory", return_value=str(tmpdir)):
|
||||
assert loop.run_until_complete(qemu.list_images()) == [
|
||||
{"filename": "a.bin"},
|
||||
{"filename": "b.bin"}
|
||||
{"filename": "a.bin", "path": "a.bin"},
|
||||
{"filename": "b.bin", "path": "b.bin"}
|
||||
]
|
||||
|
||||
|
||||
def test_list_images_recursives(loop, qemu, tmpdir):
|
||||
|
||||
fake_images = ["a.bin", "b.bin", ".blu.bin", "a.bin.md5sum"]
|
||||
for image in fake_images:
|
||||
with open(str(tmpdir / image), "w+") as f:
|
||||
f.write("1")
|
||||
os.makedirs(str(tmpdir / "c"))
|
||||
fake_images = ["c.bin", "c.bin.md5sum"]
|
||||
for image in fake_images:
|
||||
with open(str(tmpdir / "c" / image), "w+") as f:
|
||||
f.write("1")
|
||||
|
||||
with patch("gns3server.modules.Qemu.get_images_directory", return_value=str(tmpdir)):
|
||||
assert loop.run_until_complete(qemu.list_images()) == [
|
||||
{"filename": "a.bin", "path": "a.bin"},
|
||||
{"filename": "b.bin", "path": "b.bin"},
|
||||
{"filename": "c.bin", "path": os.path.sep.join(["c", "c.bin"])}
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user