[settings] fuck it, rework the settings again
this time using pydantic-settings as a base - removed all os.getenv calls - removed the secret_key default option - reworked database loading, creating tables - prob. something else also but its 4:30 and i have to sleep
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
from datetime import time
|
||||
|
||||
import pytest
|
||||
@@ -5,6 +6,9 @@ from fastapi.testclient import TestClient
|
||||
from sqlalchemy.pool import StaticPool
|
||||
from sqlmodel import Session, SQLModel, create_engine
|
||||
|
||||
os.environ["SECRET_KEY"] = "ff" * 16
|
||||
|
||||
from app.main import app
|
||||
from app.model.models import (
|
||||
AccessAuthorizationDB,
|
||||
Card,
|
||||
@@ -24,16 +28,6 @@ engine = create_engine(
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app():
|
||||
import os
|
||||
|
||||
os.environ["SECRET_KEY"] = "ff" * 16
|
||||
from app.main import app
|
||||
|
||||
return app
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def db_session():
|
||||
"""Create a fresh database session for each test."""
|
||||
@@ -44,7 +38,7 @@ def db_session():
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def client(app, db_session):
|
||||
def client(db_session):
|
||||
"""Create a test client with a database session override."""
|
||||
|
||||
def override_get_session():
|
||||
|
||||
@@ -9,10 +9,10 @@ def test_create_db_and_tables():
|
||||
# This is primarily an integration test
|
||||
from sqlalchemy import inspect
|
||||
|
||||
from app.services.database import engine
|
||||
from app.services.database import get_engine
|
||||
|
||||
create_db_and_tables()
|
||||
inspector = inspect(engine)
|
||||
inspector = inspect(get_engine())
|
||||
|
||||
# Check that tables exist
|
||||
tables = inspector.get_table_names()
|
||||
|
||||
Reference in New Issue
Block a user