Idempotentes Data-Seed-System neben Schema-Migrationen einfuehren.
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
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>
This commit is contained in:
1 parent
2f631f419a
commit
7a6eb3abe8
12 files changed
+440
-5
No files matched your search
@@ -7,6 +7,7 @@ import os
|
||||
import pytest
|
||||
|
||||
os.environ.setdefault("SKIP_DB_MIGRATE", "1")
|
||||
os.environ.setdefault("SKIP_SEEDS", "1")
|
||||
os.environ.setdefault("SKIP_BOOTSTRAP", "1")
|
||||
|
||||
|
||||
@@ -37,6 +38,16 @@ def _run_migrations():
|
||||
assert run_migrations.main() == 0
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def _seed_hygiene():
|
||||
"""Vor/nach Tests pytest-Artefakte aus der geteilten Dev-DB entfernen."""
|
||||
import run_seeds
|
||||
|
||||
run_seeds.main(["--only", "seed_001_cleanup_pytest_artifacts"])
|
||||
yield
|
||||
run_seeds.main(["--only", "seed_001_cleanup_pytest_artifacts"])
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def client():
|
||||
import importlib
|
||||
|
||||
@@ -33,6 +33,7 @@ def test_migration_runner_finds_migrations():
|
||||
names = [name for name, _ in files]
|
||||
assert "001_init_core" in names
|
||||
assert "002_auth_identity_tenant_actor" in names
|
||||
assert "003_data_seeds_tracking" in names
|
||||
|
||||
|
||||
def test_migration_runner_is_idempotent():
|
||||
@@ -44,6 +45,7 @@ def test_migration_runner_is_idempotent():
|
||||
conn.close()
|
||||
assert "001_init_core" in executed
|
||||
assert "002_auth_identity_tenant_actor" in executed
|
||||
assert "003_data_seeds_tracking" in executed
|
||||
|
||||
|
||||
def test_core_table_exists():
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
"""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
|
||||
Reference in new issue
Block a user