-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests to bucket endpoint, mongo client and boto (#6)
* hotfix: update gitignore * hotfix: update docker-compose file - remove env-files config * hotfix: structured and enhancement project (#3) * hotfix: update readme project * feat: add new environment variable * feat: add package beanie-odm * fix: remove unsing config in docker-compose file * feat: update botoclient function * feat: cleanup error codes and add news * feat: remove unusing functions and update utils functionnal * feat: define bucket policy config * test: add tests for endpoints and functional (#5)
- Loading branch information
1 parent
72234f2
commit 0dcbeab
Showing
11 changed files
with
251 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[settings] | ||
known_third_party = beanie,boto3,botocore,fastapi,fastapi_pagination,httpx,mongomock_motor,motor,pydantic,pydantic_settings,pymongo,pytest,slugify,starlette,typer,uvicorn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from unittest import mock | ||
|
||
import pytest | ||
|
||
from src.config import settings | ||
from src.config.database import shutdown_db_client, startup_db_client | ||
|
||
|
||
@pytest.mark.asyncio | ||
@mock.patch("src.config.database.init_beanie", return_value=None) | ||
async def test_startup_db_client(mock_init_beanie, fixture_client_mongo, mock_app_instance, fixture_models): | ||
await startup_db_client(app=mock_app_instance, models=[fixture_models.Bucket, fixture_models.Media]) | ||
|
||
assert mock_app_instance.mongo_db_client is not None | ||
assert fixture_client_mongo.is_mongos is True | ||
|
||
mock_init_beanie.assert_called_once_with( | ||
database=mock_app_instance.mongo_db_client[settings.MONGO_DB], | ||
document_models=[fixture_models.Bucket, fixture_models.Media], | ||
multiprocessing_mode=True, | ||
) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_shutdown_db_client(mock_app_instance): | ||
mock_app_instance.mongo_db_client = mock.AsyncMock() | ||
await shutdown_db_client(app=mock_app_instance) | ||
mock_app_instance.mongo_db_client.close.assert_called_once() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.