-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
82 additions
and
104 deletions.
There are no files selected for viewing
12 changes: 6 additions & 6 deletions
12
{{cookiecutter.project_slug}}/backend/app/app/tests/api/api_v1/test_celery.py
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
20 changes: 8 additions & 12 deletions
20
{{cookiecutter.project_slug}}/backend/app/app/tests/api/api_v1/test_login.py
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
23 changes: 14 additions & 9 deletions
23
{{cookiecutter.project_slug}}/backend/app/app/tests/conftest.py
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 |
---|---|---|
@@ -1,29 +1,34 @@ | ||
from typing import Dict, Iterator | ||
from typing import Dict, Generator | ||
|
||
import pytest | ||
from fastapi.testclient import TestClient | ||
from sqlalchemy.orm import Session | ||
|
||
from app.core.config import settings | ||
from app.db.session import SessionLocal | ||
from app.main import app | ||
from app.tests.utils.user import authentication_token_from_email | ||
from app.tests.utils.utils import get_server_api, get_superuser_token_headers | ||
from app.tests.utils.utils import get_superuser_token_headers | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def db() -> Iterator[Session]: | ||
def db() -> Generator: | ||
yield SessionLocal() | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def server_api() -> str: | ||
return get_server_api() | ||
def client() -> Generator: | ||
with TestClient(app) as c: | ||
yield c | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def superuser_token_headers() -> Dict[str, str]: | ||
return get_superuser_token_headers() | ||
def superuser_token_headers(client: TestClient) -> Dict[str, str]: | ||
return get_superuser_token_headers(client) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def normal_user_token_headers(db: Session) -> Dict[str, str]: | ||
return authentication_token_from_email(email=settings.EMAIL_TEST_USER, db=db) | ||
def normal_user_token_headers(client: TestClient, db: Session) -> Dict[str, str]: | ||
return authentication_token_from_email( | ||
client=client, email=settings.EMAIL_TEST_USER, db=db | ||
) |
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