Initial commit: VoIdeaAI - voice-first AI idea assistant
This commit is contained in:
@@ -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