Spaces:
Running
Running
| """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") | |