mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-30 20:28:08 +00:00
Fixes tests.
This commit is contained in:
parent
38fa3e9a86
commit
4f7b896a6a
@ -272,6 +272,7 @@ class QemuVM(BaseVM):
|
||||
log.info("QEMU VM {name} [id={id}] has set the QEMU hdd disk image path to {disk_image}".format(name=self._name,
|
||||
id=self._id,
|
||||
disk_image=hdd_disk_image))
|
||||
self._hdd_disk_image = hdd_disk_image
|
||||
|
||||
@property
|
||||
def adapters(self):
|
||||
|
@ -83,7 +83,8 @@ def test_vm_invalid_iouyap_path(project, manager, loop):
|
||||
|
||||
|
||||
def test_start(loop, vm, monkeypatch):
|
||||
with asyncio_patch("gns3server.modules.iou.iou_vm.IOUVM._check_requirements", return_value=True):
|
||||
|
||||
with patch("gns3server.modules.iou.iou_vm.IOUVM._check_requirements", return_value=True):
|
||||
with asyncio_patch("gns3server.modules.iou.iou_vm.IOUVM._start_ioucon", return_value=True):
|
||||
with asyncio_patch("gns3server.modules.iou.iou_vm.IOUVM._start_iouyap", return_value=True):
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()):
|
||||
|
@ -202,7 +202,7 @@ def test_disk_options(vm, loop, fake_qemu_img_binary):
|
||||
loop.run_until_complete(asyncio.async(vm._disk_options()))
|
||||
assert process.called
|
||||
args, kwargs = process.call_args
|
||||
assert args == (fake_qemu_img_binary, "create", "-f", "qcow2", os.path.join(vm.working_dir, "flash.qcow2"), "128M")
|
||||
assert args == (fake_qemu_img_binary, "create", "-f", "qcow2", os.path.join(vm.working_dir, "flash.qcow2"), "256M")
|
||||
|
||||
|
||||
def test_set_process_priority(vm, loop, fake_qemu_img_binary):
|
||||
@ -270,7 +270,7 @@ def test_build_command(vm, loop, fake_qemu_binary, port_manager):
|
||||
"-serial",
|
||||
"telnet:127.0.0.1:{},server,nowait".format(vm.console),
|
||||
"-monitor",
|
||||
"telnet:127.0.0.1:{},server,nowait".format(vm.monitor),
|
||||
"tcp:127.0.0.1:{},server,nowait".format(vm.monitor),
|
||||
"-device",
|
||||
"e1000,mac=00:00:ab:7e:b5:00,netdev=gns3-0",
|
||||
"-netdev",
|
||||
@ -292,7 +292,7 @@ def test_hda_disk_image(vm, tmpdir):
|
||||
vm.hda_disk_image = "/tmp/test"
|
||||
assert vm.hda_disk_image == "/tmp/test"
|
||||
vm.hda_disk_image = "test"
|
||||
assert vm.hda_disk_image == str(tmpdir / "test")
|
||||
assert vm.hda_disk_image == str(tmpdir / "QEMU" / "test")
|
||||
|
||||
|
||||
def test_hdb_disk_image(vm, tmpdir):
|
||||
@ -301,4 +301,20 @@ def test_hdb_disk_image(vm, tmpdir):
|
||||
vm.hdb_disk_image = "/tmp/test"
|
||||
assert vm.hdb_disk_image == "/tmp/test"
|
||||
vm.hdb_disk_image = "test"
|
||||
assert vm.hdb_disk_image == str(tmpdir / "test")
|
||||
assert vm.hdb_disk_image == str(tmpdir / "QEMU" / "test")
|
||||
|
||||
def test_hdc_disk_image(vm, tmpdir):
|
||||
|
||||
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
||||
vm.hdc_disk_image = "/tmp/test"
|
||||
assert vm.hdc_disk_image == "/tmp/test"
|
||||
vm.hdc_disk_image = "test"
|
||||
assert vm.hdc_disk_image == str(tmpdir / "QEMU" / "test")
|
||||
|
||||
def test_hdd_disk_image(vm, tmpdir):
|
||||
|
||||
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
||||
vm.hdd_disk_image = "/tmp/test"
|
||||
assert vm.hdd_disk_image == "/tmp/test"
|
||||
vm.hdd_disk_image = "test"
|
||||
assert vm.hdd_disk_image == str(tmpdir / "QEMU" / "test")
|
||||
|
@ -102,7 +102,7 @@ def test_changing_location_not_allowed(tmpdir):
|
||||
|
||||
|
||||
def test_changing_path_not_allowed(tmpdir):
|
||||
with patch("gns3server.config.Config.get_section_config", return_value={"local": False}):
|
||||
with patch("gns3server.config.Config.getboolean", return_value=False):
|
||||
with pytest.raises(aiohttp.web.HTTPForbidden):
|
||||
p = Project()
|
||||
p.path = str(tmpdir)
|
||||
|
Loading…
Reference in New Issue
Block a user