from __future__ import annotations

from core.agent.storage_adapter import StorageAdapter


def test_build_object_path_uses_expected_pattern() -> None:
    adapter = StorageAdapter(bucket="agent-chat-attachments")

    path = adapter.build_object_path(
        user_id="u1",
        session_id="s1",
        message_seq=3,
        checksum_sha256="abc123",
        extension="wav",
    )

    assert path == "agent-chat/u1/s1/3/abc123.wav"


def test_build_attachment_metadata_contains_required_fields() -> None:
    adapter = StorageAdapter(bucket="agent-chat-attachments")

    metadata = adapter.build_attachment_metadata(
        object_path="agent-chat/u1/s1/3/abc123.wav",
        mime_type="audio/wav",
        size=1024,
        checksum_sha256="abc123",
        origin="user_upload",
        preview_text="hello",
    )

    assert metadata["object_path"] == "agent-chat/u1/s1/3/abc123.wav"
    assert metadata["mime_type"] == "audio/wav"
    assert metadata["size"] == 1024
    assert metadata["checksum_sha256"] == "abc123"
    assert metadata["origin"] == "user_upload"
    assert metadata["preview_text"] == "hello"
