"""Tests for app/utils/validators.py — 100% branch coverage required."""
from decimal import Decimal
import pytest
from app.utils.validators import validate_amount


class TestValidateAmount:
    # --- Valid inputs ---
    def test_string_decimal(self):
        assert validate_amount("29.99") == Decimal("29.99")

    def test_string_with_dollar_sign(self):
        assert validate_amount("$29.99") == Decimal("29.99")

    def test_string_with_comma(self):
        assert validate_amount("$1,234.56") == Decimal("1234.56")

    def test_integer(self):
        assert validate_amount(5) == Decimal("5.00")

    def test_float(self):
        result = validate_amount(3.14)
        assert result == Decimal("3.14")

    def test_decimal_passthrough(self):
        assert validate_amount(Decimal("9.99")) == Decimal("9.99")

    def test_strips_whitespace(self):
        assert validate_amount("  12.50  ") == Decimal("12.50")

    # --- Invalid inputs ---
    def test_none_raises(self):
        with pytest.raises(ValueError, match="positive number"):
            validate_amount(None)

    def test_empty_string_raises(self):
        with pytest.raises(ValueError, match="positive number"):
            validate_amount("")

    def test_whitespace_only_raises(self):
        with pytest.raises(ValueError, match="positive number"):
            validate_amount("   ")

    def test_non_numeric_raises(self):
        with pytest.raises(ValueError, match="positive number"):
            validate_amount("abc")

    def test_zero_raises(self):
        with pytest.raises(ValueError, match="positive number"):
            validate_amount("0")

    def test_negative_raises(self):
        with pytest.raises(ValueError, match="positive number"):
            validate_amount("-5.00")
