Skip to content

Commit

Permalink
🔨 Removes respx library from base requirements listing (`fastapi.in…
Browse files Browse the repository at this point in the history
…`) (#5003)
  • Loading branch information
pcrespov authored Nov 9, 2023
1 parent da3e254 commit b766776
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 19 deletions.
1 change: 0 additions & 1 deletion packages/service-library/requirements/_fastapi.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@

fastapi
httpx
respx
uvicorn
3 changes: 0 additions & 3 deletions packages/service-library/requirements/_fastapi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ httpx==0.25.0
# -c requirements/./../../../packages/settings-library/requirements/../../../requirements/constraints.txt
# -c requirements/./../../../requirements/constraints.txt
# -r requirements/_fastapi.in
# respx
idna==3.4
# via
# anyio
Expand Down Expand Up @@ -85,8 +84,6 @@ referencing==0.29.3
# -c requirements/././constraints.txt
# jsonschema
# jsonschema-specifications
respx==0.20.2
# via -r requirements/_fastapi.in
rich==13.6.0
# via -r requirements/./../../../packages/settings-library/requirements/_base.in
rpds-py==0.10.6
Expand Down
1 change: 1 addition & 0 deletions packages/service-library/requirements/_test.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ coverage
docker
faker
flaky
respx
openapi-spec-validator
pytest
pytest-aiohttp # incompatible with pytest-asyncio. See https://github.com/pytest-dev/pytest-asyncio/issues/76
Expand Down
27 changes: 27 additions & 0 deletions packages/service-library/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ aiosignal==1.3.1
# -c requirements/_aiohttp.txt
# -c requirements/_base.txt
# aiohttp
anyio==4.0.0
# via
# -c requirements/_fastapi.txt
# httpcore
asgi-lifespan==2.1.0
# via -r requirements/_test.in
async-timeout==4.0.3
Expand All @@ -36,6 +40,8 @@ certifi==2023.7.22
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_aiohttp.txt
# -c requirements/_fastapi.txt
# httpcore
# httpx
# requests
charset-normalizer==3.3.2
# via
Expand All @@ -52,6 +58,7 @@ docker==6.1.3
exceptiongroup==1.1.3
# via
# -c requirements/_fastapi.txt
# anyio
# pytest
execnet==2.0.2
# via pytest-xdist
Expand All @@ -65,11 +72,26 @@ frozenlist==1.4.0
# -c requirements/_base.txt
# aiohttp
# aiosignal
h11==0.14.0
# via
# -c requirements/_fastapi.txt
# httpcore
httpcore==0.18.0
# via
# -c requirements/_fastapi.txt
# httpx
httpx==0.25.0
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_fastapi.txt
# respx
idna==3.4
# via
# -c requirements/_aiohttp.txt
# -c requirements/_base.txt
# -c requirements/_fastapi.txt
# anyio
# httpx
# requests
# yarl
iniconfig==2.0.0
Expand Down Expand Up @@ -182,6 +204,8 @@ requests==2.31.0
# -c requirements/_aiohttp.txt
# docker
# jsonschema-spec
respx==0.20.2
# via -r requirements/_test.in
rfc3339-validator==0.1.4
# via
# -c requirements/_aiohttp.txt
Expand All @@ -203,7 +227,10 @@ six==1.16.0
sniffio==1.3.0
# via
# -c requirements/_fastapi.txt
# anyio
# asgi-lifespan
# httpcore
# httpx
termcolor==2.3.0
# via pytest-sugar
tomli==2.0.1
Expand Down
7 changes: 1 addition & 6 deletions services/clusters-keeper/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ aio-pika==9.3.0
aioboto3==12.0.0
# via -r requirements/_base.in
aiobotocore==2.7.0
# via
# aioboto3
# aiobotocore
# via aioboto3
aiodebug==2.3.0
# via
# -c requirements/../../../packages/service-library/requirements/./_base.in
Expand Down Expand Up @@ -155,7 +153,6 @@ httpx==0.25.1
# -c requirements/../../../packages/settings-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../requirements/constraints.txt
# -r requirements/../../../packages/service-library/requirements/_fastapi.in
# respx
idna==3.4
# via
# anyio
Expand Down Expand Up @@ -297,8 +294,6 @@ referencing==0.29.3
# -c requirements/../../../packages/service-library/requirements/./constraints.txt
# jsonschema
# jsonschema-specifications
respx==0.20.2
# via -r requirements/../../../packages/service-library/requirements/_fastapi.in
rich==13.6.0
# via
# -r requirements/../../../packages/service-library/requirements/../../../packages/settings-library/requirements/_base.in
Expand Down
8 changes: 2 additions & 6 deletions services/clusters-keeper/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,7 @@ python-dateutil==2.8.2
python-dotenv==1.0.0
# via -r requirements/_test.in
python-jose==3.3.0
# via
# moto
# python-jose
# via moto
pyyaml==6.0.1
# via
# -c requirements/../../../requirements/constraints.txt
Expand Down Expand Up @@ -297,9 +295,7 @@ requests==2.31.0
responses==0.24.0
# via moto
respx==0.20.2
# via
# -c requirements/_base.txt
# -r requirements/_test.in
# via -r requirements/_test.in
rfc3339-validator==0.1.4
# via openapi-schema-validator
rpds-py==0.12.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def _startup() -> None:

def on_app_shutdown(app: FastAPI) -> Callable[[], Awaitable[None]]:
async def _stop() -> None:
await stop_periodic_task(app.state.clusters_cleaning_task)
await stop_periodic_task(app.state.clusters_cleaning_task, timeout=5)

return _stop

Expand Down
2 changes: 1 addition & 1 deletion services/clusters-keeper/tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def enabled_rabbitmq(
async def initialized_app(app_environment: EnvVarsDict) -> AsyncIterator[FastAPI]:
settings = ApplicationSettings.create_from_envs()
app = create_app(settings)
async with LifespanManager(app):
async with LifespanManager(app, shutdown_timeout=20):
yield app


Expand Down
36 changes: 36 additions & 0 deletions tests/environment-setup/test_requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import re
import sys
from pathlib import Path

import pytest

CURRENT_DIR = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent
REPO_DIR = CURRENT_DIR.parent.parent
assert any(REPO_DIR.glob(".git"))

SERVICES_DIR = REPO_DIR / "services"
assert SERVICES_DIR.exists()


@pytest.mark.parametrize(
"exclude",
[
"aioresponses",
"coverage",
"flaky",
"hypothesis",
"pytest", # NOTE: this includes all pytest plugins since they are named as pytest-*
"moto",
"respx",
],
)
@pytest.mark.parametrize(
"base_path",
SERVICES_DIR.rglob("_base.txt"),
ids=lambda p: f"{p.relative_to(SERVICES_DIR)}",
)
def test_libraries_are_not_allowed_in_base_requirements(base_path: Path, exclude: str):
requirements_text = re.sub(
r"(^|\s)(#.*|\n)", "", base_path.read_text().lower(), flags=re.MULTILINE
)
assert exclude not in requirements_text
2 changes: 1 addition & 1 deletion tests/environment-setup/test_used_docker_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import shutil
import subprocess
import sys
from collections.abc import Iterable
from itertools import chain
from pathlib import Path
from typing import Iterable

import pytest
import yaml
Expand Down

0 comments on commit b766776

Please sign in to comment.