mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Migration to FastAPI
This commit is contained in:
1 parent
c12b675691
commit
eb3cb8a41f
224 files changed
+11254
-13517
No files matched your search
@@ -25,6 +25,7 @@ from gns3server.compute.vpcs.vpcs_error import VPCSError
|
||||
from gns3server.compute.project_manager import ProjectManager
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_mac_id(compute_project, port_manager):
|
||||
|
||||
# Cleanup the VPCS object
|
||||
@@ -44,6 +45,7 @@ async def test_get_mac_id(compute_project, port_manager):
|
||||
assert vpcs.get_mac_id(vm3_id) == 0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_mac_id_multiple_project(port_manager):
|
||||
|
||||
# Cleanup the VPCS object
|
||||
@@ -63,6 +65,7 @@ async def test_get_mac_id_multiple_project(port_manager):
|
||||
assert vpcs.get_mac_id(vm3_id) == 0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_mac_id_no_id_available(compute_project, port_manager):
|
||||
|
||||
# Cleanup the VPCS object
|
||||
|
||||
@@ -31,7 +31,8 @@ from gns3server.compute.notification_manager import NotificationManager
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def manager(loop, port_manager):
|
||||
@pytest.mark.asyncio
|
||||
async def manager(port_manager):
|
||||
|
||||
m = VPCS.instance()
|
||||
m.port_manager = port_manager
|
||||
@@ -39,7 +40,8 @@ async def manager(loop, port_manager):
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
async def vm(loop, compute_project, manager, tmpdir, ubridge_path):
|
||||
@pytest.mark.asyncio
|
||||
async def vm(compute_project, manager, tmpdir, ubridge_path):
|
||||
|
||||
vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", compute_project, manager)
|
||||
vm._vpcs_version = parse_version("0.9")
|
||||
@@ -49,6 +51,7 @@ async def vm(loop, compute_project, manager, tmpdir, ubridge_path):
|
||||
return vm
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_vm(compute_project, manager):
|
||||
|
||||
vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", compute_project, manager)
|
||||
@@ -56,6 +59,7 @@ async def test_vm(compute_project, manager):
|
||||
assert vm.id == "00010203-0405-0607-0809-0a0b0c0d0e0f"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_vm_check_vpcs_version(vm):
|
||||
|
||||
with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.subprocess_check_output", return_value="Welcome to Virtual PC Simulator, version 0.9"):
|
||||
@@ -63,6 +67,7 @@ async def test_vm_check_vpcs_version(vm):
|
||||
assert vm._vpcs_version == parse_version("0.9")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_vm_check_vpcs_version_0_6_1(vm):
|
||||
|
||||
with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.subprocess_check_output", return_value="Welcome to Virtual PC Simulator, version 0.6.1"):
|
||||
@@ -70,6 +75,7 @@ async def test_vm_check_vpcs_version_0_6_1(vm):
|
||||
assert vm._vpcs_version == parse_version("0.6.1")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_vm_invalid_vpcs_version(vm, manager):
|
||||
|
||||
with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.subprocess_check_output", return_value="Welcome to Virtual PC Simulator, version 0.1"):
|
||||
@@ -81,6 +87,7 @@ async def test_vm_invalid_vpcs_version(vm, manager):
|
||||
assert vm.id == "00010203-0405-0607-0809-0a0b0c0d0e0f"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_vm_invalid_vpcs_path(vm, manager):
|
||||
|
||||
with patch("gns3server.compute.vpcs.vpcs_vm.VPCSVM._vpcs_path", return_value="/tmp/fake/path/vpcs"):
|
||||
@@ -92,6 +99,7 @@ async def test_vm_invalid_vpcs_path(vm, manager):
|
||||
assert vm.id == "00010203-0405-0607-0809-0a0b0c0d0e0e"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_start(vm):
|
||||
|
||||
process = MagicMock()
|
||||
@@ -125,6 +133,7 @@ async def test_start(vm):
|
||||
assert event == vm
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_start_0_6_1(vm):
|
||||
"""
|
||||
Version 0.6.1 doesn't have the -R options. It's not require
|
||||
@@ -157,6 +166,7 @@ async def test_start_0_6_1(vm):
|
||||
assert vm.is_running()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_stop(vm):
|
||||
|
||||
process = MagicMock()
|
||||
@@ -193,6 +203,7 @@ async def test_stop(vm):
|
||||
assert event == vm
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_reload(vm):
|
||||
|
||||
process = MagicMock()
|
||||
@@ -221,6 +232,7 @@ async def test_reload(vm):
|
||||
process.terminate.assert_called_with()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_add_nio_binding_udp(vm):
|
||||
|
||||
nio = VPCS.instance().create_nio({"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1", "filters": {}})
|
||||
@@ -229,6 +241,7 @@ async def test_add_nio_binding_udp(vm):
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
@pytest.mark.asyncio
|
||||
async def test_add_nio_binding_tap(vm, ethernet_device):
|
||||
|
||||
with patch("gns3server.compute.base_manager.BaseManager.has_privileged_access", return_value=True):
|
||||
@@ -237,6 +250,7 @@ async def test_add_nio_binding_tap(vm, ethernet_device):
|
||||
assert nio.tap_device == ethernet_device
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_port_remove_nio_binding(vm):
|
||||
|
||||
nio = VPCS.instance().create_nio({"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
|
||||
@@ -312,6 +326,7 @@ def test_change_name(vm):
|
||||
assert f.read() == "set pcname beta"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_close(vm):
|
||||
|
||||
with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
|
||||
|
||||
Reference in new issue
Block a user