"""Shared fixtures — MockJudge, sample test cases."""

from __future__ import annotations

import pytest

from evalkit.judges.base import BaseJudge
from evalkit.models import JudgeResponse, MetricScore, TestCase, ToolCall


class MockJudge(BaseJudge):

    def __init__(
        self,
        score: float = 0.8,
        reason: str = "Good answer",
    ) -> None:
        self.response_score = score
        self.response_reason = reason
        self.call_count = 0
        self.last_prompt: str | None = None

    def evaluate(self, prompt: str) -> JudgeResponse:
        self.call_count += 1
        self.last_prompt = prompt
        return JudgeResponse(score=self.response_score, reason=self.response_reason)


@pytest.fixture
def mock_judge() -> MockJudge:
    return MockJudge()


@pytest.fixture
def sample_test_case() -> TestCase:
    return TestCase(
        question="What is the capital of France?",
        context=["France is a country in Western Europe. Its capital is Paris."],
        answer="The capital of France is Paris.",
        expected_answer="Paris",
    )


@pytest.fixture
def sample_agent_test_case() -> TestCase:
    return TestCase(
        question="What is the weather in Paris?",
        expected_tool_calls=[
            ToolCall(name="get_weather", parameters={"city": "Paris"}),
        ],
        actual_tool_calls=[
            ToolCall(name="get_weather", parameters={"city": "Paris"}),
        ],
        answer="The weather in Paris is 18°C and sunny.",
    )


@pytest.fixture
def passing_score() -> MetricScore:
    return MetricScore(metric_name="test_metric", score=0.9, reason="Good", passed=True)


@pytest.fixture
def failing_score() -> MetricScore:
    return MetricScore(metric_name="test_metric", score=0.3, reason="Poor", passed=False)
