"""TS-01 mirror for ``mgf.django._errors`` (EH-01 / EH-08).

The two typed config errors carry machine-readable fields so callers route on
the field, not the message — assert construction stores those fields and that
both subclass ``ConfigError`` (so a consumer's exception-translation middleware
treats them uniformly).
"""

from __future__ import annotations

from mgf.common.exceptions import ConfigError

from mgf.django._errors import DjangoSettingTypeError, ThrottleConfigError


def test_throttle_config_error_carries_field_and_value() -> None:
    err = ThrottleConfigError("limit must be > 0", field="rate", value=-1.0)
    assert err.field == "rate"
    assert err.value == -1.0
    assert isinstance(err, ConfigError)
    assert "limit must be > 0" in str(err)


def test_django_setting_type_error_carries_received_type() -> None:
    err = DjangoSettingTypeError("expected str | None", received_type="int")
    assert err.received_type == "int"
    assert isinstance(err, ConfigError)
    assert "expected str | None" in str(err)
