mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
refactor: ruff autofixes
This commit is contained in:
455 files changed
+12322
-14762
No files matched your search
@@ -21,6 +21,7 @@ from gns3server.controller.gns3vm.remote_gns3_vm import RemoteGNS3VM
|
||||
from gns3server.controller.gns3vm.gns3_vm_error import GNS3VMError
|
||||
from pydantic import SecretStr
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def gns3vm(controller):
|
||||
|
||||
@@ -38,14 +39,16 @@ async def test_list(gns3vm, controller):
|
||||
@pytest.mark.asyncio
|
||||
async def test_start(gns3vm, controller):
|
||||
|
||||
await controller.add_compute("r1",
|
||||
name="R1",
|
||||
protocol="https",
|
||||
host="r1.local",
|
||||
port=8484,
|
||||
user="hello",
|
||||
password=SecretStr("world"),
|
||||
connect=False)
|
||||
await controller.add_compute(
|
||||
"r1",
|
||||
name="R1",
|
||||
protocol="https",
|
||||
host="r1.local",
|
||||
port=8484,
|
||||
user="hello",
|
||||
password=SecretStr("world"),
|
||||
connect=False,
|
||||
)
|
||||
|
||||
gns3vm.vmname = "R1"
|
||||
await gns3vm.start()
|
||||
@@ -60,14 +63,16 @@ async def test_start(gns3vm, controller):
|
||||
@pytest.mark.asyncio
|
||||
async def test_start_invalid_vm(gns3vm, controller):
|
||||
|
||||
await controller.add_compute("r1",
|
||||
connect=False,
|
||||
name="R1",
|
||||
protocol="https",
|
||||
host="r1.local",
|
||||
port=8484,
|
||||
user="hello",
|
||||
password=SecretStr("world"))
|
||||
await controller.add_compute(
|
||||
"r1",
|
||||
connect=False,
|
||||
name="R1",
|
||||
protocol="https",
|
||||
host="r1.local",
|
||||
port=8484,
|
||||
user="hello",
|
||||
password=SecretStr("world"),
|
||||
)
|
||||
|
||||
gns3vm.vmname = "R2"
|
||||
with pytest.raises(GNS3VMError):
|
||||
|
||||
@@ -55,9 +55,11 @@ vcpfps=25
|
||||
GuestMemoryBalloon=0
|
||||
"""
|
||||
|
||||
with asyncio_patch("gns3server.controller.gns3vm.virtualbox_gns3_vm.VirtualBoxGNS3VM._execute", return_value=showvminfo) as mock:
|
||||
with asyncio_patch(
|
||||
"gns3server.controller.gns3vm.virtualbox_gns3_vm.VirtualBoxGNS3VM._execute", return_value=showvminfo
|
||||
) as mock:
|
||||
res = await gns3vm._look_for_interface("nat")
|
||||
mock.assert_called_with('showvminfo', ['GNS3 VM', '--machinereadable'])
|
||||
mock.assert_called_with("showvminfo", ["GNS3 VM", "--machinereadable"])
|
||||
assert res == 2
|
||||
|
||||
# with asyncio_patch("gns3server.controller.gns3vm.virtualbox_gns3_vm.VirtualBoxGNS3VM._execute") as mock:
|
||||
@@ -71,6 +73,7 @@ GuestMemoryBalloon=0
|
||||
async def test_cpu_vendor_id(gns3vm):
|
||||
|
||||
from cpuinfo import get_cpu_info
|
||||
|
||||
cpu_info = await wait_run_in_executor(get_cpu_info)
|
||||
vendor_id = cpu_info.get('vendor_id_raw')
|
||||
vendor_id = cpu_info.get("vendor_id_raw")
|
||||
assert vendor_id # vendor id should not be empty
|
||||
@@ -41,20 +41,19 @@ async def test_set_extra_options(gns3vm, vmx_path, windows_platform):
|
||||
gns3vm._vmx_path = vmx_path
|
||||
|
||||
# when there is not an entry, we modify it
|
||||
with open(vmx_path, 'w') as f:
|
||||
with open(vmx_path, "w") as f:
|
||||
f.write("")
|
||||
|
||||
await gns3vm._set_extra_options()
|
||||
|
||||
with open(vmx_path, 'r') as f:
|
||||
with open(vmx_path, "r") as f:
|
||||
assert f.read() == 'vhv.enable = "TRUE"\n'
|
||||
|
||||
# when there is an entry, we don't modify it
|
||||
with open(vmx_path, 'w') as f:
|
||||
with open(vmx_path, "w") as f:
|
||||
f.write('vhv.enable = "FALSE"\n')
|
||||
|
||||
await gns3vm._set_extra_options()
|
||||
|
||||
with open(vmx_path, 'r') as f:
|
||||
with open(vmx_path, "r") as f:
|
||||
assert f.read() == 'vhv.enable = "FALSE"\n'
|
||||
|
||||
Reference in new issue
Block a user