Skip to content

Commit

Permalink
fixes app fixutre
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Sep 11, 2023
1 parent aaf88ea commit 39ed7e8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
17 changes: 0 additions & 17 deletions services/payments/tests/unit/api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 12 additions & 0 deletions services/payments/tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
10 changes: 8 additions & 2 deletions services/payments/tests/unit/test_services_payments_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# pylint: disable=too-many-arguments


from typing import Iterator
from typing import Callable, Iterator

import httpx
import pytest
Expand All @@ -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,
Expand All @@ -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(
Expand Down

0 comments on commit 39ed7e8

Please sign in to comment.