Files
agent-skills/skills/fastapi/templates/tests/test_main.py
Jason Woltje 861b28b965 feat: Expand fleet to 23 skills across all domains
New skills (14):
- nestjs-best-practices: 40 priority-ranked rules (kadajett)
- fastapi: Pydantic v2, async SQLAlchemy, JWT auth (jezweb)
- architecture-patterns: Clean Architecture, Hexagonal, DDD (wshobson)
- python-performance-optimization: Profiling and optimization (wshobson)
- ai-sdk: Vercel AI SDK streaming and agent patterns (vercel)
- create-agent: Modular agent architecture with OpenRouter (openrouterteam)
- proactive-agent: WAL Protocol, compaction recovery, self-improvement (halthelobster)
- brand-guidelines: Brand identity enforcement (anthropics)
- ui-animation: Motion design with accessibility (mblode)
- marketing-ideas: 139 ideas across 14 categories (coreyhaines31)
- pricing-strategy: SaaS pricing and tier design (coreyhaines31)
- programmatic-seo: SEO at scale with playbooks (coreyhaines31)
- competitor-alternatives: Comparison page architecture (coreyhaines31)
- referral-program: Referral and affiliate programs (coreyhaines31)

README reorganized by domain: Code Quality, Frontend, Backend,
Auth, AI/Agent Building, Marketing, Design, Meta.

Mosaic Stack is not limited to coding — the Orchestrator serves
coding, business, design, marketing, writing, logistics, and analysis.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 16:22:53 -06:00

98 lines
2.6 KiB
Python

"""Basic API tests."""
import pytest
from httpx import ASGITransport, AsyncClient
from src.main import app
@pytest.fixture
async def client():
"""Async test client fixture."""
async with AsyncClient(
transport=ASGITransport(app=app),
base_url="http://test",
) as ac:
yield ac
@pytest.mark.asyncio
async def test_root(client: AsyncClient):
"""Test root endpoint returns ok status."""
response = await client.get("/")
assert response.status_code == 200
assert response.json()["status"] == "ok"
@pytest.mark.asyncio
async def test_health(client: AsyncClient):
"""Test health endpoint."""
response = await client.get("/health")
assert response.status_code == 200
assert response.json()["status"] == "healthy"
@pytest.mark.asyncio
async def test_register_user(client: AsyncClient):
"""Test user registration."""
response = await client.post(
"/auth/register",
json={"email": "test@example.com", "password": "testpassword123"},
)
assert response.status_code == 201
data = response.json()
assert data["email"] == "test@example.com"
assert "id" in data
@pytest.mark.asyncio
async def test_login(client: AsyncClient):
"""Test user login."""
# First register
await client.post(
"/auth/register",
json={"email": "login@example.com", "password": "testpassword123"},
)
# Then login
response = await client.post(
"/auth/login",
data={"username": "login@example.com", "password": "testpassword123"},
)
assert response.status_code == 200
data = response.json()
assert "access_token" in data
assert data["token_type"] == "bearer"
@pytest.mark.asyncio
async def test_get_me_unauthorized(client: AsyncClient):
"""Test /auth/me without token returns 401."""
response = await client.get("/auth/me")
assert response.status_code == 401
@pytest.mark.asyncio
async def test_get_me_authorized(client: AsyncClient):
"""Test /auth/me with valid token returns user."""
# Register
await client.post(
"/auth/register",
json={"email": "me@example.com", "password": "testpassword123"},
)
# Login
login_response = await client.post(
"/auth/login",
data={"username": "me@example.com", "password": "testpassword123"},
)
token = login_response.json()["access_token"]
# Get me
response = await client.get(
"/auth/me",
headers={"Authorization": f"Bearer {token}"},
)
assert response.status_code == 200
assert response.json()["email"] == "me@example.com"