"""box_types registry + name() coercion (box-type routing, operator 2026-06-15)."""
import box_types


def test_registry_classes():
    assert box_types.BOX_TYPES[0] == "generic"
    assert box_types.BOX_TYPES[1] == "midrange"
    assert box_types.BOX_TYPES[2] == "high"


def test_name_known_types_int_and_str():
    assert box_types.name(2) == "high"
    assert box_types.name("2") == "high"        # string wire value coerced via int()


def test_name_unknown_type_is_typeN():
    assert box_types.name(9) == "type9"


def test_name_unset_is_untyped():
    assert box_types.name(None) == "untyped"
    assert box_types.name("") == "untyped"


def test_name_uncoercible_is_untyped_not_raise():
    # name() must never raise on garbage input (it's used in logging paths).
    assert box_types.name("abc") == "untyped"
    assert box_types.name(object()) == "untyped"
