Backend: - Add MetricItem, StatsCounts, ColumnDescriptionUpdate, MetricDescriptionUpdate DTOs - Add metric_count to DatasetItem and DatasetDetailResponse - Add server-side filtering via ?filter=unmapped|mapped|linked|all - Add PUT endpoints for column/metric description inline-edit - Add HTML stripping validation (max 2000 chars, plain text) - Add WebSocket dataset.updated event on task completion - RBAC: plugin:migration:WRITE for mutations, READ for reads - 14 pytest tests (stats, filter, metrics, inline-edit, validation, 502/503) Frontend: - Rewrite +page.svelte as split-view orchestrator (387 lines) - StatsBar.svelte — 4 metric tiles with aria-pressed, server-side filter dispatch - DatasetList.svelte — card grid with progress bars, checkboxes, search - DatasetPreview.svelte — presentational detail panel (container fetches) - ColumnsTable.svelte — inline-edit with type chips, bold/italic fallback - MetricsTable.svelte — inline-edit with expression hints - 52 vitest tests across 7 test files - i18n: 11 EN + 11 RU keys (with_mapping/с_маппингом) Spec: - 15 issues resolved (semantic label, filtering, endpoints, conflict, metric_count, RBAC, ID types, ports, i18n, validation, a11y, propagation, resize, perf, ownership) Status: 14/14 backend tests pass, 52/52 frontend tests pass, build succeeds Risk: Low — T051 browser validation pending (non-blocking)
43 lines
1.8 KiB
Python
43 lines
1.8 KiB
Python
# #region TestSessionConfig [C:2] [TYPE Module] [SEMANTICS test, conftest, db]
|
|
# @BRIEF Shared pytest fixtures and session configuration for backend tests.
|
|
# @RELATION BINDS_TO -> [init_db]
|
|
# @PRE All test modules use sys.path patching to import from src/.
|
|
# @POST Database tables exist before test session executes.
|
|
# @RATIONALE AUTH_SECRET_KEY/AUTH_DATABASE_URL/DATABASE_URL/DEV_MODE must be set before
|
|
# any project import because src.core.auth.config creates an AuthConfig()
|
|
# singleton at module level that crashes without these env vars (crash-early fix).
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Set env defaults for module-level AuthConfig() singleton — crash-early fix
|
|
os.environ.setdefault("SECRET_KEY", "test-secret-key-for-testing")
|
|
os.environ.setdefault("AUTH_DATABASE_URL", "sqlite:///:memory:test_auth")
|
|
os.environ.setdefault("DATABASE_URL", "sqlite:///:memory:test_main")
|
|
os.environ.setdefault("DEV_MODE", "true")
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture(scope="session", autouse=True)
|
|
def ensure_db_tables():
|
|
"""Ensure all tables exist before test session.
|
|
|
|
This fixture runs once per test session, creating all registered
|
|
SQLAlchemy tables. Individual test modules may also create their
|
|
own in-memory engines — this guarantees the real engine schema
|
|
is initialized for tests that depend on it.
|
|
|
|
NOTE: src.core.database may fail to import due to a pydantic-settings v2
|
|
compatibility issue with the deprecated Field(env=...) parameter in AuthConfig.
|
|
Tests that need the database import it directly and manage the env themselves.
|
|
"""
|
|
try:
|
|
from src.core.database import init_db
|
|
init_db()
|
|
except Exception:
|
|
pass # Graceful degradation — tests requiring DB manage env themselves
|
|
# #endregion TestSessionConfig
|