-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Description Fix #403 Add Postgresql databse support for tests. Use a TestAppClient per test file, to prevent tests from a module to impact other modules Configure a Postgresql database for the test workflow. Run tests with Postgresql. Run migration tests with SQLite and Postgresql. ### Checklist - [x] Created tests which fail without the change (if possible) - [x] All tests passing - [x] Extended the documentation, if necessary --------- Co-authored-by: julien4215 <120588494+julien4215@users.noreply.github.com>
- Loading branch information
1 parent
9e2b6d7
commit 0af7649
Showing
29 changed files
with
451 additions
and
323 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,3 @@ logs/ | |
|
||
# Pytest-cov | ||
.coverage | ||
|
||
# Migration tests | ||
test_migration.db | ||
test_migration.db-journal |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pytest | ||
from fastapi.testclient import TestClient | ||
|
||
from app.app import get_application | ||
from app.dependencies import get_db, get_redis_client, get_settings | ||
from tests.commons import ( | ||
override_get_db, | ||
override_get_redis_client, | ||
override_get_settings, | ||
settings, | ||
) | ||
|
||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
def client() -> TestClient: | ||
test_app = get_application(settings=settings, drop_db=True) # Create the test's app | ||
|
||
test_app.dependency_overrides[get_db] = override_get_db | ||
test_app.dependency_overrides[get_settings] = override_get_settings | ||
test_app.dependency_overrides[get_redis_client] = override_get_redis_client | ||
|
||
return TestClient(test_app) # Create a client to execute tests |
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
Oops, something went wrong.