mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
All current iou code is async
This commit is contained in:
1 parent
d323234520
commit
15f89776d3
8 files changed
+97
-30
No files matched your search
@@ -184,18 +184,18 @@ def test_create_netmap_config(vm):
|
||||
assert "513:15/3 1:15/3" in content
|
||||
|
||||
|
||||
def test_build_command(vm):
|
||||
def test_build_command(vm, loop):
|
||||
|
||||
assert vm._build_command() == [vm.path, "-L", str(vm.application_id)]
|
||||
assert loop.run_until_complete(asyncio.async(vm._build_command())) == [vm.path, "-L", str(vm.application_id)]
|
||||
|
||||
|
||||
def test_build_command_initial_config(vm):
|
||||
def test_build_command_initial_config(vm, loop):
|
||||
|
||||
filepath = os.path.join(vm.working_dir, "initial-config.cfg")
|
||||
with open(filepath, "w+") as f:
|
||||
f.write("service timestamps debug datetime msec\nservice timestamps log datetime msec\nno service password-encryption")
|
||||
|
||||
assert vm._build_command() == [vm.path, "-L", "-c", vm.initial_config_file, str(vm.application_id)]
|
||||
assert loop.run_until_complete(asyncio.async(vm._build_command())) == [vm.path, "-L", "-c", vm.initial_config_file, str(vm.application_id)]
|
||||
|
||||
|
||||
def test_get_initial_config(vm):
|
||||
@@ -231,3 +231,30 @@ def test_change_name(vm, tmpdir):
|
||||
assert vm.name == "hello"
|
||||
with open(path) as f:
|
||||
assert f.read() == "hostname hello"
|
||||
|
||||
|
||||
def test_library_check(loop, vm):
|
||||
|
||||
with asyncio_patch("gns3server.utils.asyncio.subprocess_check_output", return_value="") as mock:
|
||||
|
||||
loop.run_until_complete(asyncio.async(vm._library_check()))
|
||||
|
||||
with asyncio_patch("gns3server.utils.asyncio.subprocess_check_output", return_value="libssl => not found") as mock:
|
||||
with pytest.raises(IOUError):
|
||||
loop.run_until_complete(asyncio.async(vm._library_check()))
|
||||
|
||||
|
||||
def test_enable_l1_keepalives(loop, vm):
|
||||
|
||||
with asyncio_patch("gns3server.utils.asyncio.subprocess_check_output", return_value="***************************************************************\n\n-l Enable Layer 1 keepalive messages\n-u <n> UDP port base for distributed networks\n") as mock:
|
||||
|
||||
command = ["test"]
|
||||
loop.run_until_complete(asyncio.async(vm._enable_l1_keepalives(command)))
|
||||
assert command == ["test", "-l"]
|
||||
|
||||
with asyncio_patch("gns3server.utils.asyncio.subprocess_check_output", return_value="***************************************************************\n\n-u <n> UDP port base for distributed networks\n") as mock:
|
||||
|
||||
command = ["test"]
|
||||
with pytest.raises(IOUError):
|
||||
loop.run_until_complete(asyncio.async(vm._enable_l1_keepalives(command)))
|
||||
assert command == ["test"]
|
||||
@@ -47,7 +47,7 @@ def test_vm(project, manager):
|
||||
|
||||
|
||||
def test_vm_invalid_vpcs_version(loop, project, manager):
|
||||
with asyncio_patch("gns3server.modules.vpcs.vpcs_vm.VPCSVM._get_vpcs_welcome", return_value="Welcome to Virtual PC Simulator, version 0.1"):
|
||||
with asyncio_patch("gns3server.utils.asyncio.subprocess_check_output", return_value="Welcome to Virtual PC Simulator, version 0.1"):
|
||||
with pytest.raises(VPCSError):
|
||||
vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager)
|
||||
nio = manager.create_nio(vm.vpcs_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
|
||||
|
||||
Reference in new issue
Block a user