"""
Shared test fixtures for Boring-OS SDK tests.

Provides mock HTTP response data and a configured BoringOS client
for unit testing without a running server.
"""

import pytest

from boring_os import BoringOS


# =============================================================================
# Sample Response Data
# =============================================================================

SAMPLE_AGENT_RESPONSE = {
    "text": "I've looked into your account and found the overcharge.",
    "tool_calls": [
        {"tool": "get_billing_details", "result": {"balance": 150.0}},
    ],
    "token_usage": {"input": 1200, "output": 350, "cost": 0.0085},
    "iterations": 2,
    "model_used": "claude-sonnet-4",
    "session_id": None,
    "request_id": "req-abc-123",
}

SAMPLE_AGENT_DEFINITION = {
    "name": "billing_agent",
    "description": "Handles billing inquiries",
    "model": "claude-sonnet-4",
    "tools": ["get_billing_details", "calculate_proration"],
    "prompt_id": "billing-prompt",
    "knowledge_sources": [],
    "max_iterations": 25,
    "max_total_tokens": 100000,
    "status": "active",
    "version": "1",
}

SAMPLE_AGENT_LIST = {
    "agents": [
        {
            "name": "billing_agent",
            "description": "Handles billing inquiries",
            "model": "claude-sonnet-4",
            "status": "active",
            "version": "1",
            "tools_count": 2,
        },
        {
            "name": "roaming_agent",
            "description": "Handles roaming inquiries",
            "model": "gpt-4.1-mini",
            "status": "active",
            "version": "1",
            "tools_count": 3,
        },
    ],
    "total": 2,
}

SAMPLE_SESSION_INFO = {
    "session_id": "ses-test-12345",
    "agent_name": "billing_agent",
}

SAMPLE_MODEL_COMPLETION = {
    "text": "Gravity is a force that pulls objects together.",
    "model": "claude-sonnet-4",
    "provider": "anthropic",
    "usage": {"input_tokens": 25, "output_tokens": 50, "cost": 0.001},
    "finish_reason": "stop",
    "tool_calls": [],
}

SAMPLE_MODEL_EMBEDDING = {
    "embeddings": [[0.1, 0.2, 0.3], [-0.1, -0.2, -0.3]],
    "model": "text-embedding-3-small",
    "usage": {"total_tokens": 10},
}

SAMPLE_MODELS_LIST = {
    "models": [
        {
            "name": "claude-sonnet-4",
            "provider": "anthropic",
            "input_price_per_million": 3.0,
            "output_price_per_million": 15.0,
            "max_context_tokens": 200000,
        },
    ],
}

SAMPLE_FLOW_RESULT = {
    "text": "I've reviewed your account and applied a credit.",
    "nodes_executed": [
        {"node": "triage", "agent": "triage_agent", "duration_ms": 1200},
        {"node": "billing", "agent": "billing_agent", "duration_ms": 2500},
    ],
    "total_cost": 0.0471,
    "execution_id": "flow-exec-789",
    "total_duration_ms": 3700,
}

SAMPLE_FLOW_DEFINITION = {
    "name": "billing_resolution_flow",
    "description": "Resolves billing disputes",
    "nodes": [
        {"name": "triage", "agent": "triage_agent", "description": "Initial triage"},
        {"name": "billing", "agent": "billing_agent", "description": "Billing expert"},
    ],
    "edges": [
        {
            "source": "triage",
            "target": "billing",
            "condition_type": "keyword_match",
            "condition_value": "billing",
            "operation": "HANDOFF",
        },
    ],
    "status": "active",
    "version": "1",
}

SAMPLE_FLOW_LIST = {
    "flows": [SAMPLE_FLOW_DEFINITION],
    "total": 1,
}


# =============================================================================
# Fixtures
# =============================================================================

@pytest.fixture
def client():
    """Create a BoringOS client for testing (no server needed)."""
    return BoringOS(
        api_key="bos_test_key",
        base_url="http://testserver:8080",
    )
