Initial commit: VoIdeaAI - voice-first AI idea assistant
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
"""Tests for API route registration and root endpoints."""
|
||||
|
||||
from app.main import app
|
||||
|
||||
|
||||
def test_root_endpoint():
|
||||
"""Test root endpoint returns correct info."""
|
||||
routes = {r.path for r in app.routes if hasattr(r, "methods")}
|
||||
assert "/" in routes
|
||||
assert "/health" in routes
|
||||
assert "/api/v1/health" in routes
|
||||
|
||||
|
||||
def test_all_api_routes_registered():
|
||||
"""Test all expected API v1 routes are registered."""
|
||||
routes = {r.path for r in app.routes if hasattr(r, "methods")}
|
||||
|
||||
expected = {
|
||||
"/api/v1/auth/register",
|
||||
"/api/v1/auth/login",
|
||||
"/api/v1/auth/refresh",
|
||||
"/api/v1/auth/oauth/{provider}",
|
||||
"/api/v1/auth/oauth/{provider}/callback",
|
||||
"/api/v1/users/me",
|
||||
"/api/v1/ideas/",
|
||||
"/api/v1/ideas/{idea_id}",
|
||||
"/api/v1/ideas/{idea_id}/analyze",
|
||||
"/api/v1/agents/",
|
||||
"/api/v1/agents/{agent_name}",
|
||||
"/api/v1/agents/{agent_name}/run",
|
||||
"/api/v1/sync/pull",
|
||||
"/api/v1/sync/push",
|
||||
"/api/v1/admin/users",
|
||||
"/api/v1/admin/users/{user_id}/role",
|
||||
"/api/v1/admin/health",
|
||||
"/api/v1/admin/logs",
|
||||
}
|
||||
|
||||
for path in expected:
|
||||
assert path in routes, f"Missing route: {path}"
|
||||
|
||||
|
||||
def test_openapi_schema():
|
||||
"""Test OpenAPI schema is generated."""
|
||||
schema = app.openapi()
|
||||
assert "VoIdea" in schema["info"]["title"]
|
||||
assert "paths" in schema
|
||||
assert len(schema["paths"]) >= 20
|
||||
|
||||
|
||||
def test_app_title():
|
||||
"""Test app has correct title."""
|
||||
assert "VoIdea" in app.title
|
||||
@@ -0,0 +1,78 @@
|
||||
"""Tests for API schema validation."""
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from app.schemas.auth import LoginRequest, RegisterRequest
|
||||
from app.schemas.idea import IdeaCreate, IdeaUpdate
|
||||
from app.schemas.user import UserCreate
|
||||
|
||||
|
||||
class TestAuthSchemas:
|
||||
def test_register_valid(self):
|
||||
data = RegisterRequest(
|
||||
email="test@example.com",
|
||||
password="password123",
|
||||
display_name="Test User",
|
||||
)
|
||||
assert data.email == "test@example.com"
|
||||
|
||||
def test_register_short_password(self):
|
||||
with pytest.raises(ValidationError):
|
||||
RegisterRequest(
|
||||
email="test@example.com",
|
||||
password="123",
|
||||
display_name="Test",
|
||||
)
|
||||
|
||||
def test_register_invalid_email(self):
|
||||
with pytest.raises(ValidationError):
|
||||
RegisterRequest(
|
||||
email="not-an-email",
|
||||
password="password123",
|
||||
display_name="Test",
|
||||
)
|
||||
|
||||
def test_login_valid(self):
|
||||
data = LoginRequest(email="test@example.com", password="pass")
|
||||
assert data.email == "test@example.com"
|
||||
|
||||
|
||||
class TestIdeaSchemas:
|
||||
def test_idea_create_valid(self):
|
||||
data = IdeaCreate(title="My Idea", content="Some content")
|
||||
assert data.title == "My Idea"
|
||||
assert data.is_public is False
|
||||
|
||||
def test_idea_create_with_tags(self):
|
||||
data = IdeaCreate(
|
||||
title="My Idea",
|
||||
content="Content",
|
||||
tags=["tech", "AI"],
|
||||
is_public=True,
|
||||
)
|
||||
assert data.tags == ["tech", "AI"]
|
||||
assert data.is_public is True
|
||||
|
||||
def test_idea_create_empty_title(self):
|
||||
with pytest.raises(ValidationError):
|
||||
IdeaCreate(title="", content="Content")
|
||||
|
||||
def test_idea_update_partial(self):
|
||||
data = IdeaUpdate(title="New Title")
|
||||
assert data.title == "New Title"
|
||||
assert data.content is None
|
||||
|
||||
def test_idea_update_empty(self):
|
||||
data = IdeaUpdate()
|
||||
assert data.title is None
|
||||
|
||||
|
||||
class TestUserSchemas:
|
||||
def test_user_create_valid(self):
|
||||
data = UserCreate(
|
||||
email="test@example.com",
|
||||
password="password123",
|
||||
display_name="Test",
|
||||
)
|
||||
assert data.display_name == "Test"
|
||||
Reference in New Issue
Block a user