diff --git a/tests/compute/builtin/nodes/test_cloud.py b/tests/compute/builtin/nodes/test_cloud.py index a25e390df..bebec5fc5 100644 --- a/tests/compute/builtin/nodes/test_cloud.py +++ b/tests/compute/builtin/nodes/test_cloud.py @@ -16,15 +16,15 @@ # along with this program. If not, see . import uuid +from unittest.mock import MagicMock, call, patch + import pytest import pytest_asyncio -from unittest.mock import MagicMock, patch, call from gns3server.compute.builtin.nodes.cloud import Cloud from gns3server.compute.nios.nio_udp import NIOUDP from tests.utils import asyncio_patch - pytestmark = pytest.mark.asyncio diff --git a/tests/compute/docker/test_docker.py b/tests/compute/docker/test_docker.py index 14d347ba9..74c7f365b 100644 --- a/tests/compute/docker/test_docker.py +++ b/tests/compute/docker/test_docker.py @@ -16,13 +16,14 @@ # along with this program. If not, see . import asyncio -import pytest -import pytest_asyncio from unittest.mock import MagicMock, patch -from tests.utils import asyncio_patch, AsyncioMagicMock -from gns3server.compute.docker import Docker, DOCKER_PREFERRED_API_VERSION, DOCKER_MINIMUM_API_VERSION +import pytest +import pytest_asyncio + +from gns3server.compute.docker import DOCKER_MINIMUM_API_VERSION, DOCKER_PREFERRED_API_VERSION, Docker from gns3server.compute.docker.docker_error import DockerError, DockerHttp404Error +from tests.utils import AsyncioMagicMock, asyncio_patch @pytest_asyncio.fixture diff --git a/tests/compute/docker/test_docker_vm.py b/tests/compute/docker/test_docker_vm.py index ecb64dd0b..2c15d8927 100644 --- a/tests/compute/docker/test_docker_vm.py +++ b/tests/compute/docker/test_docker_vm.py @@ -14,27 +14,24 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import aiohttp import asyncio -import pytest -import pytest_asyncio -import uuid import os import shutil - +import uuid from types import SimpleNamespace -from unittest.mock import patch -from tests.utils import asyncio_patch, AsyncioMagicMock +from unittest.mock import AsyncMock, MagicMock, call, patch + +import aiohttp +import pytest +import pytest_asyncio -from gns3server.compute.ubridge.ubridge_error import UbridgeNamespaceError from gns3server.compute.compute_error import ComputeError -from gns3server.compute.docker.docker_vm import DockerVM -from gns3server.compute.docker.docker_error import DockerError, DockerHttp404Error -from gns3server.compute.error import ImageMissingError from gns3server.compute.docker import Docker - - -from unittest.mock import AsyncMock, patch, MagicMock, call +from gns3server.compute.docker.docker_error import DockerError, DockerHttp404Error +from gns3server.compute.docker.docker_vm import DockerVM +from gns3server.compute.error import ImageMissingError +from gns3server.compute.ubridge.ubridge_error import UbridgeNamespaceError +from tests.utils import AsyncioMagicMock, asyncio_patch @pytest_asyncio.fixture @@ -2246,6 +2243,7 @@ def test_extra_config_schema_rejects_bad_targets(): """ from pydantic import ValidationError + from gns3server.schemas.common import ExtraConfig for bad in ("relative/path", "/has/../dots", "/", "/etc/", "no-leading-slash"): diff --git a/tests/compute/docker/test_iol_docker_vm.py b/tests/compute/docker/test_iol_docker_vm.py index 66861c8c5..23fcb0e36 100644 --- a/tests/compute/docker/test_iol_docker_vm.py +++ b/tests/compute/docker/test_iol_docker_vm.py @@ -27,22 +27,19 @@ import glob import json import os import uuid +from unittest.mock import MagicMock, call, patch import pytest import pytest_asyncio -from unittest.mock import patch, MagicMock, call - -from tests.utils import asyncio_patch, AsyncioMagicMock - from gns3server.compute.docker import Docker -from gns3server.compute.docker.docker_vm import DockerVM -from gns3server.compute.docker.vendor_docker_vm import VendorDockerVM -from gns3server.compute.docker.iol_docker_vm import IOLDockerVM from gns3server.compute.docker.docker_error import DockerError +from gns3server.compute.docker.docker_vm import DockerVM +from gns3server.compute.docker.iol_docker_vm import IOLDockerVM +from gns3server.compute.docker.vendor_docker_vm import VendorDockerVM from gns3server.compute.iou.utils.iou_export import nvram_export from gns3server.compute.iou.utils.iou_import import nvram_import - +from tests.utils import AsyncioMagicMock, asyncio_patch # --------------------------------------------------------------------------- # Helpers / fixtures diff --git a/tests/compute/docker/test_vendor_docker_vm.py b/tests/compute/docker/test_vendor_docker_vm.py index 2839e93c8..e594cf5fa 100644 --- a/tests/compute/docker/test_vendor_docker_vm.py +++ b/tests/compute/docker/test_vendor_docker_vm.py @@ -30,21 +30,18 @@ These tests cover: * the container-side _fix_permissions passes. """ -import uuid import os +import uuid +from unittest.mock import MagicMock, call, patch import pytest import pytest_asyncio -from unittest.mock import patch, MagicMock, call - -from tests.utils import asyncio_patch, AsyncioMagicMock - from gns3server.compute.docker import Docker +from gns3server.compute.docker.docker_error import DockerError, DockerHttp404Error from gns3server.compute.docker.docker_vm import DockerVM from gns3server.compute.docker.vendor_docker_vm import VendorDockerVM, _LazyExecTelnetServer -from gns3server.compute.docker.docker_error import DockerError, DockerHttp404Error - +from tests.utils import AsyncioMagicMock, asyncio_patch # --------------------------------------------------------------------------- # Helpers / fixtures diff --git a/tests/compute/dynamips/test_dynamips_manager.py b/tests/compute/dynamips/test_dynamips_manager.py index 0d62c014b..2d39592bf 100644 --- a/tests/compute/dynamips/test_dynamips_manager.py +++ b/tests/compute/dynamips/test_dynamips_manager.py @@ -15,16 +15,17 @@ # along with this program. If not, see . -import pytest -import pytest_asyncio +import os import tempfile import uuid -import os +from unittest.mock import patch + +import pytest +import pytest_asyncio from gns3server.compute.dynamips import Dynamips from gns3server.compute.dynamips.dynamips_error import DynamipsError -from unittest.mock import patch -from tests.utils import asyncio_patch, AsyncioMagicMock +from tests.utils import AsyncioMagicMock, asyncio_patch @pytest_asyncio.fixture diff --git a/tests/compute/dynamips/test_dynamips_router.py b/tests/compute/dynamips/test_dynamips_router.py index 068bb5e9e..e98ec98a0 100644 --- a/tests/compute/dynamips/test_dynamips_router.py +++ b/tests/compute/dynamips/test_dynamips_router.py @@ -16,12 +16,13 @@ import os import uuid + import pytest import pytest_asyncio -from gns3server.compute.dynamips.nodes.router import Router -from gns3server.compute.dynamips.dynamips_error import DynamipsError from gns3server.compute.dynamips import Dynamips +from gns3server.compute.dynamips.dynamips_error import DynamipsError +from gns3server.compute.dynamips.nodes.router import Router from gns3server.config import Config diff --git a/tests/compute/dynamips/test_ethernet_switch.py b/tests/compute/dynamips/test_ethernet_switch.py index c34be1952..49a0b1111 100644 --- a/tests/compute/dynamips/test_ethernet_switch.py +++ b/tests/compute/dynamips/test_ethernet_switch.py @@ -15,8 +15,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from tests.utils import AsyncioMagicMock from gns3server.compute.nios.nio_udp import NIOUDP +from tests.utils import AsyncioMagicMock def test_mac_command(): diff --git a/tests/compute/iou/test_iou_vm.py b/tests/compute/iou/test_iou_vm.py index d80cc4356..45ec5973a 100644 --- a/tests/compute/iou/test_iou_vm.py +++ b/tests/compute/iou/test_iou_vm.py @@ -14,22 +14,22 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest -import pytest_asyncio import asyncio import os -import stat +import shutil import socket +import stat import struct import uuid -import shutil - -from tests.utils import asyncio_patch, AsyncioMagicMock - from unittest.mock import MagicMock, call -from gns3server.compute.iou.iou_vm import IOUL1KeepaliveProtocol, IOUVM -from gns3server.compute.iou.iou_error import IOUError + +import pytest +import pytest_asyncio + from gns3server.compute.iou import IOU +from gns3server.compute.iou.iou_error import IOUError +from gns3server.compute.iou.iou_vm import IOUVM, IOUL1KeepaliveProtocol +from tests.utils import AsyncioMagicMock, asyncio_patch @pytest_asyncio.fixture diff --git a/tests/compute/marker/test_marker_manager.py b/tests/compute/marker/test_marker_manager.py index dcd71c3f9..b694340ed 100644 --- a/tests/compute/marker/test_marker_manager.py +++ b/tests/compute/marker/test_marker_manager.py @@ -16,11 +16,11 @@ # along with this program. If not, see . import asyncio + import pytest -from gns3server.compute.marker.marker_manager import MarkerManager from gns3server.compute.marker.marker_listener import MarkerListener - +from gns3server.compute.marker.marker_manager import MarkerManager # --------------------------------------------------------------------------- # Registry diff --git a/tests/compute/qemu/test_qcow2.py b/tests/compute/qemu/test_qcow2.py index dfd86a2e0..e9306a17e 100644 --- a/tests/compute/qemu/test_qcow2.py +++ b/tests/compute/qemu/test_qcow2.py @@ -16,9 +16,10 @@ # along with this program. If not, see . import os -import pytest import shutil +import pytest + from gns3server.compute.qemu.utils.qcow2 import Qcow2, Qcow2Error diff --git a/tests/compute/qemu/test_qemu_manager.py b/tests/compute/qemu/test_qemu_manager.py index 9f3c2afac..bab61bf17 100644 --- a/tests/compute/qemu/test_qemu_manager.py +++ b/tests/compute/qemu/test_qemu_manager.py @@ -15,17 +15,17 @@ # along with this program. If not, see . import os -import stat -import pytest import platform +import stat import sys +from unittest.mock import MagicMock, patch + +import pytest from gns3server.compute.qemu import Qemu from gns3server.compute.qemu.qemu_error import QemuError from tests.utils import asyncio_patch -from unittest.mock import patch, MagicMock - @pytest.fixture def fake_qemu_img_binary(tmpdir): diff --git a/tests/compute/qemu/test_qemu_vm.py b/tests/compute/qemu/test_qemu_vm.py index e20eddcd6..bfeb02bdf 100644 --- a/tests/compute/qemu/test_qemu_vm.py +++ b/tests/compute/qemu/test_qemu_vm.py @@ -14,23 +14,22 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest -import pytest_asyncio import asyncio import os import stat import sys -from tests.utils import asyncio_patch, AsyncioMagicMock - - from unittest import mock -from unittest.mock import patch, MagicMock +from unittest.mock import MagicMock, patch + +import pytest +import pytest_asyncio -from gns3server.compute.qemu.qemu_vm import QemuVM -from gns3server.compute.qemu.qemu_error import QemuError -from gns3server.compute.qemu import Qemu -from gns3server.utils import force_unix_path, macaddress_to_int, int_to_macaddress from gns3server.compute.notification_manager import NotificationManager +from gns3server.compute.qemu import Qemu +from gns3server.compute.qemu.qemu_error import QemuError +from gns3server.compute.qemu.qemu_vm import QemuVM +from gns3server.utils import force_unix_path, int_to_macaddress, macaddress_to_int +from tests.utils import AsyncioMagicMock, asyncio_patch @pytest_asyncio.fixture diff --git a/tests/compute/test_base_node.py b/tests/compute/test_base_node.py index 850db6325..9d4e15374 100644 --- a/tests/compute/test_base_node.py +++ b/tests/compute/test_base_node.py @@ -17,19 +17,18 @@ import os import shutil from collections import OrderedDict +from unittest.mock import MagicMock, patch import pytest import pytest_asyncio -from tests.utils import asyncio_patch, AsyncioMagicMock -from unittest.mock import patch, MagicMock - from gns3server.compute.compute_error import ComputeError -from gns3server.compute.vpcs.vpcs_vm import VPCSVM from gns3server.compute.docker.docker_vm import DockerVM from gns3server.compute.error import NodeError -from gns3server.compute.vpcs import VPCS from gns3server.compute.nios.nio_udp import NIOUDP +from gns3server.compute.vpcs import VPCS +from gns3server.compute.vpcs.vpcs_vm import VPCSVM +from tests.utils import AsyncioMagicMock, asyncio_patch @pytest_asyncio.fixture(scope="function") diff --git a/tests/compute/test_manager.py b/tests/compute/test_manager.py index f0f5bbc46..db9f22586 100644 --- a/tests/compute/test_manager.py +++ b/tests/compute/test_manager.py @@ -14,19 +14,20 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import uuid import os +import uuid +from unittest.mock import MagicMock, patch + import pytest import pytest_asyncio -from unittest.mock import patch, MagicMock -from tests.utils import asyncio_patch -from gns3server.compute.vpcs import VPCS -from gns3server.compute.dynamips import Dynamips -from gns3server.compute.qemu import Qemu -from gns3server.compute.error import NodeError, ImageMissingError from gns3server.compute.compute_error import ComputeError +from gns3server.compute.dynamips import Dynamips +from gns3server.compute.error import ImageMissingError, NodeError +from gns3server.compute.qemu import Qemu +from gns3server.compute.vpcs import VPCS from gns3server.utils import force_unix_path +from tests.utils import asyncio_patch @pytest_asyncio.fixture(scope="function") diff --git a/tests/compute/test_notification_manager.py b/tests/compute/test_notification_manager.py index 3daea1a8c..3ee862302 100644 --- a/tests/compute/test_notification_manager.py +++ b/tests/compute/test_notification_manager.py @@ -15,9 +15,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest import uuid +import pytest + from gns3server.compute.notification_manager import NotificationManager diff --git a/tests/compute/test_port_manager.py b/tests/compute/test_port_manager.py index f28418563..2e55ec8a1 100644 --- a/tests/compute/test_port_manager.py +++ b/tests/compute/test_port_manager.py @@ -14,13 +14,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest import threading import uuid - -from fastapi import HTTPException from unittest.mock import patch +import pytest +from fastapi import HTTPException + from gns3server.compute.port_manager import PortManager from gns3server.compute.project import Project diff --git a/tests/compute/test_project.py b/tests/compute/test_project.py index d46abe4e9..abf969084 100644 --- a/tests/compute/test_project.py +++ b/tests/compute/test_project.py @@ -17,16 +17,17 @@ import os import uuid +from unittest.mock import patch +from uuid import uuid4 + import pytest import pytest_asyncio -from uuid import uuid4 -from unittest.mock import patch -from tests.utils import asyncio_patch -from gns3server.compute.project import Project -from gns3server.compute.notification_manager import NotificationManager from gns3server.compute.compute_error import ComputeError, ComputeForbiddenError +from gns3server.compute.notification_manager import NotificationManager +from gns3server.compute.project import Project from gns3server.compute.vpcs import VPCS, VPCSVM +from tests.utils import asyncio_patch @pytest_asyncio.fixture(scope="function") diff --git a/tests/compute/ubridge/test_hypervisor.py b/tests/compute/ubridge/test_hypervisor.py index 1ee5a555a..74f0be660 100644 --- a/tests/compute/ubridge/test_hypervisor.py +++ b/tests/compute/ubridge/test_hypervisor.py @@ -22,13 +22,13 @@ transport (AF_UNIX ``-U`` vs TCP ``-H``), command building, the human-readable immediately-exiting uBridge process (e.g. an old build that rejects ``-U``). """ +import logging import os import re import stat -import logging +from unittest.mock import AsyncMock, MagicMock, patch import pytest -from unittest.mock import MagicMock, AsyncMock, patch from gns3server.compute.ubridge.hypervisor import Hypervisor from gns3server.compute.ubridge.ubridge_error import UbridgeError diff --git a/tests/compute/virtualbox/test_virtualbox_manager.py b/tests/compute/virtualbox/test_virtualbox_manager.py index 8a23b41df..4e60da7da 100644 --- a/tests/compute/virtualbox/test_virtualbox_manager.py +++ b/tests/compute/virtualbox/test_virtualbox_manager.py @@ -15,14 +15,14 @@ # along with this program. If not, see . -import pytest -import pytest_asyncio -import tempfile import os import stat - +import tempfile from unittest.mock import patch +import pytest +import pytest_asyncio + from gns3server.compute.virtualbox import VirtualBox from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError from tests.utils import asyncio_patch diff --git a/tests/compute/virtualbox/test_virtualbox_vm.py b/tests/compute/virtualbox/test_virtualbox_vm.py index ead5c72fe..d2cab8aa1 100644 --- a/tests/compute/virtualbox/test_virtualbox_vm.py +++ b/tests/compute/virtualbox/test_virtualbox_vm.py @@ -15,13 +15,14 @@ # along with this program. If not, see . import os + import pytest import pytest_asyncio -from tests.utils import asyncio_patch, AsyncioMagicMock -from gns3server.compute.virtualbox.virtualbox_vm import VirtualBoxVM -from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError from gns3server.compute.virtualbox import VirtualBox +from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError +from gns3server.compute.virtualbox.virtualbox_vm import VirtualBoxVM +from tests.utils import AsyncioMagicMock, asyncio_patch @pytest_asyncio.fixture diff --git a/tests/compute/vmware/test_vmware_vm.py b/tests/compute/vmware/test_vmware_vm.py index f2badff9c..f13efb08b 100644 --- a/tests/compute/vmware/test_vmware_vm.py +++ b/tests/compute/vmware/test_vmware_vm.py @@ -17,8 +17,8 @@ import pytest import pytest_asyncio -from gns3server.compute.vmware.vmware_vm import VMwareVM from gns3server.compute.vmware import VMware +from gns3server.compute.vmware.vmware_vm import VMwareVM @pytest_asyncio.fixture diff --git a/tests/compute/vpcs/test_vpcs_manager.py b/tests/compute/vpcs/test_vpcs_manager.py index d567b8674..7aad60146 100644 --- a/tests/compute/vpcs/test_vpcs_manager.py +++ b/tests/compute/vpcs/test_vpcs_manager.py @@ -15,13 +15,13 @@ # along with this program. If not, see . -import pytest import uuid +import pytest +from gns3server.compute.project_manager import ProjectManager from gns3server.compute.vpcs import VPCS from gns3server.compute.vpcs.vpcs_error import VPCSError -from gns3server.compute.project_manager import ProjectManager @pytest.mark.asyncio diff --git a/tests/compute/vpcs/test_vpcs_vm.py b/tests/compute/vpcs/test_vpcs_vm.py index 1d74fdf95..be4d6a364 100644 --- a/tests/compute/vpcs/test_vpcs_vm.py +++ b/tests/compute/vpcs/test_vpcs_vm.py @@ -14,19 +14,19 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest -import pytest_asyncio import asyncio import os +from unittest.mock import ANY, MagicMock, patch -from tests.utils import asyncio_patch, AsyncioMagicMock -from gns3server.utils import parse_version -from unittest.mock import patch, MagicMock, ANY +import pytest +import pytest_asyncio -from gns3server.compute.vpcs.vpcs_vm import VPCSVM -from gns3server.compute.vpcs.vpcs_error import VPCSError -from gns3server.compute.vpcs import VPCS from gns3server.compute.notification_manager import NotificationManager +from gns3server.compute.vpcs import VPCS +from gns3server.compute.vpcs.vpcs_error import VPCSError +from gns3server.compute.vpcs.vpcs_vm import VPCSVM +from gns3server.utils import parse_version +from tests.utils import AsyncioMagicMock, asyncio_patch @pytest_asyncio.fixture diff --git a/tests/controller/gns3vm/test_remote_gns3_vm.py b/tests/controller/gns3vm/test_remote_gns3_vm.py index 5b475a174..be1620869 100644 --- a/tests/controller/gns3vm/test_remote_gns3_vm.py +++ b/tests/controller/gns3vm/test_remote_gns3_vm.py @@ -16,11 +16,11 @@ # along with this program. If not, see . import pytest - -from gns3server.controller.gns3vm.remote_gns3_vm import RemoteGNS3VM -from gns3server.controller.gns3vm.gns3_vm_error import GNS3VMError from pydantic import SecretStr +from gns3server.controller.gns3vm.gns3_vm_error import GNS3VMError +from gns3server.controller.gns3vm.remote_gns3_vm import RemoteGNS3VM + @pytest.fixture def gns3vm(controller): diff --git a/tests/controller/gns3vm/test_virtualbox_gns3_vm.py b/tests/controller/gns3vm/test_virtualbox_gns3_vm.py index 6ae3cc5a6..fe8f453c3 100644 --- a/tests/controller/gns3vm/test_virtualbox_gns3_vm.py +++ b/tests/controller/gns3vm/test_virtualbox_gns3_vm.py @@ -18,10 +18,9 @@ import pytest import pytest_asyncio -from tests.utils import asyncio_patch -from gns3server.utils.asyncio import wait_run_in_executor - from gns3server.controller.gns3vm.virtualbox_gns3_vm import VirtualBoxGNS3VM +from gns3server.utils.asyncio import wait_run_in_executor +from tests.utils import asyncio_patch @pytest_asyncio.fixture diff --git a/tests/controller/test_appliance.py b/tests/controller/test_appliance.py index 969d90d54..b18a6cb97 100644 --- a/tests/controller/test_appliance.py +++ b/tests/controller/test_appliance.py @@ -22,7 +22,6 @@ from gns3server.controller.appliance import Appliance from gns3server.controller.appliance_to_template import ApplianceToTemplate from gns3server.schemas.controller.appliances import ApplianceModel - # v8 mirror of the XRd Control Plane appliance shape (docker, custom_adapters, no versions) XRD_V8 = { "registry_version": 8, diff --git a/tests/controller/test_appliance_manager.py b/tests/controller/test_appliance_manager.py index 38c343181..0700b0312 100644 --- a/tests/controller/test_appliance_manager.py +++ b/tests/controller/test_appliance_manager.py @@ -16,6 +16,7 @@ # along with this program. If not, see . import uuid + import pytest from gns3server.controller.appliance import Appliance diff --git a/tests/controller/test_appliance_to_template.py b/tests/controller/test_appliance_to_template.py index a50338370..9faff12b4 100644 --- a/tests/controller/test_appliance_to_template.py +++ b/tests/controller/test_appliance_to_template.py @@ -15,14 +15,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest import pydantic +import pytest from gns3server.controller.appliance_to_template import ApplianceToTemplate from gns3server.controller.controller_error import ControllerError from gns3server.schemas.controller.appliances import ApplianceModel - # reduced mirror of the upstream vyos.gns3a (registry version 8, qemu, 2 settings sets) VYOS_V8 = { "registry_version": 8, diff --git a/tests/controller/test_compute.py b/tests/controller/test_compute.py index 04ed1d740..9a05e7c27 100644 --- a/tests/controller/test_compute.py +++ b/tests/controller/test_compute.py @@ -15,25 +15,26 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import sys -import json import asyncio +import json +import sys +from types import SimpleNamespace +from unittest.mock import MagicMock, patch + import aiohttp import pytest -from types import SimpleNamespace -from unittest.mock import patch, MagicMock +from pydantic import SecretStr -from gns3server.controller.project import Project -from gns3server.controller.compute import Compute from gns3server.api.server import app as gns3_app +from gns3server.controller.compute import Compute from gns3server.controller.controller_error import ( + ComputeConflictError, ControllerError, ControllerNotFoundError, ControllerUnauthorizedError, - ComputeConflictError, ) -from pydantic import SecretStr -from tests.utils import asyncio_patch, AsyncioMagicMock +from gns3server.controller.project import Project +from tests.utils import AsyncioMagicMock, asyncio_patch @pytest.fixture diff --git a/tests/controller/test_controller.py b/tests/controller/test_controller.py index 18edb22ee..355576d3f 100644 --- a/tests/controller/test_controller.py +++ b/tests/controller/test_controller.py @@ -15,21 +15,21 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import os -import uuid -import json import asyncio -import pytest +import json +import os import socket +import uuid from unittest.mock import MagicMock, patch -from tests.utils import AsyncioMagicMock, asyncio_patch -from watchdog.events import FileCreatedEvent, DirCreatedEvent +import pytest +from watchdog.events import DirCreatedEvent, FileCreatedEvent + +from gns3server.controller import _ProjectsDirectoryEventHandler from gns3server.controller.compute import Compute from gns3server.controller.controller_error import ControllerError, ControllerNotFoundError -from gns3server.controller import _ProjectsDirectoryEventHandler from gns3server.version import __version__ - +from tests.utils import AsyncioMagicMock, asyncio_patch # def test_save(controller, controller_config_path): # diff --git a/tests/controller/test_drawing.py b/tests/controller/test_drawing.py index cd7946e10..b80e404af 100644 --- a/tests/controller/test_drawing.py +++ b/tests/controller/test_drawing.py @@ -15,14 +15,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from unittest.mock import MagicMock -import pytest -import uuid import os +import uuid +from unittest.mock import MagicMock -from tests.utils import AsyncioMagicMock +import pytest from gns3server.controller.drawing import Drawing +from tests.utils import AsyncioMagicMock @pytest.fixture diff --git a/tests/controller/test_export_project.py b/tests/controller/test_export_project.py index 5927a7e66..3f4009c9a 100644 --- a/tests/controller/test_export_project.py +++ b/tests/controller/test_export_project.py @@ -16,22 +16,21 @@ # along with this program. If not, see . -import os import json +import os +import stat +import zipfile +from pathlib import Path +from unittest.mock import MagicMock, patch + import pytest import pytest_asyncio -import zipfile -import stat -from pathlib import Path -from unittest.mock import patch -from unittest.mock import MagicMock -from tests.utils import AsyncioMagicMock, AsyncioBytesIO - -from gns3server.controller.project import Project -from gns3server.controller.export_project import export_project, _is_exportable -from gns3server.utils.asyncio import aiozipstream from gns3server.controller.controller_error import ControllerError +from gns3server.controller.export_project import _is_exportable, export_project +from gns3server.controller.project import Project +from gns3server.utils.asyncio import aiozipstream +from tests.utils import AsyncioBytesIO, AsyncioMagicMock @pytest_asyncio.fixture diff --git a/tests/controller/test_gns3vm.py b/tests/controller/test_gns3vm.py index 48af40493..d9832e4f5 100644 --- a/tests/controller/test_gns3vm.py +++ b/tests/controller/test_gns3vm.py @@ -15,13 +15,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest import sys -from tests.utils import asyncio_patch, AsyncioMagicMock + +import pytest +from pydantic import SecretStr from gns3server.controller.gns3vm import GNS3VM from gns3server.controller.gns3vm.gns3_vm_error import GNS3VMError -from pydantic import SecretStr +from tests.utils import AsyncioMagicMock, asyncio_patch @pytest.fixture diff --git a/tests/controller/test_import_project.py b/tests/controller/test_import_project.py index b7d7ea042..792d3c012 100644 --- a/tests/controller/test_import_project.py +++ b/tests/controller/test_import_project.py @@ -15,23 +15,22 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest +import json import os import uuid -import json import zipfile +from pathlib import Path +from unittest.mock import MagicMock, patch + import pytest -from pathlib import Path -from tests.utils import asyncio_patch, AsyncioMagicMock -from unittest.mock import patch, MagicMock - -from gns3server.utils.asyncio import aiozipstream -from gns3server.controller.project import Project from gns3server.controller.controller_error import ControllerError from gns3server.controller.export_project import export_project -from gns3server.controller.import_project import import_project, _move_files_to_compute +from gns3server.controller.import_project import _move_files_to_compute, import_project +from gns3server.controller.project import Project +from gns3server.utils.asyncio import aiozipstream from gns3server.version import __version__ +from tests.utils import AsyncioMagicMock, asyncio_patch @pytest.mark.asyncio diff --git a/tests/controller/test_link.py b/tests/controller/test_link.py index 1cfcdb9bf..12436abb5 100644 --- a/tests/controller/test_link.py +++ b/tests/controller/test_link.py @@ -15,15 +15,16 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest -import pytest_asyncio from unittest.mock import MagicMock +import pytest +import pytest_asyncio + +from gns3server.controller.controller_error import ControllerError from gns3server.controller.link import Link from gns3server.controller.node import Node from gns3server.controller.ports.ethernet_port import EthernetPort from gns3server.controller.ports.serial_port import SerialPort -from gns3server.controller.controller_error import ControllerError from tests.utils import AsyncioBytesIO, AsyncioMagicMock diff --git a/tests/controller/test_marker.py b/tests/controller/test_marker.py index ec23b5d2d..bc27772c5 100644 --- a/tests/controller/test_marker.py +++ b/tests/controller/test_marker.py @@ -25,18 +25,17 @@ Controller-layer tests for the traffic-insight marker feature: """ import uuid +from contextlib import ExitStack +from unittest.mock import MagicMock, patch import pytest -from unittest.mock import MagicMock, patch -from contextlib import ExitStack -from tests.utils import AsyncioMagicMock - -from gns3server.controller.udp_link import UDPLink +from gns3server.controller.controller_error import ControllerError, ControllerNotFoundError +from gns3server.controller.node import Node from gns3server.controller.ports.ethernet_port import EthernetPort from gns3server.controller.ports.serial_port import SerialPort -from gns3server.controller.node import Node -from gns3server.controller.controller_error import ControllerError, ControllerNotFoundError +from gns3server.controller.udp_link import UDPLink +from tests.utils import AsyncioMagicMock def _valid_bpf(): diff --git a/tests/controller/test_marker_replay.py b/tests/controller/test_marker_replay.py index e958d3888..7939b9a03 100644 --- a/tests/controller/test_marker_replay.py +++ b/tests/controller/test_marker_replay.py @@ -43,25 +43,25 @@ from unittest.mock import patch import pytest +from gns3server.controller import marker_replay from gns3server.controller.controller_error import ( ControllerBadRequestError, ControllerError, ControllerNotFoundError, ) -from gns3server.controller import marker_replay from gns3server.controller.marker_replay import ( FilterError, SharkdError, SharkdMissingError, + _count_tree_nodes, + _format_ts, + _parse_ts, + _rename_value, build_timeline, decode_frame, query_frames, read_frame_bytes, scan_pcap_frames, - _count_tree_nodes, - _format_ts, - _parse_ts, - _rename_value, ) pytestmark = pytest.mark.asyncio diff --git a/tests/controller/test_node.py b/tests/controller/test_node.py index 300d410bd..717537a37 100644 --- a/tests/controller/test_node.py +++ b/tests/controller/test_node.py @@ -15,18 +15,18 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import shutil -import pytest -import uuid import os +import shutil +import uuid +from unittest.mock import ANY, MagicMock + +import pytest -from unittest.mock import MagicMock, ANY -from tests.utils import AsyncioMagicMock, asyncio_patch from gns3server.compute.docker.docker_error import DockerError - +from gns3server.controller.controller_error import ComputeConflictError, ControllerError from gns3server.controller.node import Node from gns3server.controller.project import Project -from gns3server.controller.controller_error import ComputeConflictError, ControllerError +from tests.utils import AsyncioMagicMock, asyncio_patch @pytest.fixture diff --git a/tests/controller/test_node_port_name.py b/tests/controller/test_node_port_name.py index bfd108197..76dee1f2f 100644 --- a/tests/controller/test_node_port_name.py +++ b/tests/controller/test_node_port_name.py @@ -15,13 +15,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest import uuid -from tests.utils import AsyncioMagicMock +import pytest from gns3server.controller.node import Node from gns3server.controller.ports.ethernet_port import EthernetPort +from tests.utils import AsyncioMagicMock @pytest.fixture diff --git a/tests/controller/test_notification.py b/tests/controller/test_notification.py index 1369a9b11..53e24f1f2 100644 --- a/tests/controller/test_notification.py +++ b/tests/controller/test_notification.py @@ -15,9 +15,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from unittest.mock import MagicMock + import pytest import pytest_asyncio -from unittest.mock import MagicMock from tests.utils import AsyncioMagicMock diff --git a/tests/controller/test_project.py b/tests/controller/test_project.py index 8256dd450..3a5d3b175 100644 --- a/tests/controller/test_project.py +++ b/tests/controller/test_project.py @@ -15,26 +15,26 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import os import json +import os import uuid -import pytest -import pytest_asyncio -from unittest.mock import MagicMock -from tests.utils import AsyncioMagicMock, asyncio_patch -from unittest.mock import patch +from unittest.mock import MagicMock, patch from uuid import uuid4 -from gns3server.controller.project import Project +import pytest +import pytest_asyncio + +from gns3server.config import Config +from gns3server.controller.controller_error import ( + ComputeConflictError, + ControllerError, + ControllerForbiddenError, + ControllerNotFoundError, +) from gns3server.controller.node import Node from gns3server.controller.ports.ethernet_port import EthernetPort -from gns3server.controller.controller_error import ( - ControllerError, - ControllerNotFoundError, - ControllerForbiddenError, - ComputeConflictError, -) -from gns3server.config import Config +from gns3server.controller.project import Project +from tests.utils import AsyncioMagicMock, asyncio_patch @pytest_asyncio.fixture diff --git a/tests/controller/test_project_open.py b/tests/controller/test_project_open.py index 1d5ce49d9..f3830bee3 100644 --- a/tests/controller/test_project_open.py +++ b/tests/controller/test_project_open.py @@ -15,14 +15,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import os import json -import pytest +import os -from tests.utils import asyncio_patch +import pytest from gns3server.controller.compute import Compute from gns3server.controller.project import Project +from tests.utils import asyncio_patch @pytest.fixture diff --git a/tests/controller/test_rbac.py b/tests/controller/test_rbac.py index b332f20e0..6dd3b7dd2 100644 --- a/tests/controller/test_rbac.py +++ b/tests/controller/test_rbac.py @@ -15,22 +15,22 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest -import pytest_asyncio import uuid +import pytest +import pytest_asyncio from fastapi import FastAPI, status from httpx import AsyncClient from httpx_ws.transport import ASGIWebSocketTransport - from sqlalchemy.ext.asyncio import AsyncSession + from gns3server.controller import Controller +from gns3server.db.models import User +from gns3server.db.repositories.pools import ResourcePoolsRepository from gns3server.db.repositories.rbac import RbacRepository from gns3server.db.repositories.users import UsersRepository -from gns3server.db.repositories.pools import ResourcePoolsRepository -from gns3server.schemas.controller.rbac import ACECreate from gns3server.schemas.controller.pools import ResourceCreate, ResourcePoolCreate -from gns3server.db.models import User +from gns3server.schemas.controller.rbac import ACECreate from gns3server.services import auth_service pytestmark = pytest.mark.asyncio diff --git a/tests/controller/test_snapshot.py b/tests/controller/test_snapshot.py index 008d0bb57..4e4a1a4a5 100644 --- a/tests/controller/test_snapshot.py +++ b/tests/controller/test_snapshot.py @@ -16,13 +16,13 @@ # along with this program. If not, see . import os +from unittest import mock +from unittest.mock import MagicMock, patch from uuid import uuid4 import pytest -from unittest import mock -from unittest.mock import patch, MagicMock -from gns3server.controller.snapshot import Snapshot +from gns3server.controller.snapshot import Snapshot from tests.utils import AsyncioMagicMock diff --git a/tests/controller/test_symbols.py b/tests/controller/test_symbols.py index 3856427fb..ee9eda8c5 100644 --- a/tests/controller/test_symbols.py +++ b/tests/controller/test_symbols.py @@ -17,8 +17,8 @@ import os -from gns3server.controller.symbols import Symbols from gns3server.controller.symbol_themes import BUILTIN_SYMBOL_THEMES +from gns3server.controller.symbols import Symbols from gns3server.utils.get_resource import get_resource diff --git a/tests/controller/test_topology.py b/tests/controller/test_topology.py index 3419aa794..2e2d5c4ff 100644 --- a/tests/controller/test_topology.py +++ b/tests/controller/test_topology.py @@ -17,15 +17,16 @@ import json import uuid -import pytest from unittest.mock import MagicMock, patch -from tests.utils import asyncio_patch -from gns3server.controller.project import Project +import pytest + from gns3server.controller.compute import Compute -from gns3server.controller.topology import project_to_topology, load_topology, GNS3_FILE_FORMAT_REVISION from gns3server.controller.controller_error import ControllerError +from gns3server.controller.project import Project +from gns3server.controller.topology import GNS3_FILE_FORMAT_REVISION, load_topology, project_to_topology from gns3server.version import __version__ +from tests.utils import asyncio_patch @pytest.mark.asyncio diff --git a/tests/controller/test_udp_link.py b/tests/controller/test_udp_link.py index 7c433a6fb..4a055ae8a 100644 --- a/tests/controller/test_udp_link.py +++ b/tests/controller/test_udp_link.py @@ -15,14 +15,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest from unittest.mock import MagicMock -from tests.utils import AsyncioMagicMock -from gns3server.controller.udp_link import UDPLink -from gns3server.controller.ports.ethernet_port import EthernetPort -from gns3server.controller.node import Node +import pytest + from gns3server.controller.controller_error import ControllerError +from gns3server.controller.node import Node +from gns3server.controller.ports.ethernet_port import EthernetPort +from gns3server.controller.udp_link import UDPLink +from tests.utils import AsyncioMagicMock @pytest.mark.asyncio