Newer
Older
geekbrain_io_web / tests / test_schemas.py
from app.schemas import ContactCreate

def test_contact_create_valid():
    data = {
        "name": "Jean Dupont",
        "email": "[email protected]",
        "subject": "Test",
        "message": "Hello"
    }
    contact = ContactCreate(**data)
    assert contact.name == "Jean Dupont"
    assert contact.email == "[email protected]"

def test_contact_create_invalid_email():
    data = {
        "name": "Test",
        "email": "not-an-email",
        "subject": "Test",
        "message": "Hello"
    }
    try:
        ContactCreate(**data)
        assert False, "Should raise validation error"
    except Exception as e:
        assert "email" in str(e).lower()