chore: switch to all-SQLite stack (drop Postgres service)

This commit is contained in:
Jonas Miederer 2026-09-07 08:39:06 +00:00
parent 74831483eb
commit 7d5ade6b6a
12 changed files with 104 additions and 62 deletions

View file

@ -1,25 +1,22 @@
"""Shared pytest fixtures.
Requires TEST_DATABASE_URL (a dedicated Postgres database, e.g. the
`kirche_einfach_test` database from the compose stack). The URL is mapped
onto DATABASE_URL *before* any app module is imported, so settings and the
alembic env both target the test database. Never point this at production.
Tests run on a throwaway SQLite file (no external database required).
`DATABASE_URL` and `FLOWS_DIR` are pointed at a session temp dir *before* any
app module is imported, so settings pick them up at import time. The app
schema is migrated to head once per session via Alembic.
"""
import os
import tempfile
from pathlib import Path
import pytest
TEST_DB_URL = os.environ.get("TEST_DATABASE_URL")
if not TEST_DB_URL:
raise RuntimeError(
"TEST_DATABASE_URL is not set. Refusing to run tests without "
"an explicit test database (see .env.example)."
)
TEST_AREA = Path(tempfile.mkdtemp(prefix="kirche-tests-"))
# Must precede all `app.*` imports: Settings is instantiated at import time.
os.environ["DATABASE_URL"] = TEST_DB_URL
os.environ["DATABASE_URL"] = f"sqlite:///{TEST_AREA / 'test.db'}"
os.environ["FLOWS_DIR"] = str(TEST_AREA / "flows")
BACKEND_DIR = Path(__file__).resolve().parent.parent
@ -115,6 +112,10 @@ def lfx_server(tmp_path_factory):
env = {
**os.environ,
# lfx serve refuses to start without a serve key; requests need it too.
# get_api_key() prefers LANGFLOW_API_KEY over LFX_API_KEY, and the repo
# .env may put a real Langflow key in the environment — clear it so the
# test key below is the one the client sends.
"LANGFLOW_API_KEY": "",
"LFX_API_KEY": "test-lfx-key",
}
proc = subprocess.Popen(

View file

@ -16,7 +16,9 @@ def test_flow_definition_defaults(session):
assert d.status == "active"
assert d.continuation_flow_id is None
assert d.created_at is not None
assert d.created_at.tzinfo is not None
# Timestamps are written as UTC. SQLite does not round-trip tzinfo, so
# after a refresh the value is calendar-time UTC without tzinfo.
assert d.created_at.year >= 2026
def test_flow_definition_name_unique(session):