🚚 Refactor and simplify backend file structure (#609)
This commit is contained in:

committed by
GitHub

parent
a065f9c9e8
commit
73b2884057
35
src/backend/app/tests/conftest.py
Normal file
35
src/backend/app/tests/conftest.py
Normal file
@@ -0,0 +1,35 @@
|
||||
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.engine import engine
|
||||
from app.main import app
|
||||
from app.tests.utils.user import authentication_token_from_email
|
||||
from app.tests.utils.utils import get_superuser_token_headers
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def db() -> Generator:
|
||||
with Session(engine) as session:
|
||||
yield session
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def client() -> Generator:
|
||||
with TestClient(app) as c:
|
||||
yield c
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def superuser_token_headers(client: TestClient) -> Dict[str, str]:
|
||||
return get_superuser_token_headers(client)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
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
|
||||
)
|
Reference in New Issue
Block a user