Some checks failed
Deploy Development / deploy (push) Failing after 36s
Test Suite / pytest-backend (push) Failing after 0s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""Data seed runner tests (require PostgreSQL)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import uuid
|
|
|
|
import run_seeds
|
|
from tests.factories import create_user
|
|
|
|
|
|
def test_seed_runner_finds_seeds():
|
|
seeds_dir = run_seeds.seeds_directory()
|
|
names = [name for name, _, _ in run_seeds.seed_files(seeds_dir)]
|
|
assert "seed_001_cleanup_pytest_artifacts" in names
|
|
assert "seed_002_bootstrap_admin" in names
|
|
|
|
|
|
def test_cleanup_seed_removes_example_com_users():
|
|
suffix = uuid.uuid4().hex[:8]
|
|
user = create_user(email=f"seed-test-{suffix}@example.com")
|
|
|
|
assert run_seeds.main(["--only", "seed_001_cleanup_pytest_artifacts", "--force"]) == 0
|
|
|
|
from db import get_connection
|
|
|
|
conn = get_connection()
|
|
try:
|
|
with conn.cursor() as cur:
|
|
cur.execute("SELECT COUNT(*) FROM users WHERE id = %s", (user["id"],))
|
|
assert cur.fetchone()[0] == 0
|
|
finally:
|
|
conn.close()
|
|
|
|
|
|
def test_cleanup_seed_is_idempotent():
|
|
assert run_seeds.main(["--only", "seed_001_cleanup_pytest_artifacts"]) == 0
|
|
assert run_seeds.main(["--only", "seed_001_cleanup_pytest_artifacts"]) == 0
|