Arag / tests /unit /test_contact_request.py
AuthorBot
Add fixed Contact Us tab and support email flow in admin panel.
851e167
Raw
History Blame Contribute Delete
941 Bytes
"""Unit tests for general contact request schema."""
import pytest
from pydantic import ValidationError
from app.schemas.admin import ContactRequest
class TestContactRequestSchema:
"""R-029: Contact endpoint uses validated Pydantic schema."""
def test_valid_request(self):
req = ContactRequest(message="Need help with billing")
assert req.category == "general"
assert req.message == "Need help with billing"
def test_accepts_all_categories(self):
for cat in ("general", "billing", "technical", "publishing"):
req = ContactRequest(category=cat, message="Hello")
assert req.category == cat
def test_rejects_empty_message(self):
with pytest.raises(ValidationError):
ContactRequest(message="")
def test_rejects_invalid_category(self):
with pytest.raises(ValidationError):
ContactRequest(category="spam", message="Hello")