- Remove User/Quota models; quota fields now live directly on APIKey - Admin UI: login, API key management, settings (Ollama URL/model), proxy info display - .env/.env.example: ADMIN_PASSWORD, PROXY_HOST/PORT, DATABASE_URL, APP_TZ - Admin API runs on 127.0.0.1 only; proxy host/port configurable - API keys support optional expires_at; verified against Europe/Berlin timezone - Daily/monthly quota resets use Europe/Berlin midnight boundary - Fix all tests to use new flat model; add expiry tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36 lines
949 B
Python
36 lines
949 B
Python
import pytest
|
|
import os
|
|
|
|
os.environ.setdefault("OLLAMA_URL", "http://127.0.0.1:9999")
|
|
|
|
|
|
def _setup_db():
|
|
from database import Base, engine, SessionLocal
|
|
from crud import create_api_key
|
|
|
|
Base.metadata.drop_all(bind=engine)
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
db = SessionLocal()
|
|
_, raw_key = create_api_key(db, name="test-key", daily_tokens=1_000_000,
|
|
monthly_tokens=10_000_000, daily_requests=1000,
|
|
monthly_requests=10000)
|
|
os.environ["TEST_API_KEY"] = raw_key
|
|
db.close()
|
|
|
|
|
|
def _teardown_db():
|
|
from database import engine, Base
|
|
Base.metadata.drop_all(bind=engine)
|
|
os.environ.pop("TEST_API_KEY", None)
|
|
|
|
|
|
@pytest.fixture(scope="function")
|
|
def test_client():
|
|
_setup_db()
|
|
from main import app
|
|
from fastapi.testclient import TestClient
|
|
client = TestClient(app, raise_server_exceptions=False)
|
|
yield client
|
|
_teardown_db()
|