- Adopt PEP 517/518 src-layout for api package using hatchling and uv. - Configure dependencies: FastAPI, async SQLAlchemy 2.0, GeoAlchemy2, pgvector, and Pydantic v2. - Implement decoupled SSO Identity Provider protocol with MockDevAdapter, GoogleOAuthAdapter, and AuthService. - Define PostGIS and pgvector SQLAlchemy database models in api/db_models/. - Implement pure-logic Consensus Engine with Haversine distance, Velocity Checks, and cluster confidence scoring. - Add test suite in api/tests/ with 18 unit/integration tests and configure Ruff and Pyright quality gates.
29 lines
906 B
Python
29 lines
906 B
Python
import pytest
|
|
from httpx import AsyncClient
|
|
|
|
from api.main import auth_service
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_health_check_endpoint(async_client: AsyncClient):
|
|
response = await async_client.get("/health")
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert data["status"] == "healthy"
|
|
assert "Novias del Gato" in data["service"]
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_dev_token_endpoint(async_client: AsyncClient):
|
|
payload = {"email": "carlos@example.com", "name": "Carlos Ruiz"}
|
|
response = await async_client.post("/auth/dev-token", json=payload)
|
|
assert response.status_code == 200
|
|
|
|
data = response.json()
|
|
assert "access_token" in data
|
|
assert data["token_type"] == "Bearer"
|
|
|
|
# Verify returned token with auth service
|
|
decoded = auth_service.decode_access_token(data["access_token"])
|
|
assert decoded["email"] == "carlos@example.com"
|