"""Tests for core response helpers."""

from ars25.core.responses import (
    success_response,
    error_response,
    validation_error,
    not_found_error,
    internal_error,
    ErrorType,
)


def test_success_response():
    r = success_response(count=5, data="hello")
    assert r["status"] == "success"
    assert r["count"] == 5
    assert r["data"] == "hello"


def test_success_response_empty():
    r = success_response()
    assert r == {"status": "success"}


def test_error_response():
    r = error_response("something broke", ErrorType.INTERNAL)
    assert r["status"] == "error"
    assert r["error"] == "something broke"
    assert r["error_type"] == "internal_error"


def test_error_response_with_extra():
    r = error_response("bad input", ErrorType.VALIDATION, field="name")
    assert r["field"] == "name"


def test_validation_error():
    r = validation_error("invalid section")
    assert r["error_type"] == "validation_error"


def test_not_found_error():
    r = not_found_error("section 25-999 not found")
    assert r["error_type"] == "not_found"


def test_internal_error():
    r = internal_error("unexpected crash")
    assert r["error_type"] == "internal_error"
