feat: add settings and async db engine

This commit is contained in:
Indiana
2026-07-20 15:01:25 +00:00
parent 1747c355e0
commit 9e69c622c9
4 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
import os
def pytest_configure(config):
"""Set up minimal environment variables for tests before any imports."""
os.environ.setdefault("DATABASE_URL", "postgresql+asyncpg://test:test@localhost/test")
os.environ.setdefault("OLLAMA_BASE_URL", "http://localhost:11434")
os.environ.setdefault("SESSION_SECRET", "test-secret-key")

View File

@@ -0,0 +1,11 @@
from app.config import Settings
def test_settings_load_from_env(monkeypatch):
monkeypatch.setenv("DATABASE_URL", "postgresql+asyncpg://u:p@host/db")
monkeypatch.setenv("OLLAMA_BASE_URL", "http://10.30.20.107:11434")
monkeypatch.setenv("SESSION_SECRET", "test-secret")
settings = Settings(_env_file=None)
assert settings.database_url == "postgresql+asyncpg://u:p@host/db"
assert settings.ollama_base_url == "http://10.30.20.107:11434"
assert settings.port == 7777