From 6b8ce8219c0420dacdbdd47762a42b584f22345d Mon Sep 17 00:00:00 2001 From: grossmj Date: Thu, 15 Apr 2021 18:30:22 +0930 Subject: [PATCH] Fix tests. --- tests/api/routes/compute/test_virtualbox_nodes.py | 13 ++++++------- tests/api/routes/compute/test_vmware_nodes.py | 14 ++++++-------- tests/api/routes/controller/test_computes.py | 2 +- tests/api/routes/controller/test_users.py | 2 +- tests/conftest.py | 2 +- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/tests/api/routes/compute/test_virtualbox_nodes.py b/tests/api/routes/compute/test_virtualbox_nodes.py index bff6aa95b..5ff06722c 100644 --- a/tests/api/routes/compute/test_virtualbox_nodes.py +++ b/tests/api/routes/compute/test_virtualbox_nodes.py @@ -75,14 +75,13 @@ async def test_vbox_get(app: FastAPI, client: AsyncClient, compute_project: Proj async def test_vbox_start(app: FastAPI, client: AsyncClient, vm: dict) -> None: - with asyncio_patch("gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.check_hw_virtualization", return_value=True): - with asyncio_patch("gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.start", return_value=True) as mock: + with asyncio_patch("gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.start", return_value=True) as mock: - response = await client.post(app.url_path_for("start_virtualbox_node", - project_id=vm["project_id"], - node_id=vm["node_id"])) - assert mock.called - assert response.status_code == status.HTTP_204_NO_CONTENT + response = await client.post(app.url_path_for("start_virtualbox_node", + project_id=vm["project_id"], + node_id=vm["node_id"])) + assert mock.called + assert response.status_code == status.HTTP_204_NO_CONTENT async def test_vbox_stop(app: FastAPI, client: AsyncClient, vm: dict) -> None: diff --git a/tests/api/routes/compute/test_vmware_nodes.py b/tests/api/routes/compute/test_vmware_nodes.py index f3e8783ae..a32d43747 100644 --- a/tests/api/routes/compute/test_vmware_nodes.py +++ b/tests/api/routes/compute/test_vmware_nodes.py @@ -82,14 +82,12 @@ async def test_vmware_get(app: FastAPI, client: AsyncClient, compute_project: Pr async def test_vmware_start(app: FastAPI, client: AsyncClient, vm: dict) -> None: - with asyncio_patch("gns3server.compute.vmware.vmware_vm.VMwareVM.check_hw_virtualization", return_value=True) as mock1: - with asyncio_patch("gns3server.compute.vmware.vmware_vm.VMwareVM.start", return_value=True) as mock2: - response = await client.post(app.url_path_for("start_vmware_node", - project_id=vm["project_id"], - node_id=vm["node_id"])) - assert mock1.called - assert mock2.called - assert response.status_code == status.HTTP_204_NO_CONTENT + with asyncio_patch("gns3server.compute.vmware.vmware_vm.VMwareVM.start", return_value=True) as mock: + response = await client.post(app.url_path_for("start_vmware_node", + project_id=vm["project_id"], + node_id=vm["node_id"])) + assert mock.called + assert response.status_code == status.HTTP_204_NO_CONTENT async def test_vmware_stop(app: FastAPI, client: AsyncClient, vm: dict) -> None: diff --git a/tests/api/routes/controller/test_computes.py b/tests/api/routes/controller/test_computes.py index 6cb7040b2..0e2c0e69d 100644 --- a/tests/api/routes/controller/test_computes.py +++ b/tests/api/routes/controller/test_computes.py @@ -21,7 +21,7 @@ import pytest from fastapi import FastAPI, status from httpx import AsyncClient -from gns3server.schemas.computes import Compute +from gns3server.schemas.controller.computes import Compute pytestmark = pytest.mark.asyncio diff --git a/tests/api/routes/controller/test_users.py b/tests/api/routes/controller/test_users.py index 32041cb0c..f8ad92f06 100644 --- a/tests/api/routes/controller/test_users.py +++ b/tests/api/routes/controller/test_users.py @@ -27,7 +27,7 @@ from gns3server.db.repositories.users import UsersRepository from gns3server.services import auth_service from gns3server.services.authentication import DEFAULT_JWT_SECRET_KEY from gns3server.config import Config -from gns3server.schemas.users import User +from gns3server.schemas.controller.users import User pytestmark = pytest.mark.asyncio diff --git a/tests/conftest.py b/tests/conftest.py index 7996955c5..f54c1422d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -23,7 +23,7 @@ from gns3server.db.repositories.users import UsersRepository from gns3server.db.repositories.computes import ComputesRepository from gns3server.api.routes.controller.dependencies.database import get_db_session from gns3server import schemas -from gns3server.schemas.computes import Protocol +from gns3server.schemas.controller.computes import Protocol from gns3server.services import auth_service from gns3server.services.authentication import DEFAULT_JWT_SECRET_KEY