mirror of
https://github.com/reconurge/flowsint.git
synced 2026-11-08 14:35:41 -06:00
Without known_first_party, isort's own-package detection depends on which files it's given: sorted alone, a file inside flowsint_enrichers gets flowsint_enrichers imports grouped separately from flowsint_core/ flowsint_types; sorted together with the rest of the workspace (as `make lint` and CI do), they collapse into one group. lint-staged only ever passes the staged subset, so a commit could pass the pre-commit hook locally and still fail `make lint` in CI — silently, since both are "isort says it's fine," just about different file sets. Pin the four packages as known_first_party in all four pyproject.toml so grouping is the same regardless of invocation scope. The rest of the diff is isort re-normalizing ~100 files to the now-consistent order — import statements only, verified against the diff.
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
"""Pytest harness for flowsint-api. Provides a TestClient backed by an
|
|
in-memory SQLite database, overriding the real Postgres get_db dependency."""
|
|
|
|
import os
|
|
|
|
# Env required at import time by flowsint-core modules. Set before importing app.
|
|
os.environ.setdefault("AUTH_SECRET", "test-secret-please-ignore")
|
|
os.environ.setdefault(
|
|
"MASTER_VAULT_KEY_V1", "base64:qnHTmwYb+uoygIw9MsRMY22vS5YPchY+QOi/E79GAvM="
|
|
)
|
|
|
|
import pytest # noqa: E402
|
|
from fastapi.testclient import TestClient # noqa: E402
|
|
from sqlalchemy import create_engine # noqa: E402
|
|
from sqlalchemy.orm import sessionmaker # noqa: E402
|
|
|
|
from app.main import app # noqa: E402
|
|
from flowsint_core.core.models import Base # noqa: E402
|
|
from flowsint_core.core.postgre_db import get_db # noqa: E402
|
|
|
|
|
|
@pytest.fixture
|
|
def db_session():
|
|
engine = create_engine(
|
|
"sqlite:///:memory:", connect_args={"check_same_thread": False}
|
|
)
|
|
Base.metadata.create_all(engine)
|
|
Session = sessionmaker(bind=engine)
|
|
session = Session()
|
|
yield session
|
|
session.close()
|
|
|
|
|
|
@pytest.fixture
|
|
def client(db_session):
|
|
app.dependency_overrides[get_db] = lambda: db_session
|
|
yield TestClient(app)
|
|
app.dependency_overrides.clear()
|