from datetime import datetime, timezone

from src.domain.conversations import Conversation, ConversationParticipant, Message


def test_conversation_is_record_scoped_and_not_vertical():
    conversation = Conversation(subject_entity_key="application", subject_record_id="app_1")
    assert conversation.subject_record_id == "app_1"


def test_conversation_participants_carry_the_authorization_boundary():
    participant = ConversationParticipant(
        conversation_id="conversation_1",
        user_id="student_1",
        role="student",
        joined_at=datetime.now(timezone.utc),
    )
    assert participant.role == "student"


def test_message_supports_existing_file_attachment_ids_without_owning_files():
    message = Message(
        conversation_id="conversation_1",
        author_user_id="staff_1",
        body="Please upload the transcript.",
        created_at=datetime.now(timezone.utc),
        attachment_ids=["attachment_1"],
    )
    assert message.attachment_ids == ["attachment_1"]
