mirror of
https://github.com/kevin-DL/full-stack-fastapi-postgresql.git
synced 2026-01-12 10:15:12 +00:00
* ♻️ Refactor backend, update DB session handling * ✨ Add mypy config and plugins * ➕ Use Python-jose instead of PyJWT as it has some extra functionalities and features * ✨ Add/update scripts for test, lint, format * 🔧 Update lint and format configs * 🎨 Update import format, comments, and types * 🎨 Add types to config * ✨ Add types for all the code, and small fixes * 🎨 Use global imports to simplify exploring with Jupyter * ♻️ Import schemas and models, instead of each class * 🚚 Rename db_session to db for simplicity * 📌 Update dependencies installation for testing
30 lines
785 B
Python
30 lines
785 B
Python
from typing import Dict, Iterator
|
|
|
|
import pytest
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.core.config import settings
|
|
from app.db.session import SessionLocal
|
|
from app.tests.utils.user import authentication_token_from_email
|
|
from app.tests.utils.utils import get_server_api, get_superuser_token_headers
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def db() -> Iterator[Session]:
|
|
yield SessionLocal()
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def server_api() -> str:
|
|
return get_server_api()
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def superuser_token_headers() -> Dict[str, str]:
|
|
return get_superuser_token_headers()
|
|
|
|
|
|
@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)
|