Implements docs/api-contract-v2.md. Migration 002 adds follow-up fields. EchoTransport replaced by SMTP->Clipboard selection behind unchanged approval gate. Scheduler (APScheduler) daily 07:00 fetch+score, env-gated, default off. Test image installs workspace packages; build context moved to repo root. Recovered and committed by integration lead after W2 worker hit iteration limit.
47 lines
No EOL
1.2 KiB
Python
47 lines
No EOL
1.2 KiB
Python
"""Pytest fixtures: database setup/teardown for all tests.
|
|
|
|
Uses a real PostgreSQL on port 5433 (jobhunt-test-pg container).
|
|
Each test module gets a clean database via truncate fixtures.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
# Set DATABASE_URL before importing app modules
|
|
os.environ.setdefault(
|
|
"DATABASE_URL",
|
|
"postgresql://jobhunt:jobhunt@localhost:5433/jobhunt",
|
|
)
|
|
|
|
from app.db import close_pool, get_pool # noqa: E402
|
|
from app.db import migrate as migrate_mod # noqa: E402
|
|
from app.db import repo_app, repo_profile # noqa: E402
|
|
|
|
|
|
@pytest.fixture(scope="session", autouse=True)
|
|
def _setup_database():
|
|
"""Run migrations once at session start."""
|
|
migrate_mod.reset_database()
|
|
yield
|
|
close_pool()
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _truncate_tables():
|
|
"""Truncate all tables before each test (except schema_migrations)."""
|
|
import psycopg
|
|
from app.config import DATABASE_URL
|
|
|
|
with psycopg.connect(DATABASE_URL) as conn:
|
|
conn.execute(
|
|
"""
|
|
TRUNCATE TABLE task_run, outbox, approval, artifact,
|
|
application, job_posting, cv_section, profile
|
|
RESTART IDENTITY CASCADE
|
|
"""
|
|
)
|
|
conn.commit()
|
|
yield |