From b46b9a1d265846ae08db53eb824e0e91237f615a Mon Sep 17 00:00:00 2001 From: Mark Paronyan Date: Wed, 30 Sep 2026 20:51:24 +0300 Subject: [PATCH] style: sort imports in api tests --- tests/api/routes/compute/test_capabilities.py | 6 ++--- tests/api/routes/compute/test_cloud_nodes.py | 4 +--- tests/api/routes/compute/test_compute.py | 6 ++--- tests/api/routes/compute/test_docker_nodes.py | 6 ++--- .../api/routes/compute/test_dynamips_nodes.py | 6 ++--- .../compute/test_ethernet_switch_nodes.py | 6 ++--- tests/api/routes/compute/test_images.py | 2 +- tests/api/routes/compute/test_iou_nodes.py | 12 +++++----- tests/api/routes/compute/test_nat_nodes.py | 3 +-- .../api/routes/compute/test_notifications.py | 3 ++- tests/api/routes/compute/test_projects.py | 19 ++++++++++----- tests/api/routes/compute/test_qemu_nodes.py | 14 +++++------ .../routes/compute/test_virtualbox_nodes.py | 12 +++++----- tests/api/routes/compute/test_vmware_nodes.py | 12 +++++----- tests/api/routes/compute/test_vpcs_nodes.py | 12 +++++----- .../routes/controller/test_access_tickets.py | 2 +- tests/api/routes/controller/test_acl.py | 11 ++++----- .../api/routes/controller/test_appliances.py | 3 ++- tests/api/routes/controller/test_computes.py | 4 ++-- .../api/routes/controller/test_controller.py | 4 ++-- tests/api/routes/controller/test_drawings.py | 1 - tests/api/routes/controller/test_gns3vm.py | 2 +- tests/api/routes/controller/test_groups.py | 3 +-- tests/api/routes/controller/test_images.py | 15 ++++++------ tests/api/routes/controller/test_links.py | 15 ++++++------ .../routes/controller/test_marker_replay.py | 5 ++-- tests/api/routes/controller/test_markers.py | 3 +-- tests/api/routes/controller/test_netmiko.py | 1 - tests/api/routes/controller/test_nodes.py | 23 ++++++++----------- tests/api/routes/controller/test_pools.py | 6 ++--- tests/api/routes/controller/test_projects.py | 12 +++++----- tests/api/routes/controller/test_roles.py | 3 +-- tests/api/routes/controller/test_settings.py | 3 +-- tests/api/routes/controller/test_snapshots.py | 2 +- tests/api/routes/controller/test_symbols.py | 2 +- tests/api/routes/controller/test_templates.py | 18 +++++++-------- tests/api/routes/controller/test_users.py | 16 ++++++------- tests/api/routes/controller/test_version.py | 1 - tests/api/routes/test_index.py | 10 ++++---- tests/api/routes/test_routes.py | 6 ++--- 40 files changed, 142 insertions(+), 152 deletions(-) diff --git a/tests/api/routes/compute/test_capabilities.py b/tests/api/routes/compute/test_capabilities.py index 9a285c7bc..a401e8f24 100644 --- a/tests/api/routes/compute/test_capabilities.py +++ b/tests/api/routes/compute/test_capabilities.py @@ -16,14 +16,14 @@ import sys -import pytest -import psutil +import psutil +import pytest from fastapi import FastAPI, status from httpx import AsyncClient -from gns3server.version import __version__ from gns3server.utils.path import get_default_project_directory +from gns3server.version import __version__ pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/compute/test_cloud_nodes.py b/tests/api/routes/compute/test_cloud_nodes.py index 01a32ec36..0500356a8 100644 --- a/tests/api/routes/compute/test_cloud_nodes.py +++ b/tests/api/routes/compute/test_cloud_nodes.py @@ -16,13 +16,11 @@ import pytest import pytest_asyncio - from fastapi import FastAPI, status from httpx import AsyncClient -from tests.utils import asyncio_patch - from gns3server.compute.project import Project +from tests.utils import asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/compute/test_compute.py b/tests/api/routes/compute/test_compute.py index 1a9579b77..433b908c6 100644 --- a/tests/api/routes/compute/test_compute.py +++ b/tests/api/routes/compute/test_compute.py @@ -14,16 +14,16 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from unittest.mock import patch, MagicMock -import pytest +from unittest.mock import MagicMock, patch +import pytest from fastapi import FastAPI, status from httpx import AsyncClient -from gns3server.version import __version__ from gns3server.compute.project import Project from gns3server.config import Config from gns3server.schemas.config import ServerSettings +from gns3server.version import __version__ pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/compute/test_docker_nodes.py b/tests/api/routes/compute/test_docker_nodes.py index e16fb422c..40cb31679 100644 --- a/tests/api/routes/compute/test_docker_nodes.py +++ b/tests/api/routes/compute/test_docker_nodes.py @@ -14,17 +14,17 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from unittest.mock import MagicMock, patch + import pytest import pytest_asyncio - from fastapi import FastAPI, status from httpx import AsyncClient -from tests.utils import asyncio_patch, AsyncioMagicMock -from unittest.mock import patch, MagicMock from gns3server.compute.docker import Docker from gns3server.compute.docker.iol_docker_vm import IOLDockerVM from gns3server.compute.project import Project +from tests.utils import AsyncioMagicMock, asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/compute/test_dynamips_nodes.py b/tests/api/routes/compute/test_dynamips_nodes.py index c5d014ea6..60ea6acf6 100644 --- a/tests/api/routes/compute/test_dynamips_nodes.py +++ b/tests/api/routes/compute/test_dynamips_nodes.py @@ -14,12 +14,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest -import sys import os import stat - +import sys from unittest.mock import patch + +import pytest from fastapi import FastAPI, status from httpx import AsyncClient diff --git a/tests/api/routes/compute/test_ethernet_switch_nodes.py b/tests/api/routes/compute/test_ethernet_switch_nodes.py index cc046e3ef..7930b6bb4 100644 --- a/tests/api/routes/compute/test_ethernet_switch_nodes.py +++ b/tests/api/routes/compute/test_ethernet_switch_nodes.py @@ -14,15 +14,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from unittest.mock import MagicMock, call + import pytest import pytest_asyncio - from fastapi import FastAPI, status from httpx import AsyncClient -from tests.utils import asyncio_patch, AsyncioMagicMock -from unittest.mock import call, MagicMock from gns3server.compute.project import Project +from tests.utils import AsyncioMagicMock, asyncio_patch # The builtin Ethernet switch talks to uBridge (brctl/bridge modules) instead of # the Dynamips hypervisor. These are the seams we stub so the routes can be diff --git a/tests/api/routes/compute/test_images.py b/tests/api/routes/compute/test_images.py index 62209eea1..f1a3da75e 100644 --- a/tests/api/routes/compute/test_images.py +++ b/tests/api/routes/compute/test_images.py @@ -15,9 +15,9 @@ # along with this program. If not, see . import pytest - from fastapi import FastAPI, status from httpx import AsyncClient + from tests.utils import asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/compute/test_iou_nodes.py b/tests/api/routes/compute/test_iou_nodes.py index 65c2e56db..feebe2b87 100644 --- a/tests/api/routes/compute/test_iou_nodes.py +++ b/tests/api/routes/compute/test_iou_nodes.py @@ -14,18 +14,18 @@ # 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 os import stat import uuid - -from fastapi import FastAPI, status -from httpx import AsyncClient -from tests.utils import asyncio_patch from unittest.mock import patch +import pytest +import pytest_asyncio +from fastapi import FastAPI, status +from httpx import AsyncClient + from gns3server.compute.project import Project +from tests.utils import asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/compute/test_nat_nodes.py b/tests/api/routes/compute/test_nat_nodes.py index 0d40cd487..d6f404721 100644 --- a/tests/api/routes/compute/test_nat_nodes.py +++ b/tests/api/routes/compute/test_nat_nodes.py @@ -16,12 +16,11 @@ import pytest import pytest_asyncio - from fastapi import FastAPI, status from httpx import AsyncClient -from tests.utils import asyncio_patch from gns3server.compute.project import Project +from tests.utils import asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/compute/test_notifications.py b/tests/api/routes/compute/test_notifications.py index da8663e6c..b0636d99c 100644 --- a/tests/api/routes/compute/test_notifications.py +++ b/tests/api/routes/compute/test_notifications.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 json +import pytest + from gns3server.compute.notification_manager import NotificationManager diff --git a/tests/api/routes/compute/test_projects.py b/tests/api/routes/compute/test_projects.py index 2b8637d5b..30866aaa6 100644 --- a/tests/api/routes/compute/test_projects.py +++ b/tests/api/routes/compute/test_projects.py @@ -14,17 +14,17 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest -import uuid import os - +import uuid from unittest.mock import patch -from tests.utils import asyncio_patch + +import pytest from fastapi import FastAPI, status from httpx import AsyncClient -from gns3server.compute.project_manager import ProjectManager from gns3server.compute.project import Project +from gns3server.compute.project_manager import ProjectManager +from tests.utils import asyncio_patch pytestmark = pytest.mark.asyncio @@ -208,6 +208,7 @@ class TestBatchNIOEdgeCases: async def test_dynamips_router_dispatch_to_slot_add_nio_binding(self): """_add_nio_binding dispatches Dynamips router to slot_add_nio_binding.""" from unittest.mock import AsyncMock, MagicMock + from gns3server.api.routes.compute.projects import _add_nio_binding node = MagicMock() @@ -222,6 +223,7 @@ class TestBatchNIOEdgeCases: async def test_dynamips_switch_dispatch_to_add_nio(self): """_add_nio_binding dispatches Dynamips switch to add_nio.""" from unittest.mock import AsyncMock, MagicMock + from gns3server.api.routes.compute.projects import _add_nio_binding node = MagicMock() @@ -239,8 +241,8 @@ class TestBatchNIOEdgeCases: Dynamips.create_nio is async (returns a coroutine) unlike the sync base version. The batch handler must await it. """ - import inspect import asyncio as _asyncio + import inspect class _FakeDynamips: async def create_nio(self, node, nio_settings): @@ -267,6 +269,7 @@ class TestBatchNIOEdgeCases: async def test_qemu_dispatch_to_adapter_add_nio_binding(self): """_add_nio_binding dispatches Qemu to adapter_add_nio_binding.""" from unittest.mock import AsyncMock, MagicMock + from gns3server.api.routes.compute.projects import _add_nio_binding node = MagicMock() @@ -281,6 +284,7 @@ class TestBatchNIOEdgeCases: async def test_iou_dispatch_to_adapter_add_nio_binding(self): """_add_nio_binding dispatches IOU to adapter_add_nio_binding(adapter, port, nio).""" from unittest.mock import AsyncMock, MagicMock + from gns3server.api.routes.compute.projects import _add_nio_binding node = MagicMock() @@ -300,6 +304,7 @@ class TestBatchNIOEdgeCases: cross-wired links (the last entry per node wins). """ from unittest.mock import AsyncMock, MagicMock + from gns3server.api.routes.compute.projects import ( _add_nio_binding, _get_existing_nio, @@ -326,6 +331,7 @@ class TestBatchNIOEdgeCases: async def test_vpcs_dispatch_to_port_add_nio_binding(self): """_add_nio_binding dispatches VPCS to port_add_nio_binding.""" from unittest.mock import AsyncMock, MagicMock + from gns3server.api.routes.compute.projects import _add_nio_binding node = MagicMock() @@ -340,6 +346,7 @@ class TestBatchNIOEdgeCases: async def test_builtin_dispatch_to_add_nio(self): """_add_nio_binding dispatches Builtin nodes to add_nio(nio, port).""" from unittest.mock import AsyncMock, MagicMock + from gns3server.api.routes.compute.projects import _add_nio_binding node = MagicMock() diff --git a/tests/api/routes/compute/test_qemu_nodes.py b/tests/api/routes/compute/test_qemu_nodes.py index 304f330a4..1281f338f 100644 --- a/tests/api/routes/compute/test_qemu_nodes.py +++ b/tests/api/routes/compute/test_qemu_nodes.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 os +import shutil +import stat +import uuid +from unittest.mock import MagicMock, patch + import pytest import pytest_asyncio -import os -import stat -import shutil -import uuid - from fastapi import FastAPI, status from httpx import AsyncClient -from tests.utils import asyncio_patch -from unittest.mock import patch, MagicMock from gns3server.compute.project import Project +from tests.utils import asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/compute/test_virtualbox_nodes.py b/tests/api/routes/compute/test_virtualbox_nodes.py index 2de646193..7325805dd 100644 --- a/tests/api/routes/compute/test_virtualbox_nodes.py +++ b/tests/api/routes/compute/test_virtualbox_nodes.py @@ -14,15 +14,15 @@ # 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 fastapi import FastAPI, status -from httpx import AsyncClient -from tests.utils import asyncio_patch from unittest.mock import patch +import pytest +import pytest_asyncio +from fastapi import FastAPI, status +from httpx import AsyncClient + from gns3server.compute.project import Project +from tests.utils import asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/compute/test_vmware_nodes.py b/tests/api/routes/compute/test_vmware_nodes.py index df485774a..b1b4d419d 100644 --- a/tests/api/routes/compute/test_vmware_nodes.py +++ b/tests/api/routes/compute/test_vmware_nodes.py @@ -14,15 +14,15 @@ # 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 fastapi import FastAPI, status -from httpx import AsyncClient -from tests.utils import asyncio_patch from unittest.mock import patch +import pytest +import pytest_asyncio +from fastapi import FastAPI, status +from httpx import AsyncClient + from gns3server.compute.project import Project +from tests.utils import asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/compute/test_vpcs_nodes.py b/tests/api/routes/compute/test_vpcs_nodes.py index fd558d9a9..3fd03cfe6 100644 --- a/tests/api/routes/compute/test_vpcs_nodes.py +++ b/tests/api/routes/compute/test_vpcs_nodes.py @@ -14,15 +14,15 @@ # 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 fastapi import FastAPI, status -from httpx import AsyncClient -from tests.utils import asyncio_patch from unittest.mock import patch +import pytest +import pytest_asyncio +from fastapi import FastAPI, status +from httpx import AsyncClient + from gns3server.compute.project import Project +from tests.utils import asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_access_tickets.py b/tests/api/routes/controller/test_access_tickets.py index b70f135b5..c2fb634cd 100644 --- a/tests/api/routes/controller/test_access_tickets.py +++ b/tests/api/routes/controller/test_access_tickets.py @@ -33,9 +33,9 @@ from gns3server.controller.node import Node from gns3server.controller.project import Project from gns3server.services import access_ticket_service from gns3server.services.access_tickets import ( - AccessTicketService, DEFAULT_TICKET_TTL, TICKET_PREFIX, + AccessTicketService, ) from gns3server.utils.http_client import HTTPClient from tests.api.routes.controller.test_nodes import FakeComputeConsoleWebSocket diff --git a/tests/api/routes/controller/test_acl.py b/tests/api/routes/controller/test_acl.py index ed1fee046..e8f015a7a 100644 --- a/tests/api/routes/controller/test_acl.py +++ b/tests/api/routes/controller/test_acl.py @@ -17,16 +17,15 @@ import pytest import pytest_asyncio - from fastapi import FastAPI, status from httpx import AsyncClient - from sqlalchemy.ext.asyncio import AsyncSession -from gns3server.db.repositories.users import UsersRepository -from gns3server.db.repositories.rbac import RbacRepository -from gns3server.schemas.controller.users import User -from gns3server.schemas.controller.rbac import ACECreate + from gns3server.controller import Controller +from gns3server.db.repositories.rbac import RbacRepository +from gns3server.db.repositories.users import UsersRepository +from gns3server.schemas.controller.rbac import ACECreate +from gns3server.schemas.controller.users import User pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_appliances.py b/tests/api/routes/controller/test_appliances.py index c37f18ddd..94e7673f7 100644 --- a/tests/api/routes/controller/test_appliances.py +++ b/tests/api/routes/controller/test_appliances.py @@ -16,11 +16,12 @@ # along with this program. If not, see . import os -import pytest import shutil +import pytest from fastapi import FastAPI, status from httpx import AsyncClient + from gns3server.controller import Controller pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_computes.py b/tests/api/routes/controller/test_computes.py index ea2317821..3c213c07c 100644 --- a/tests/api/routes/controller/test_computes.py +++ b/tests/api/routes/controller/test_computes.py @@ -16,9 +16,9 @@ # along with this program. If not, see . import uuid -import pytest from unittest.mock import MagicMock, patch +import pytest from fastapi import FastAPI, status from httpx import AsyncClient @@ -26,7 +26,7 @@ from gns3server.schemas.controller.computes import Compute pytestmark = pytest.mark.asyncio -from tests.utils import asyncio_patch, AsyncioMagicMock +from tests.utils import AsyncioMagicMock, asyncio_patch class TestComputeRoutes: diff --git a/tests/api/routes/controller/test_controller.py b/tests/api/routes/controller/test_controller.py index b71a9cf2c..4ef729543 100644 --- a/tests/api/routes/controller/test_controller.py +++ b/tests/api/routes/controller/test_controller.py @@ -16,11 +16,11 @@ # along with this program. If not, see . import os -import pytest +from unittest.mock import MagicMock +import pytest from fastapi import FastAPI, status from httpx import AsyncClient -from unittest.mock import MagicMock from gns3server.config import Config diff --git a/tests/api/routes/controller/test_drawings.py b/tests/api/routes/controller/test_drawings.py index 2096df27a..955b46f86 100644 --- a/tests/api/routes/controller/test_drawings.py +++ b/tests/api/routes/controller/test_drawings.py @@ -15,7 +15,6 @@ # along with this program. If not, see . import pytest - from fastapi import FastAPI, status from httpx import AsyncClient diff --git a/tests/api/routes/controller/test_gns3vm.py b/tests/api/routes/controller/test_gns3vm.py index bf5db4141..c3782eb4d 100644 --- a/tests/api/routes/controller/test_gns3vm.py +++ b/tests/api/routes/controller/test_gns3vm.py @@ -15,9 +15,9 @@ # along with this program. If not, see . import pytest - from fastapi import FastAPI, status from httpx import AsyncClient + from tests.utils import asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_groups.py b/tests/api/routes/controller/test_groups.py index 69ff6183f..5451293f7 100644 --- a/tests/api/routes/controller/test_groups.py +++ b/tests/api/routes/controller/test_groups.py @@ -16,11 +16,10 @@ # along with this program. If not, see . import pytest - from fastapi import FastAPI, status from httpx import AsyncClient - from sqlalchemy.ext.asyncio import AsyncSession + from gns3server.db.repositories.users import UsersRepository from gns3server.schemas.controller.users import User, UserGroupCreate diff --git a/tests/api/routes/controller/test_images.py b/tests/api/routes/controller/test_images.py index ec498f763..c92cbefac 100644 --- a/tests/api/routes/controller/test_images.py +++ b/tests/api/routes/controller/test_images.py @@ -15,22 +15,21 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import os -import json -import uuid -import pytest import hashlib +import json +import os +import uuid -from tests.utils import asyncio_patch -from sqlalchemy.ext.asyncio import AsyncSession +import pytest from fastapi import FastAPI, status from httpx import AsyncClient -from tests.utils import AsyncioMagicMock +from sqlalchemy.ext.asyncio import AsyncSession +from gns3server.compute.qemu import Qemu from gns3server.controller import Controller from gns3server.db.repositories.images import ImagesRepository from gns3server.db.repositories.templates import TemplatesRepository -from gns3server.compute.qemu import Qemu +from tests.utils import AsyncioMagicMock, asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_links.py b/tests/api/routes/controller/test_links.py index d6af89d70..518eb22f9 100644 --- a/tests/api/routes/controller/test_links.py +++ b/tests/api/routes/controller/test_links.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 uuid -import pytest_asyncio - from typing import Tuple +from unittest.mock import MagicMock, patch + +import pytest +import pytest_asyncio from fastapi import FastAPI, status from httpx import AsyncClient -from unittest.mock import patch, MagicMock -from tests.utils import asyncio_patch, AsyncioMagicMock - -from gns3server.controller.project import Project from gns3server.controller.compute import Compute +from gns3server.controller.link import FILTERS, Link from gns3server.controller.node import Node from gns3server.controller.ports.ethernet_port import EthernetPort -from gns3server.controller.link import Link, FILTERS +from gns3server.controller.project import Project from gns3server.controller.udp_link import UDPLink +from tests.utils import AsyncioMagicMock, asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_marker_replay.py b/tests/api/routes/controller/test_marker_replay.py index 072190f4c..1ea9faab2 100644 --- a/tests/api/routes/controller/test_marker_replay.py +++ b/tests/api/routes/controller/test_marker_replay.py @@ -32,11 +32,10 @@ import pytest_asyncio from fastapi import FastAPI, status from httpx import AsyncClient +from gns3server.controller import marker_replay from gns3server.controller.project import Project from gns3server.controller.udp_link import UDPLink -from gns3server.controller import marker_replay - -from tests.controller.test_marker_replay import _write_pcap, _icmp_frame, _tcp_syn_frame, _cols +from tests.controller.test_marker_replay import _cols, _icmp_frame, _tcp_syn_frame, _write_pcap pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_markers.py b/tests/api/routes/controller/test_markers.py index 54e4dc8f0..b53ec8533 100644 --- a/tests/api/routes/controller/test_markers.py +++ b/tests/api/routes/controller/test_markers.py @@ -23,10 +23,9 @@ import pytest from fastapi import FastAPI, status from httpx import AsyncClient -from tests.utils import asyncio_patch - from gns3server.controller.project import Project from gns3server.controller.udp_link import UDPLink +from tests.utils import asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_netmiko.py b/tests/api/routes/controller/test_netmiko.py index 6384161bb..a0acc9f12 100644 --- a/tests/api/routes/controller/test_netmiko.py +++ b/tests/api/routes/controller/test_netmiko.py @@ -16,7 +16,6 @@ import pytest - from fastapi import FastAPI, status from httpx import AsyncClient diff --git a/tests/api/routes/controller/test_nodes.py b/tests/api/routes/controller/test_nodes.py index 017e65783..a2d37922a 100644 --- a/tests/api/routes/controller/test_nodes.py +++ b/tests/api/routes/controller/test_nodes.py @@ -18,31 +18,28 @@ import asyncio import contextlib import logging +from types import SimpleNamespace +from typing import List, Optional +from unittest.mock import MagicMock, patch import aiohttp import pytest - -from types import SimpleNamespace -from typing import List, Optional - from fastapi import FastAPI, HTTPException, WebSocketDisconnect, status from httpx import AsyncClient -from pydantic import SecretStr -from httpx_ws import aconnect_ws from httpx_ws import WebSocketDisconnect as HttpxWebSocketDisconnect -from httpx_ws.transport import ASGIWebSocketTransport, ASGIWebSocketAsyncNetworkStream - -from unittest.mock import MagicMock, patch -from tests.utils import AsyncioMagicMock +from httpx_ws import aconnect_ws +from httpx_ws.transport import ASGIWebSocketAsyncNetworkStream, ASGIWebSocketTransport +from pydantic import SecretStr +from gns3server.api.routes.controller.nodes import vnc_console, ws_console from gns3server.config import Config +from gns3server.controller.compute import Compute from gns3server.controller.node import Node from gns3server.controller.project import Project -from gns3server.controller.compute import Compute -from gns3server.utils.http_client import HTTPClient -from gns3server.api.routes.controller.nodes import ws_console, vnc_console from gns3server.services import auth_service from gns3server.services.authentication import DEFAULT_JWT_SECRET_KEY +from gns3server.utils.http_client import HTTPClient +from tests.utils import AsyncioMagicMock pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_pools.py b/tests/api/routes/controller/test_pools.py index f3b78cccb..2a505c63c 100644 --- a/tests/api/routes/controller/test_pools.py +++ b/tests/api/routes/controller/test_pools.py @@ -16,16 +16,16 @@ # along with this program. If not, see . import uuid + import pytest import pytest_asyncio - from fastapi import FastAPI, status from httpx import AsyncClient - from sqlalchemy.ext.asyncio import AsyncSession -from gns3server.db.repositories.pools import ResourcePoolsRepository + from gns3server.controller import Controller from gns3server.controller.project import Project +from gns3server.db.repositories.pools import ResourcePoolsRepository from gns3server.schemas.controller.pools import ResourceCreate, ResourcePoolCreate pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_projects.py b/tests/api/routes/controller/test_projects.py index 0d840a41c..3ae35c689 100644 --- a/tests/api/routes/controller/test_projects.py +++ b/tests/api/routes/controller/test_projects.py @@ -14,21 +14,21 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import uuid -import os import json +import os +import uuid +from unittest.mock import MagicMock, patch + import pytest import pytest_asyncio - from fastapi import FastAPI, status from httpx import AsyncClient -from unittest.mock import patch, MagicMock -from tests.utils import asyncio_patch, AsyncioMagicMock import gns3server.utils.zipfile_zstd as zipfile_zstd from gns3server.controller import Controller -from gns3server.controller.project import Project from gns3server.controller.compute import Compute +from gns3server.controller.project import Project +from tests.utils import AsyncioMagicMock, asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_roles.py b/tests/api/routes/controller/test_roles.py index bdc6f6651..45676a8fb 100644 --- a/tests/api/routes/controller/test_roles.py +++ b/tests/api/routes/controller/test_roles.py @@ -16,11 +16,10 @@ # along with this program. If not, see . import pytest - from fastapi import FastAPI, status from httpx import AsyncClient - from sqlalchemy.ext.asyncio import AsyncSession + from gns3server.db.repositories.rbac import RbacRepository pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_settings.py b/tests/api/routes/controller/test_settings.py index e23d0606c..f7500a295 100644 --- a/tests/api/routes/controller/test_settings.py +++ b/tests/api/routes/controller/test_settings.py @@ -14,11 +14,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import os import configparser +import os import pytest - from fastapi import FastAPI, status from httpx import AsyncClient diff --git a/tests/api/routes/controller/test_snapshots.py b/tests/api/routes/controller/test_snapshots.py index 1c2f60a5e..5e0faf1f4 100644 --- a/tests/api/routes/controller/test_snapshots.py +++ b/tests/api/routes/controller/test_snapshots.py @@ -17,9 +17,9 @@ import os import uuid + import pytest import pytest_asyncio - from fastapi import FastAPI, status from httpx import AsyncClient diff --git a/tests/api/routes/controller/test_symbols.py b/tests/api/routes/controller/test_symbols.py index 97f80889e..17446443b 100644 --- a/tests/api/routes/controller/test_symbols.py +++ b/tests/api/routes/controller/test_symbols.py @@ -15,10 +15,10 @@ # along with this program. If not, see . -import pytest import os import urllib.parse +import pytest from fastapi import FastAPI, status from httpx import AsyncClient diff --git a/tests/api/routes/controller/test_templates.py b/tests/api/routes/controller/test_templates.py index 864cc1d57..34e60ef2d 100644 --- a/tests/api/routes/controller/test_templates.py +++ b/tests/api/routes/controller/test_templates.py @@ -15,27 +15,25 @@ # 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 shutil +import unittest.mock +import uuid +from pathlib import Path import pytest -import uuid -import unittest.mock - -from pathlib import Path from fastapi import FastAPI, status from httpx import AsyncClient from sqlalchemy.ext.asyncio import AsyncSession -from tests.utils import asyncio_patch +from gns3server import schemas +from gns3server.api.routes.controller.dependencies.authentication import get_current_active_user +from gns3server.controller import Config, Controller from gns3server.db.repositories.images import ImagesRepository from gns3server.db.repositories.templates import TemplatesRepository -from gns3server.controller import Controller -from gns3server.controller import Config from gns3server.services.templates import BUILTIN_TEMPLATES -from gns3server.api.routes.controller.dependencies.authentication import get_current_active_user -from gns3server import schemas +from tests.utils import asyncio_patch pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_users.py b/tests/api/routes/controller/test_users.py index 8bdf437ad..0eb708139 100644 --- a/tests/api/routes/controller/test_users.py +++ b/tests/api/routes/controller/test_users.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 pytest - from typing import Optional + +import pytest from fastapi import FastAPI, HTTPException, status -from sqlalchemy import update from httpx import AsyncClient from joserfc import jwt from joserfc.jwk import OctKey - +from sqlalchemy import update from sqlalchemy.ext.asyncio import AsyncSession -from gns3server.db.repositories.users import UsersRepository -from gns3server.services import auth_service -from gns3server.config import Config -from gns3server.schemas.controller.users import User + import gns3server.db.models as models +from gns3server.config import Config +from gns3server.db.repositories.users import UsersRepository +from gns3server.schemas.controller.users import User +from gns3server.services import auth_service pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_version.py b/tests/api/routes/controller/test_version.py index c7220ed62..b0ea854aa 100644 --- a/tests/api/routes/controller/test_version.py +++ b/tests/api/routes/controller/test_version.py @@ -15,7 +15,6 @@ # along with this program. If not, see . import pytest - from fastapi import FastAPI, status from httpx import AsyncClient diff --git a/tests/api/routes/test_index.py b/tests/api/routes/test_index.py index df3c242b1..8a99c0d54 100644 --- a/tests/api/routes/test_index.py +++ b/tests/api/routes/test_index.py @@ -14,16 +14,16 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import pytest import os - -from fastapi import FastAPI, status -from httpx import AsyncClient from unittest.mock import patch -from gns3server.version import __version__ +import pytest +from fastapi import FastAPI, status +from httpx import AsyncClient + from gns3server.controller import Controller from gns3server.utils.get_resource import get_resource +from gns3server.version import __version__ pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/test_routes.py b/tests/api/routes/test_routes.py index e43a8c557..296cd679d 100644 --- a/tests/api/routes/test_routes.py +++ b/tests/api/routes/test_routes.py @@ -14,15 +14,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from typing import Iterator, Sequence, Tuple + import pytest from fastapi import FastAPI, status from fastapi.routing import APIRoute, APIWebSocketRoute, _IncludedRouter -from starlette.routing import BaseRoute, Mount from httpx import AsyncClient from httpx_ws import aconnect_ws from httpx_ws.transport import ASGIWebSocketTransport -from typing import Iterator, Sequence, Tuple - +from starlette.routing import BaseRoute, Mount pytestmark = pytest.mark.asyncio