mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Merge branch 'master' into unstable
This commit is contained in:
commit
00fa1cc370
27 files changed
+307
-116
No files matched your search
@@ -260,24 +260,23 @@ def test_control_vm_expect_text(vm, loop, running_subprocess_mock):
|
||||
def test_build_command(vm, loop, fake_qemu_binary, port_manager):
|
||||
|
||||
os.environ["DISPLAY"] = "0:0"
|
||||
with patch("gns3server.modules.qemu.qemu_vm.QemuVM._get_random_mac", return_value="00:00:ab:7e:b5:00"):
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process:
|
||||
cmd = loop.run_until_complete(asyncio.async(vm._build_command()))
|
||||
assert cmd == [
|
||||
fake_qemu_binary,
|
||||
"-name",
|
||||
"test",
|
||||
"-m",
|
||||
"256",
|
||||
"-hda",
|
||||
os.path.join(vm.working_dir, "flash.qcow2"),
|
||||
"-serial",
|
||||
"telnet:127.0.0.1:{},server,nowait".format(vm.console),
|
||||
"-device",
|
||||
"e1000,mac=00:00:ab:7e:b5:00,netdev=gns3-0",
|
||||
"-netdev",
|
||||
"user,id=gns3-0"
|
||||
]
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process:
|
||||
cmd = loop.run_until_complete(asyncio.async(vm._build_command()))
|
||||
assert cmd == [
|
||||
fake_qemu_binary,
|
||||
"-name",
|
||||
"test",
|
||||
"-m",
|
||||
"256",
|
||||
"-hda",
|
||||
os.path.join(vm.working_dir, "flash.qcow2"),
|
||||
"-serial",
|
||||
"telnet:127.0.0.1:{},server,nowait".format(vm.console),
|
||||
"-device",
|
||||
"e1000,mac=00:00:ab:0e:0f:00,netdev=gns3-0",
|
||||
"-netdev",
|
||||
"user,id=gns3-0"
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
|
||||
@@ -96,10 +96,16 @@ def test_get_abs_image_path(qemu, tmpdir):
|
||||
|
||||
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
||||
assert qemu.get_abs_image_path(path1) == path1
|
||||
assert qemu.get_abs_image_path("test1.bin") == path1
|
||||
assert qemu.get_abs_image_path(path2) == path2
|
||||
assert qemu.get_abs_image_path("test2.bin") == path2
|
||||
assert qemu.get_abs_image_path("../test1.bin") == path1
|
||||
|
||||
# We look at first in new location
|
||||
path2 = str(tmpdir / "QEMU" / "test1.bin")
|
||||
open(path2, 'w+').close()
|
||||
assert qemu.get_abs_image_path("test1.bin") == path2
|
||||
|
||||
|
||||
def test_get_relative_image_path(qemu, tmpdir):
|
||||
os.makedirs(str(tmpdir / "QEMU"))
|
||||
@@ -111,6 +117,7 @@ def test_get_relative_image_path(qemu, tmpdir):
|
||||
|
||||
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
|
||||
assert qemu.get_relative_image_path(path1) == path1
|
||||
assert qemu.get_relative_image_path("test1.bin") == path1
|
||||
assert qemu.get_relative_image_path(path2) == "test2.bin"
|
||||
assert qemu.get_relative_image_path("test2.bin") == "test2.bin"
|
||||
assert qemu.get_relative_image_path("../test1.bin") == path1
|
||||
|
||||
@@ -45,3 +45,13 @@ def test_release_udp_port():
|
||||
pm.reserve_udp_port(4242, project)
|
||||
pm.release_udp_port(4242, project)
|
||||
pm.reserve_udp_port(4242, project)
|
||||
|
||||
|
||||
def test_find_unused_port():
|
||||
p = PortManager().find_unused_port(1000, 10000)
|
||||
assert p is not None
|
||||
|
||||
|
||||
def test_find_unused_port_invalid_range():
|
||||
with pytest.raises(aiohttp.web.HTTPConflict):
|
||||
p = PortManager().find_unused_port(10000, 1000)
|
||||
@@ -69,15 +69,14 @@ def test_changing_path_temporary_flag(tmpdir):
|
||||
with patch("gns3server.modules.project.Project.is_local", return_value=True):
|
||||
p = Project(temporary=True)
|
||||
assert os.path.exists(p.path)
|
||||
original_path = p.path
|
||||
assert os.path.exists(os.path.join(p.path, ".gns3_temporary"))
|
||||
p.temporary = False
|
||||
assert not os.path.exists(os.path.join(p.path, ".gns3_temporary"))
|
||||
|
||||
with open(str(tmpdir / ".gns3_temporary"), "w+") as f:
|
||||
f.write("1")
|
||||
|
||||
p.path = str(tmpdir)
|
||||
p.temporary = False
|
||||
assert not os.path.exists(os.path.join(p.path, ".gns3_temporary"))
|
||||
assert not os.path.exists(os.path.join(str(tmpdir), ".gns3_temporary"))
|
||||
assert not os.path.exists(original_path)
|
||||
|
||||
|
||||
def test_temporary_path():
|
||||
|
||||
Reference in new issue
Block a user