auth: add dependencies and pytest scaffold
This commit is contained in:
parent
0cdeabc0e6
commit
4bf2086fb8
@ -8,3 +8,6 @@ requests==2.32.3
|
|||||||
cryptography==44.0.2
|
cryptography==44.0.2
|
||||||
msal==1.32.0
|
msal==1.32.0
|
||||||
openpyxl==3.1.5
|
openpyxl==3.1.5
|
||||||
|
argon2-cffi==23.1.0
|
||||||
|
pytest==8.3.3
|
||||||
|
httpx==0.27.2
|
||||||
|
|||||||
1
containers/clearview/src/clearview_app/auth/__init__.py
Normal file
1
containers/clearview/src/clearview_app/auth/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
"""Authentication, session, and user-management subsystem."""
|
||||||
0
containers/clearview/tests/__init__.py
Normal file
0
containers/clearview/tests/__init__.py
Normal file
51
containers/clearview/tests/conftest.py
Normal file
51
containers/clearview/tests/conftest.py
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
"""Pytest fixtures for Clearview tests.
|
||||||
|
|
||||||
|
Uses an in-memory SQLite database. Schema is created from the SQLAlchemy
|
||||||
|
metadata directly (the Alembic migrations target Postgres types like JSONB).
|
||||||
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from sqlalchemy import create_engine, event
|
||||||
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
|
SRC = Path(__file__).resolve().parents[1] / "src"
|
||||||
|
sys.path.insert(0, str(SRC))
|
||||||
|
|
||||||
|
os.environ.setdefault("DATABASE_URL", "sqlite+pysqlite:///:memory:")
|
||||||
|
os.environ.setdefault("COOKIE_SECURE", "false")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def db_engine():
|
||||||
|
engine = create_engine(
|
||||||
|
"sqlite+pysqlite:///:memory:",
|
||||||
|
connect_args={"check_same_thread": False},
|
||||||
|
future=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
@event.listens_for(engine, "connect")
|
||||||
|
def _fk_on(dbapi_conn, _):
|
||||||
|
cur = dbapi_conn.cursor()
|
||||||
|
cur.execute("PRAGMA foreign_keys=ON")
|
||||||
|
cur.close()
|
||||||
|
|
||||||
|
from clearview_app.auth.models import Base as AuthBase
|
||||||
|
|
||||||
|
AuthBase.metadata.create_all(engine)
|
||||||
|
yield engine
|
||||||
|
engine.dispose()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def db_session(db_engine):
|
||||||
|
Session = sessionmaker(bind=db_engine, autoflush=False, autocommit=False, future=True)
|
||||||
|
s = Session()
|
||||||
|
try:
|
||||||
|
yield s
|
||||||
|
finally:
|
||||||
|
s.close()
|
||||||
Loading…
Reference in New Issue
Block a user