Files
localthings/tests/test_select_display.py
T
Marc Billowandgalaxysj 00db7890f5 Squash-merge PR #251: fix appliance course labels and AC setup timeouts
- Add confirmed Samsung Table_02 washer course mappings (69-79, 88)
- Add confirmed dishwasher course mappings (82, 8a, a7, a8, 8c, 88)
- Localize new washer/dishwasher course labels in en, cs, nl
- Decode device-provided personal washer course names from TLV payloads
- Show unrecognized washer enum bytes as 'Unknown (0xNN)'
- Normalize select current-state and options through one display path
- Bound first-setup subdevice enumeration with a shared time budget

Co-authored-by: galaxysj <224385302+galaxysj@users.noreply.github.com>
2026-08-08 21:17:43 +00:00

55 lines
2.0 KiB
Python

"""Tests for select-option display casing (custom_components/localthings/select.py)."""
from custom_components.localthings.select import _display
_UNTRANSLATED = None
_TRANSLATED = "ice_type"
def test_display_titlecases_a_fully_lowercase_device_native_token():
"""Samsung's sound-mode field is genuinely lowercase on the wire
('voice'/'tone'/'mute') -- these have no other casing signal to key
off, so title-case them for display."""
assert _display("voice", _UNTRANSLATED) == "Voice"
assert _display("mute", _UNTRANSLATED) == "Mute"
def test_display_inserts_a_space_at_a_camelcase_boundary():
"""'ExtraHigh' (from supportedHeatedDry) should read as two words."""
assert _display("ExtraHigh", _UNTRANSLATED) == "Extra High"
def test_display_passes_through_an_already_human_friendly_value():
"""'AI Wash' etc. (dishwasher cycle names) already read fine and
have no camelCase boundary or all-lowercase pattern -- must not be
mangled."""
assert _display("AI Wash", _UNTRANSLATED) == "AI Wash"
assert _display("Low", _UNTRANSLATED) == "Low"
assert _display("Off", _UNTRANSLATED) == "Off"
def test_display_lowercases_for_translation_key_lookup():
"""An entity with a translation_key must match the catalog's
lowercase keys exactly -- unlike the untranslated cases above, this
is not a cosmetic transform."""
assert _display("Whiskey_IceBall_3", _TRANSLATED) == "whiskey_iceball_3"
def test_unknown_translated_vendor_value_keeps_readable_fallback():
"""A firmware-added value must remain readable instead of being mangled."""
assert _display("FutureVendorMode", _TRANSLATED) == "Future Vendor Mode"
def test_known_camel_case_state_uses_snake_case_translation_key():
assert _display("ExtraHigh", "heated_dry") == "extra_high"
def test_display_passes_through_non_string_values():
assert _display(None, _UNTRANSLATED) is None
def test_display_uses_fallback_when_translation_has_no_state_table():
assert _display('69', 'cycle', lambda value: f'Unknown (0x{value})') == (
'Unknown (0x69)'
)