"""
Generated by mcp-eval. Do not edit manually.
Test file for server: {{ server_name }}
"""

from mcp_eval import task, Expect
from mcp_eval.session import TestAgent, TestSession
import mcp_eval
from mcp_agent.agents.agent_spec import AgentSpec
from mcp_eval.core import with_agent

{% if suite_agent %}
@mcp_eval.setup
def configure_suite_agent():
    mcp_eval.use_agent(
        AgentSpec(
            name={{ suite_agent.name | tojson }},
            instruction={{ suite_agent.instruction | tojson }},
            server_names={{ suite_agent.server_names | tojson }},
            {% if suite_agent.provider %}provider={{ suite_agent.provider | tojson }},{% endif %}
            {% if suite_agent.model %}model={{ suite_agent.model | tojson }},{% endif %}
        )
    )
{% endif %}

{% for test in tests %}
@task("{{ test.description }}")
{% if test.agent %}
@with_agent(
    AgentSpec(
        name={{ test.agent.name | tojson }},
        instruction={{ test.agent.instruction | tojson }},
        server_names={{ test.agent.server_names | tojson }}
    )
)
{% endif %}
async def {{ test.test_name }}(agent: TestAgent, session: TestSession):
    """
    {{ test.description }}
    """
    objective = {{ test.objective | tojson }}
    response = await agent.generate_str(objective)

    {% for a in test.assertions %}
    {%- if a.kind == 'response_contains' %}
    await session.assert_that(Expect.content.contains({{ a.text | tojson }}, case_sensitive={{ a.case_sensitive|default(False) }}), response=response)
    {%- elif a.kind == 'tool_was_called' %}
    await session.assert_that(Expect.tools.was_called({{ a.tool_name | tojson }}, min_times={{ a.min_times|default(1) }}))
    {%- elif a.kind == 'llm_judge' %}
    await session.assert_that(Expect.judge.llm({{ a.rubric | tojson }}, min_score={{ a.min_score|default(0.8) }}), response=response)
    {%- elif a.kind == 'tool_sequence' %}
    await session.assert_that(Expect.tools.sequence({{ a.sequence | tojson }}, allow_other_calls={{ a.allow_other_calls|default(False) }}))
    {%- elif a.kind == 'tool_called_with' %}
    await session.assert_that(Expect.tools.called_with({{ a.tool_name | tojson }}, {{ a.arguments | py }}))
    {%- elif a.kind == 'tool_output_matches' %}
    await session.assert_that(Expect.tools.output_matches(tool_name={{ a.tool_name | tojson }}, expected_output={{ a.expected_output | py }}, field_path={{ a.field_path | py }}, match_type={{ a.match_type | tojson }}, case_sensitive={{ a.case_sensitive|default(True) }}, call_index={{ a.call_index|default(-1) }}))
    {%- elif a.kind == 'max_iterations' %}
    await session.assert_that(Expect.performance.max_iterations({{ a.max_iterations }}))
    {%- elif a.kind == 'response_time_under' %}
    await session.assert_that(Expect.performance.response_time_under({{ a.ms }}))
    {%- endif %}
    {% endfor %}

{% endfor %}