diff --git a/requirements-dev.txt b/requirements-dev.txt index 8420e0cc..5f23ea69 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,7 @@ # uv pip compile requirements-dev.in -o requirements-dev.txt aiohappyeyeballs==2.6.1 # via aiohttp -aiohttp==3.12.14 +aiohttp==3.13.2 # via # aiohttp-jinja2 # textual-dev @@ -13,42 +13,44 @@ aiosignal==1.4.0 # via aiohttp annotated-types==0.7.0 # via pydantic -anyio==4.9.0 +anyio==4.12.0 # via # asyncer # httpx # watchfiles asgi-lifespan==2.1.0 # via -r requirements-dev.in -asttokens==3.0.0 +asttokens==3.0.1 # via stack-data -asyncer==0.0.8 +asyncer==0.0.11 # via -r requirements-dev.in -attrs==25.3.0 +attrs==25.4.0 # via aiohttp +backports-zstd==1.2.0 + # via hatch bidict==0.23.1 # via python-socketio -black==25.1.0 +black==25.12.0 # via -r requirements-dev.in blinker==1.9.0 # via flask -brotli==1.1.0 +brotli==1.2.0 # via geventhttpclient bunnet==1.3.0 # via -r requirements-dev.in -certifi==2025.7.14 +certifi==2025.11.12 # via # geventhttpclient # httpcore # httpx # requests -cffi==1.17.1 +cffi==2.0.0 # via cryptography -cfgv==3.4.0 +cfgv==3.5.0 # via pre-commit -charset-normalizer==3.4.2 +charset-normalizer==3.4.4 # via requests -click==8.2.1 +click==8.3.1 # via # black # bunnet @@ -63,23 +65,23 @@ configargparse==1.7.1 # via # locust # locust-cloud -coverage==7.9.2 +coverage==7.13.0 # via -r requirements-dev.in -cryptography==45.0.6 +cryptography==46.0.3 # via secretstorage decorator==5.2.1 # via ipython distlib==0.4.0 # via virtualenv -dnspython==2.7.0 +dnspython==2.8.0 # via pymongo -executing==2.2.0 +executing==2.2.1 # via stack-data -fastapi-cli==0.0.8 +fastapi-cli==0.0.16 # via -r requirements-dev.in -filelock==3.18.0 +filelock==3.20.0 # via virtualenv -flask==3.1.1 +flask==3.1.2 # via # flask-cors # flask-login @@ -88,31 +90,31 @@ flask-cors==6.0.1 # via locust flask-login==0.6.3 # via locust -frozenlist==1.7.0 +frozenlist==1.8.0 # via # aiohttp # aiosignal -gevent==25.5.1 +gevent==25.9.1 # via # geventhttpclient # locust # locust-cloud -geventhttpclient==2.3.4 +geventhttpclient==2.3.7 # via locust -greenlet==3.2.3 +greenlet==3.3.0 # via gevent h11==0.16.0 # via # httpcore # uvicorn # wsproto -hatch==1.14.1 +hatch==1.16.2 # via -r requirements-dev.in hatch-requirements-txt==0.4.1 # via -r requirements-dev.in hatch-vcs==0.5.0 # via -r requirements-dev.in -hatchling==1.27.0 +hatchling==1.28.0 # via # -r requirements-dev.in # hatch @@ -120,24 +122,24 @@ hatchling==1.27.0 # hatch-vcs httpcore==1.0.9 # via httpx -httptools==0.6.4 +httptools==0.7.1 # via uvicorn httpx==0.28.1 # via hatch hyperlink==21.0.0 # via hatch -identify==2.6.12 +identify==2.6.15 # via pre-commit -idna==3.10 +idna==3.11 # via # anyio # httpx # hyperlink # requests # yarl -iniconfig==2.1.0 +iniconfig==2.3.0 # via pytest -ipython==9.4.0 +ipython==9.8.0 # via -r requirements-dev.in ipython-pygments-lexers==1.1.1 # via ipython @@ -147,7 +149,7 @@ jaraco-classes==3.4.0 # via keyring jaraco-context==6.0.1 # via keyring -jaraco-functools==4.2.1 +jaraco-functools==4.3.0 # via keyring jedi==0.19.2 # via ipython @@ -160,41 +162,41 @@ jinja2==3.1.6 # aiohttp-jinja2 # flask # textual-serve -keyring==25.6.0 +keyring==25.7.0 # via hatch lazy-model==0.2.0 # via bunnet linkify-it-py==2.0.3 # via markdown-it-py -locust==2.37.14 +locust==2.42.6 # via -r requirements-dev.in -locust-cloud==1.26.3 +locust-cloud==1.29.5 # via locust -markdown-it-py[linkify,plugins]==3.0.0 +markdown-it-py==4.0.0 # via # mdit-py-plugins # rich # textual -markupsafe==3.0.2 +markupsafe==3.0.3 # via # flask # jinja2 # werkzeug -matplotlib-inline==0.1.7 +matplotlib-inline==0.2.1 # via ipython -mdit-py-plugins==0.4.2 - # via markdown-it-py +mdit-py-plugins==0.5.0 + # via textual mdurl==0.1.2 # via markdown-it-py -more-itertools==10.7.0 +more-itertools==10.8.0 # via # jaraco-classes # jaraco-functools -msgpack==1.1.1 +msgpack==1.1.2 # via # locust # textual-dev -multidict==6.6.3 +multidict==6.7.0 # via # aiohttp # yarl @@ -212,7 +214,7 @@ packaging==25.0 # hatchling # pytest # setuptools-scm -parso==0.8.4 +parso==0.8.5 # via jedi pathspec==0.12.1 # via @@ -222,7 +224,7 @@ pexpect==4.9.0 # via # hatch # ipython -platformdirs==4.3.8 +platformdirs==4.5.1 # via # black # hatch @@ -233,29 +235,29 @@ pluggy==1.6.0 # via # hatchling # pytest -pre-commit==4.2.0 +pre-commit==4.5.0 # via pre-commit-uv -pre-commit-uv==4.1.4 +pre-commit-uv==4.2.0 # via -r requirements-dev.in -prompt-toolkit==3.0.51 +prompt-toolkit==3.0.52 # via ipython -propcache==0.3.2 +propcache==0.4.1 # via # aiohttp # yarl -psutil==7.0.0 +psutil==7.1.3 # via locust ptyprocess==0.7.0 # via pexpect pure-eval==0.2.3 # via stack-data -pycparser==2.22 +pycparser==2.23 # via cffi -pydantic==2.11.7 +pydantic==2.12.5 # via # bunnet # lazy-model -pydantic-core==2.33.2 +pydantic-core==2.41.5 # via pydantic pygments==2.19.2 # via @@ -263,48 +265,59 @@ pygments==2.19.2 # ipython-pygments-lexers # pytest # rich -pymongo==4.13.2 + # textual +pymongo==4.15.5 # via bunnet -pyright==1.1.403 +pyproject-hooks==1.2.0 + # via hatch +pyright==1.1.407 # via -r requirements-dev.in -pytest==8.4.1 +pytest==9.0.2 # via # -r requirements-dev.in + # locust # pytest-asyncio -pytest-asyncio==1.0.0 +pytest-asyncio==1.3.0 # via -r requirements-dev.in -python-dotenv==1.1.1 +python-dotenv==1.2.1 # via uvicorn -python-engineio==4.12.2 +python-engineio==4.12.3 # via + # locust # locust-cloud # python-socketio -python-socketio[client]==5.13.0 - # via locust-cloud -pyyaml==6.0.2 +python-socketio==5.15.0 + # via + # locust + # locust-cloud +pytokens==0.3.0 + # via black +pyyaml==6.0.3 # via # pre-commit # uvicorn -pyzmq==27.0.0 +pyzmq==27.1.0 # via locust requests==2.32.4 # via # locust # python-socketio -rich==14.0.0 +rich==14.2.0 # via # hatch # rich-toolkit # textual # textual-serve # typer -rich-toolkit==0.14.8 +rich-toolkit==0.17.0 # via fastapi-cli -ruff==0.12.4 +ruff==0.14.8 # via -r requirements-dev.in -secretstorage==3.3.3 +secretstorage==3.5.0 # via keyring -setuptools-scm==8.3.1 +setuptools==80.9.0 + # via setuptools-scm +setuptools-scm==9.2.2 # via hatch-vcs shellingham==1.5.4 # via @@ -314,17 +327,17 @@ simple-websocket==1.1.0 # via python-engineio sniffio==1.3.1 # via - # anyio # asgi-lifespan + # asyncer stack-data==0.6.3 # via ipython -textual==4.0.0 +textual==6.8.0 # via # textual-dev # textual-serve -textual-dev==1.7.0 +textual-dev==1.8.0 # via -r requirements-dev.in -textual-serve==1.1.2 +textual-serve==1.1.3 # via textual-dev toml==0.10.2 # via bunnet @@ -336,14 +349,12 @@ traitlets==5.14.3 # via # ipython # matplotlib-inline -trove-classifiers==2025.5.9.12 +trove-classifiers==2025.12.1.14 # via hatchling -typer==0.16.0 +typer==0.20.0 # via fastapi-cli -typing-extensions==4.14.1 +typing-extensions==4.15.0 # via - # aiosignal - # anyio # pydantic # pydantic-core # pyright @@ -352,50 +363,48 @@ typing-extensions==4.14.1 # textual-dev # typer # typing-inspection -typing-inspection==0.4.1 +typing-inspection==0.4.2 # via pydantic uc-micro-py==1.0.3 # via linkify-it-py -urllib3==2.5.0 +urllib3==2.6.1 # via # geventhttpclient # requests userpath==1.9.2 # via hatch -uv==0.9.5 +uv==0.9.16 # via # -r requirements-dev.in # hatch # pre-commit-uv -uvicorn[standard]==0.35.0 +uvicorn==0.38.0 # via fastapi-cli -uvloop==0.21.0 +uvloop==0.22.1 # via uvicorn -virtualenv==20.32.0 +virtualenv==20.35.4 # via # hatch # pre-commit -watchfiles==1.1.0 +watchfiles==1.1.1 # via uvicorn -wcwidth==0.2.13 +wcwidth==0.2.14 # via prompt-toolkit -websocket-client==1.8.0 +websocket-client==1.9.0 # via python-socketio websockets==15.0.1 # via uvicorn -werkzeug==3.1.3 +werkzeug==3.1.4 # via # flask # flask-cors # flask-login # locust -wsproto==1.2.0 +wsproto==1.3.2 # via simple-websocket -yarl==1.20.1 +yarl==1.22.0 # via aiohttp -zope-event==5.1.1 +zope-event==6.1 # via gevent -zope-interface==7.2 +zope-interface==8.1.1 # via gevent -zstandard==0.23.0 - # via hatch diff --git a/requirements.in b/requirements.in index be571861..6254cf81 100644 --- a/requirements.in +++ b/requirements.in @@ -9,7 +9,6 @@ httpx httpx-socks[asyncio] jinja2 jinja-partials -motor n2snusertools passlib prometheus-fastapi-instrumentator diff --git a/requirements.txt b/requirements.txt index f544b2bf..ce628f89 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,45 +1,45 @@ # This file was autogenerated by uv via the following command: # uv pip compile requirements.in -o requirements.txt -aiofiles==24.1.0 +aiofiles==25.1.0 # via -r requirements.in +annotated-doc==0.0.4 + # via fastapi annotated-types==0.7.0 # via pydantic -anyio==4.9.0 +anyio==4.12.0 # via # httpx # starlette argon2-cffi==25.1.0 # via -r requirements.in -argon2-cffi-bindings==21.2.0 +argon2-cffi-bindings==25.1.0 # via argon2-cffi asgi-correlation-id==4.3.4 # via -r requirements.in -async-timeout==5.0.1 - # via httpx-socks -beanie==1.30.0 +beanie==2.0.1 # via -r requirements.in -certifi==2025.7.14 +certifi==2025.11.12 # via # httpcore # httpx -cffi==1.17.1 +cffi==2.0.0 # via argon2-cffi-bindings -click==8.2.1 +click==8.3.1 # via # beanie # typer # uvicorn decorator==5.2.1 # via gssapi -dnspython==2.7.0 +dnspython==2.8.0 # via pymongo dunamai==1.25.0 # via uv-dynamic-versioning -faker==37.4.2 +faker==38.2.0 # via -r requirements.in -fastapi==0.116.1 +fastapi==0.124.0 # via -r requirements.in -gssapi==1.9.0 +gssapi==1.10.1 # via n2snusertools gunicorn==23.0.0 # via -r requirements.in @@ -47,7 +47,7 @@ h11==0.16.0 # via # httpcore # uvicorn -hatchling==1.27.0 +hatchling==1.28.0 # via uv-dynamic-versioning httpcore==1.0.9 # via @@ -57,9 +57,9 @@ httpx==0.28.1 # via # -r requirements.in # httpx-socks -httpx-socks==0.10.1 +httpx-socks==0.11.0 # via -r requirements.in -idna==3.10 +idna==3.11 # via # anyio # httpx @@ -70,29 +70,25 @@ jinja2==3.1.6 # -r requirements.in # jinja-partials # uv-dynamic-versioning -lazy-model==0.2.0 +lazy-model==0.4.0 # via beanie ldap3==2.9.1 # via n2snusertools linkify-it-py==2.0.3 # via markdown-it-py -markdown-it-py==3.0.0 +markdown-it-py==4.0.0 # via # mdit-py-plugins # rich # textual -markupsafe==3.0.2 +markupsafe==3.0.3 # via # jinja2 # werkzeug -mdit-py-plugins==0.4.2 - # via markdown-it-py +mdit-py-plugins==0.5.0 + # via textual mdurl==0.1.2 # via markdown-it-py -motor==3.7.1 - # via - # -r requirements.in - # beanie n2snusertools==0.3.10 # via -r requirements.in packaging==25.0 @@ -105,75 +101,76 @@ passlib==1.7.4 # via -r requirements.in pathspec==0.12.1 # via hatchling -platformdirs==4.3.8 +platformdirs==4.5.1 # via textual pluggy==1.6.0 # via hatchling -prettytable==3.16.0 +prettytable==3.17.0 # via n2snusertools -prometheus-client==0.22.1 +prometheus-client==0.23.1 # via prometheus-fastapi-instrumentator prometheus-fastapi-instrumentator==7.1.0 # via -r requirements.in pyasn1==0.6.1 # via ldap3 -pycparser==2.22 +pycparser==2.23 # via cffi -pydantic==2.11.7 +pydantic==2.12.5 # via # -r requirements.in # beanie # fastapi # lazy-model # pydantic-settings - # uv-dynamic-versioning -pydantic-core==2.33.2 +pydantic-core==2.41.5 # via pydantic -pydantic-settings==2.10.1 +pydantic-settings==2.12.0 # via -r requirements.in pygments==2.19.2 - # via rich -pymongo==4.13.2 + # via + # rich + # textual +pymongo==4.15.5 # via # -r requirements.in - # motor -python-dotenv==1.1.1 + # beanie +python-dotenv==1.2.1 # via pydantic-settings python-multipart==0.0.20 # via -r requirements.in -python-socks==2.7.1 +python-socks==2.8.0 # via httpx-socks -pyyaml==6.0.2 +pyyaml==6.0.3 # via n2snusertools -rich==14.0.0 +rich==14.2.0 # via # -r requirements.in # textual # typer shellingham==1.5.4 # via typer -slack-bolt==1.23.0 +slack-bolt==1.27.0 # via -r requirements.in -slack-sdk==3.36.0 +slack-sdk==3.39.0 # via # -r requirements.in # slack-bolt sniffio==1.3.1 - # via anyio -starlette==0.47.2 + # via httpx-socks +starlette==0.50.0 # via # asgi-correlation-id # fastapi # prometheus-fastapi-instrumentator -textual==4.0.0 +textual==6.8.0 # via -r requirements.in tomlkit==0.13.3 # via uv-dynamic-versioning -trove-classifiers==2025.5.9.12 +trove-classifiers==2025.12.1.14 # via hatchling -typer==0.16.0 +typer==0.20.0 # via -r requirements.in -typing-extensions==4.14.1 +typing-extensions==4.15.0 # via # beanie # fastapi @@ -182,7 +179,7 @@ typing-extensions==4.14.1 # textual # typer # typing-inspection -typing-inspection==0.4.1 +typing-inspection==0.4.2 # via # pydantic # pydantic-settings @@ -192,11 +189,11 @@ uc-micro-py==1.0.3 # via linkify-it-py uuid==1.30 # via -r requirements.in -uv-dynamic-versioning==0.8.2 +uv-dynamic-versioning==0.11.2 # via -r requirements.in -uvicorn==0.35.0 +uvicorn==0.38.0 # via -r requirements.in -wcwidth==0.2.13 +wcwidth==0.2.14 # via prettytable -werkzeug==3.1.3 +werkzeug==3.1.4 # via -r requirements.in diff --git a/src/nsls2api/infrastructure/mongodb_setup.py b/src/nsls2api/infrastructure/mongodb_setup.py index 66b9b38b..6a079e71 100644 --- a/src/nsls2api/infrastructure/mongodb_setup.py +++ b/src/nsls2api/infrastructure/mongodb_setup.py @@ -2,8 +2,8 @@ import beanie import click -import motor.motor_asyncio from pydantic import MongoDsn +from pymongo import AsyncMongoClient from nsls2api import models from nsls2api.infrastructure.logging import logger @@ -25,13 +25,10 @@ def create_connection_string( async def init_connection(mongodb_dsn: MongoDsn): logger.info(f"Attempting to connect to {click.style(str(mongodb_dsn), fg='green')}") - client = motor.motor_asyncio.AsyncIOMotorClient( + client = AsyncMongoClient( mongodb_dsn.unicode_string(), uuidRepresentation="standard" ) - # This is to make sure that the client is using the same event loop as the rest of the application - client.get_io_loop = asyncio.get_event_loop - await beanie.init_beanie( database=client.get_default_database(), document_models=models.all_models, diff --git a/src/nsls2api/tests/conftest.py b/src/nsls2api/tests/conftest.py index 65f25a8e..1d867059 100644 --- a/src/nsls2api/tests/conftest.py +++ b/src/nsls2api/tests/conftest.py @@ -14,7 +14,7 @@ from nsls2api.models.proposals import Proposal -@pytest_asyncio.fixture(scope="session", loop_scope="session", autouse=True) +@pytest_asyncio.fixture(scope="function", autouse=True) async def db(): settings = get_settings() await init_connection(settings.mongodb_dsn) @@ -97,17 +97,17 @@ async def db(): # Clean up the database collections for model in models.all_models: print(f"dropping {model}") - await model.get_motor_collection().drop() - await model.get_motor_collection().drop_indexes() + await model.get_pymongo_collection().drop() + await model.get_pymongo_collection().drop_indexes() -@pytest_asyncio.fixture(scope="session", loop_scope="session", autouse=True) +@pytest_asyncio.fixture(scope="function", autouse=True) async def api_key(db): """Generate and return an API key for test authentication.""" return await generate_api_key(username="test_user", usertype=ApiUserType.user) -@pytest_asyncio.fixture(scope="session", loop_scope="session", autouse=True) +@pytest_asyncio.fixture(scope="function", autouse=True) async def admin_api_key(db): """Generate and return an admin API key for test authentication.""" # Create API key for the admin test user