"""
{{ display_name }} - Automation tests.

This module contains tests for the AI analysis automation.
"""

import pytest

from torivers_sdk.testing import LocalSandbox
from main import {{ class_name }}


@pytest.fixture
def sandbox():
    """Create a local sandbox for testing."""
    return LocalSandbox()


@pytest.fixture
def automation():
    """Create an automation instance."""
    return {{ class_name }}()


@pytest.mark.asyncio
async def test_comprehensive_analysis(sandbox, automation):
    """Test comprehensive analysis execution."""
    result = await sandbox.run(
        automation,
        input_data={
            "content": "This is a test content for AI analysis.",
            "analysis_type": "comprehensive",
        },
    )

    assert result.success
    assert "_blocks" in result.output_data
    blocks = result.output_data["_blocks"]
    assert len(blocks) > 0
    assert blocks[0]["type"] == "json_data"
    data = blocks[0]["data"]
    assert "summary" in data
    assert "entities" in data
    assert "insights" in data


@pytest.mark.asyncio
async def test_summary_only(sandbox, automation):
    """Test summary-only analysis."""
    result = await sandbox.run(
        automation,
        input_data={
            "content": "Brief content to summarize.",
            "analysis_type": "summary",
        },
    )

    assert result.success
    assert "_blocks" in result.output_data


@pytest.mark.asyncio
async def test_sentiment_analysis(sandbox, automation):
    """Test sentiment analysis output."""
    result = await sandbox.run(
        automation,
        input_data={
            "content": "I absolutely love this product! It's amazing.",
            "analysis_type": "sentiment",
        },
    )

    assert result.success
    assert "_blocks" in result.output_data


@pytest.mark.asyncio
async def test_output_format(sandbox, automation):
    """Test that output matches expected format."""
    result = await sandbox.run(
        automation,
        input_data={
            "content": "Test content for format validation.",
        },
    )

    assert result.success
    assert result.output_data.get("_version") == 1
    blocks = result.output_data["_blocks"]
    assert isinstance(blocks, list)
    assert all("type" in b and "label" in b for b in blocks)
