Skip to content

Commit d0d98c2

Browse files
committed
Add support for Beanie >2.0.0
1 parent 8f15e66 commit d0d98c2

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ classifiers = [
8686
requires-python = ">=3.10"
8787
dependencies = [
8888
"fastapi-users >= 15.0.1",
89-
"beanie >=1.11.0,<2.0.0",
89+
"beanie >=2.0.0",
9090
]
9191

9292
[project.urls]

tests/test_access_token.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66
import pytest_asyncio
77
from beanie import Document, PydanticObjectId, init_beanie
8-
from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorDatabase
8+
from pymongo import AsyncMongoClient
99

1010
from fastapi_users_db_beanie.access_token import (
1111
BeanieAccessTokenDatabase,
@@ -19,7 +19,7 @@ class AccessToken(BeanieBaseAccessToken, Document):
1919

2020
@pytest_asyncio.fixture
2121
async def mongodb_client():
22-
client = AsyncIOMotorClient(
22+
client = AsyncMongoClient(
2323
"mongodb://localhost:27017",
2424
serverSelectionTimeoutMS=10000,
2525
uuidRepresentation="standard",
@@ -28,17 +28,17 @@ async def mongodb_client():
2828
try:
2929
await client.server_info()
3030
yield client
31-
client.close()
31+
await client.close()
3232
except pymongo.errors.ServerSelectionTimeoutError:
3333
pytest.skip("MongoDB not available", allow_module_level=True)
3434
return
3535

3636

3737
@pytest_asyncio.fixture
3838
async def beanie_access_token_db(
39-
mongodb_client: AsyncIOMotorClient,
39+
mongodb_client: AsyncMongoClient,
4040
) -> AsyncGenerator[BeanieAccessTokenDatabase, None]:
41-
database: AsyncIOMotorDatabase = mongodb_client["test_database"]
41+
database = mongodb_client["test_database"]
4242
await init_beanie(database=database, document_models=[AccessToken])
4343

4444
yield BeanieAccessTokenDatabase(AccessToken)

tests/test_fastapi_users_db_beanie.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import pytest_asyncio
77
from beanie import Document, PydanticObjectId, init_beanie
88
from fastapi_users import InvalidID
9-
from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorDatabase
109
from pydantic import Field
10+
from pymongo import AsyncMongoClient
1111

1212
from fastapi_users_db_beanie import (
1313
BaseOAuthAccount,
@@ -31,7 +31,7 @@ class UserOAuth(User):
3131

3232
@pytest_asyncio.fixture
3333
async def mongodb_client():
34-
client = AsyncIOMotorClient(
34+
client = AsyncMongoClient(
3535
"mongodb://localhost:27017",
3636
serverSelectionTimeoutMS=10000,
3737
uuidRepresentation="standard",
@@ -40,17 +40,17 @@ async def mongodb_client():
4040
try:
4141
await client.server_info()
4242
yield client
43-
client.close()
43+
await client.close()
4444
except pymongo.errors.ServerSelectionTimeoutError:
4545
pytest.skip("MongoDB not available", allow_module_level=True)
4646
return
4747

4848

4949
@pytest_asyncio.fixture
5050
async def beanie_user_db(
51-
mongodb_client: AsyncIOMotorClient,
51+
mongodb_client: AsyncMongoClient,
5252
) -> AsyncGenerator[BeanieUserDatabase, None]:
53-
database: AsyncIOMotorDatabase = mongodb_client["test_database"]
53+
database = mongodb_client["test_database"]
5454
await init_beanie(database=database, document_models=[User])
5555

5656
yield BeanieUserDatabase(User)
@@ -60,9 +60,9 @@ async def beanie_user_db(
6060

6161
@pytest_asyncio.fixture
6262
async def beanie_user_db_oauth(
63-
mongodb_client: AsyncIOMotorClient,
63+
mongodb_client: AsyncMongoClient,
6464
) -> AsyncGenerator[BeanieUserDatabase, None]:
65-
database: AsyncIOMotorDatabase = mongodb_client["test_database"]
65+
database = mongodb_client["test_database"]
6666
await init_beanie(database=database, document_models=[UserOAuth])
6767

6868
yield BeanieUserDatabase(UserOAuth, OAuthAccount)

0 commit comments

Comments
 (0)