Rewrote image search

This code is more generic and support all cases. Previously
we had bug where the user lost his image path if the image
was not located in image directory.
This commit is contained in:
Julien Duponchelle committed 2015-04-14 18:46:55 +02:00
1 parent e51a129216
commit aa2472fb30
9 files changed
+124 -70

No files matched your search

+16
View File
@@ -17,7 +17,9 @@
import pytest
from unittest.mock import patch
import uuid
import os
from gns3server.modules.iou import IOU
@@ -25,6 +27,15 @@ from gns3server.modules.iou.iou_error import IOUError
from gns3server.modules.project_manager import ProjectManager
@pytest.fixture(scope="function")
def iou(port_manager):
# Cleanup the IOU object
IOU._instance = None
iou = IOU.instance()
iou.port_manager = port_manager
return iou
def test_get_application_id(loop, project, port_manager):
# Cleanup the IOU object
IOU._instance = None
@@ -71,3 +82,8 @@ def test_get_application_id_no_id_available(loop, project, port_manager):
vm_id = str(uuid.uuid4())
loop.run_until_complete(iou.create_vm("PC {}".format(i), project.id, vm_id))
assert iou.get_application_id(vm_id) == i
def test_get_images_directory(iou, tmpdir):
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
assert iou.get_images_directory() == str(tmpdir / "IOU")