from __future__ import annotations

import pytest
from mgf.common.exceptions import AppError

from mgf.tele.core import (
    ChecksumError,
    MalformedHandshakeError,
    MalformedPacketError,
    SessionClosedError,
    TelematicsError,
    UnknownTrackerError,
    UnsupportedCodecError,
)

_SUBCLASSES = [
    ChecksumError,
    MalformedHandshakeError,
    MalformedPacketError,
    SessionClosedError,
    UnknownTrackerError,
    UnsupportedCodecError,
]


def test_base_subclasses_apperror() -> None:
    """EH-01 — the category roots at the federation AppError."""
    assert issubclass(TelematicsError, AppError)


@pytest.mark.parametrize("exc_type", _SUBCLASSES)
def test_every_subclass_is_a_telematics_error(exc_type: type[TelematicsError]) -> None:
    assert issubclass(exc_type, TelematicsError)
    # Catching the category catches each specific failure shape.
    with pytest.raises(TelematicsError):
        raise exc_type("boom")
