Migration to FastAPI

This commit is contained in:
grossmj committed 2020-10-02 16:07:50 +09:30
1 parent c12b675691
commit eb3cb8a41f
224 files changed
+11254 -13517

No files matched your search

+16 -2
View File
@@ -37,7 +37,8 @@ if not sys.platform.startswith("win"):
@pytest.fixture
async def manager(loop, port_manager):
@pytest.mark.asyncio
async def manager(port_manager):
m = IOU.instance()
m.port_manager = port_manager
@@ -45,7 +46,8 @@ async def manager(loop, port_manager):
@pytest.fixture(scope="function")
async def vm(loop, compute_project, manager, tmpdir, fake_iou_bin, iourc_file):
@pytest.mark.asyncio
async def vm(compute_project, manager, tmpdir, fake_iou_bin, iourc_file):
vm = IOUVM("test", str(uuid.uuid4()), compute_project, manager, application_id=1)
config = manager.config.get_section_config("IOU")
@@ -92,6 +94,7 @@ def test_vm_startup_config_content(compute_project, manager):
assert vm.id == "00010203-0405-0607-0808-0a0b0c0d0e0f"
@pytest.mark.asyncio
async def test_start(vm):
mock_process = MagicMock()
@@ -114,6 +117,7 @@ async def test_start(vm):
vm._ubridge_send.assert_any_call("iol_bridge start IOL-BRIDGE-513")
@pytest.mark.asyncio
async def test_start_with_iourc(vm, tmpdir):
fake_file = str(tmpdir / "iourc")
@@ -136,6 +140,7 @@ async def test_start_with_iourc(vm, tmpdir):
assert kwargs["env"]["IOURC"] == fake_file
@pytest.mark.asyncio
async def test_rename_nvram_file(vm):
"""
It should rename the nvram file to the correct name before launching the VM
@@ -152,6 +157,7 @@ async def test_rename_nvram_file(vm):
assert os.path.exists(os.path.join(vm.working_dir, "vlan.dat-0000{}".format(vm.application_id)))
@pytest.mark.asyncio
async def test_stop(vm):
process = MagicMock()
@@ -176,6 +182,7 @@ async def test_stop(vm):
process.terminate.assert_called_with()
@pytest.mark.asyncio
async def test_reload(vm, fake_iou_bin):
process = MagicMock()
@@ -200,6 +207,7 @@ async def test_reload(vm, fake_iou_bin):
process.terminate.assert_called_with()
@pytest.mark.asyncio
async def test_close(vm, port_manager):
vm._start_ubridge = AsyncioMagicMock(return_value=True)
@@ -252,6 +260,7 @@ def test_create_netmap_config(vm):
assert "513:15/3 1:15/3" in content
@pytest.mark.asyncio
async def test_build_command(vm):
assert await vm._build_command() == [vm.path, str(vm.application_id)]
@@ -316,6 +325,7 @@ def test_change_name(vm):
assert f.read() == "no service password-encryption\nhostname charlie\nno ip icmp rate-limit unreachable"
@pytest.mark.asyncio
async def test_library_check(vm):
with asyncio_patch("gns3server.utils.asyncio.subprocess_check_output", return_value=""):
@@ -326,6 +336,7 @@ async def test_library_check(vm):
await vm._library_check()
@pytest.mark.asyncio
async def test_enable_l1_keepalives(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"):
@@ -341,6 +352,7 @@ async def test_enable_l1_keepalives(vm):
assert command == ["test"]
@pytest.mark.asyncio
async def test_start_capture(vm, tmpdir, manager, free_console_port):
output_file = str(tmpdir / "test.pcap")
@@ -350,6 +362,7 @@ async def test_start_capture(vm, tmpdir, manager, free_console_port):
assert vm._adapters[0].get_nio(0).capturing
@pytest.mark.asyncio
async def test_stop_capture(vm, tmpdir, manager, free_console_port):
output_file = str(tmpdir / "test.pcap")
@@ -366,6 +379,7 @@ def test_get_legacy_vm_workdir():
assert IOU.get_legacy_vm_workdir(42, "bla") == "iou/device-42"
@pytest.mark.asyncio
async def test_invalid_iou_file(vm, iourc_file):
hostname = socket.gethostname()