1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-01 04:38:12 +00:00

Fixes tests.

This commit is contained in:
grossmj 2015-03-11 23:09:01 -06:00
parent 38fa3e9a86
commit 4f7b896a6a
4 changed files with 24 additions and 6 deletions

View File

@ -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, 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, id=self._id,
disk_image=hdd_disk_image)) disk_image=hdd_disk_image))
self._hdd_disk_image = hdd_disk_image
@property @property
def adapters(self): def adapters(self):

View File

@ -83,7 +83,8 @@ def test_vm_invalid_iouyap_path(project, manager, loop):
def test_start(loop, vm, monkeypatch): 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_ioucon", return_value=True):
with asyncio_patch("gns3server.modules.iou.iou_vm.IOUVM._start_iouyap", 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()): with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()):

View File

@ -202,7 +202,7 @@ def test_disk_options(vm, loop, fake_qemu_img_binary):
loop.run_until_complete(asyncio.async(vm._disk_options())) loop.run_until_complete(asyncio.async(vm._disk_options()))
assert process.called assert process.called
args, kwargs = process.call_args 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): 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", "-serial",
"telnet:127.0.0.1:{},server,nowait".format(vm.console), "telnet:127.0.0.1:{},server,nowait".format(vm.console),
"-monitor", "-monitor",
"telnet:127.0.0.1:{},server,nowait".format(vm.monitor), "tcp:127.0.0.1:{},server,nowait".format(vm.monitor),
"-device", "-device",
"e1000,mac=00:00:ab:7e:b5:00,netdev=gns3-0", "e1000,mac=00:00:ab:7e:b5:00,netdev=gns3-0",
"-netdev", "-netdev",
@ -292,7 +292,7 @@ def test_hda_disk_image(vm, tmpdir):
vm.hda_disk_image = "/tmp/test" vm.hda_disk_image = "/tmp/test"
assert vm.hda_disk_image == "/tmp/test" assert vm.hda_disk_image == "/tmp/test"
vm.hda_disk_image = "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): def test_hdb_disk_image(vm, tmpdir):
@ -301,4 +301,20 @@ def test_hdb_disk_image(vm, tmpdir):
vm.hdb_disk_image = "/tmp/test" vm.hdb_disk_image = "/tmp/test"
assert vm.hdb_disk_image == "/tmp/test" assert vm.hdb_disk_image == "/tmp/test"
vm.hdb_disk_image = "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")

View File

@ -102,7 +102,7 @@ def test_changing_location_not_allowed(tmpdir):
def test_changing_path_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): with pytest.raises(aiohttp.web.HTTPForbidden):
p = Project() p = Project()
p.path = str(tmpdir) p.path = str(tmpdir)