Files
sovereign_ai/SovereignAI-Starter/tests/api_client.py
T

13 lines
415 B
Python

"""Helpers for API tests that exercise authenticated application routes."""
from fastapi import FastAPI
from fastapi.testclient import TestClient
from app import auth, database
def authenticated_client(app: FastAPI) -> TestClient:
database.ensure_user(database.LOCAL_USER_ID)
token, _ = auth.issue_session(database.LOCAL_USER_ID)
return TestClient(app, headers={"Authorization": f"Bearer {token}"})