From 39ed7e802a0a37a0b808ba1fde57a6e142f66d75 Mon Sep 17 00:00:00 2001 From: Pedro Crespo <32402063+pcrespov@users.noreply.github.com> Date: Mon, 11 Sep 2023 15:48:32 +0200 Subject: [PATCH] fixes app fixutre --- services/payments/tests/unit/api/conftest.py | 17 ----------------- services/payments/tests/unit/conftest.py | 12 ++++++++++++ .../unit/test_services_payments_gateway.py | 10 ++++++++-- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/services/payments/tests/unit/api/conftest.py b/services/payments/tests/unit/api/conftest.py index 904179b55f00..1248a8477a96 100644 --- a/services/payments/tests/unit/api/conftest.py +++ b/services/payments/tests/unit/api/conftest.py @@ -13,26 +13,9 @@ from asgi_lifespan import LifespanManager from fastapi import FastAPI, status from httpx._transports.asgi import ASGITransport -from pytest_mock import MockerFixture from simcore_service_payments.core.settings import ApplicationSettings from simcore_service_payments.models.schemas.auth import Token -# pylint: disable=protected-access -# pylint: disable=redefined-outer-name -# pylint: disable=too-many-arguments -# pylint: disable=unused-argument -# pylint: disable=unused-variable - - -@pytest.fixture -def disable_rabbitmq_service(mocker: MockerFixture) -> Callable: - def _doit(): - # The following moduls are affected if rabbitmq is not in place - mocker.patch("simcore_service_payments.core.application.setup_rabbitmq") - mocker.patch("simcore_service_payments.core.application.setup_rpc_routes") - - return _doit - @pytest.fixture async def client( diff --git a/services/payments/tests/unit/conftest.py b/services/payments/tests/unit/conftest.py index 776309c1a5c4..43d5dcf0f53b 100644 --- a/services/payments/tests/unit/conftest.py +++ b/services/payments/tests/unit/conftest.py @@ -6,14 +6,26 @@ from collections.abc import AsyncIterator +from typing import Callable import pytest from asgi_lifespan import LifespanManager from fastapi import FastAPI +from pytest_mock import MockerFixture from pytest_simcore.helpers.typing_env import EnvVarsDict from simcore_service_payments.core.application import create_app +@pytest.fixture +def disable_rabbitmq_service(mocker: MockerFixture) -> Callable: + def _doit(): + # The following moduls are affected if rabbitmq is not in place + mocker.patch("simcore_service_payments.core.application.setup_rabbitmq") + mocker.patch("simcore_service_payments.core.application.setup_rpc_api_routes") + + return _doit + + @pytest.fixture def app(app_environment: EnvVarsDict) -> FastAPI: """Inits app on a light environment""" diff --git a/services/payments/tests/unit/test_services_payments_gateway.py b/services/payments/tests/unit/test_services_payments_gateway.py index 27124cda2dd5..bf40ea1d23f7 100644 --- a/services/payments/tests/unit/test_services_payments_gateway.py +++ b/services/payments/tests/unit/test_services_payments_gateway.py @@ -4,7 +4,7 @@ # pylint: disable=too-many-arguments -from typing import Iterator +from typing import Callable, Iterator import httpx import pytest @@ -14,6 +14,7 @@ from fastapi.encoders import jsonable_encoder from pytest_simcore.helpers.utils_envs import EnvVarsDict from respx import MockRouter +from simcore_service_payments.core.application import create_app from simcore_service_payments.core.settings import ApplicationSettings from simcore_service_payments.models.payments_gateway import ( InitPayment, @@ -34,10 +35,15 @@ async def test_setup_payment_gateway_api(app_environment: EnvVarsDict): assert payment_gateway_api is not None +@pytest.fixture +def app(disable_rabbitmq_service: Callable, app_environment: EnvVarsDict): + disable_rabbitmq_service() + return create_app() + + @pytest.fixture def mock_payments_gateway_service_api_base( app: FastAPI, - faker: Faker, ) -> Iterator[MockRouter]: settings: ApplicationSettings = app.state.settings with respx.mock(