import pytest
from app.crud import create_contact
from app.models import Contact
from app.schemas import ContactCreate
from unittest.mock import AsyncMock

@pytest.mark.asyncio
async def test_create_contact():
    # Mock DB session
    mock_session = AsyncMock()
    mock_contact = Contact(
        id=1,
        name="Test",
        email="test@example.com",
        subject="Test",
        message="Hello",
        submitted_at=None
    )
    mock_session.add = AsyncMock()
    mock_session.commit = AsyncMock()
    mock_session.refresh = AsyncMock()

    contact_data = ContactCreate(name="Test", email="test@example.com", subject="Test", message="Hello")
    result = await create_contact(mock_session, contact_data)
    mock_session.add.assert_called_once()
    mock_session.commit.assert_called_once()
