Files
localthings/tests/test_climate_windfree.py
T
Marc Billow daf7e3787f Add ruff (lint + format) and ty (type checking) to the project
Adds [tool.ruff] and [tool.ty] config to pyproject.toml with a curated
ruff rule set (E, F, W, I, UP, B, C4, SIM, RUF, ASYNC, LOG, G, PIE, RET,
PERF, N), pins ruff/ty in requirements-dev.txt, reformats the whole tree
with `ruff format`, and fixes the pre-existing lint and type-check debt
those tools surfaced so both run clean.

Production-code type fixes include: HA's ConfigFlowResult vs. the
generic FlowResult in config_flow.py, narrowing BoundEntity.desc to its
platform-specific subclass (SelectDesc/NumberDesc/SensorDesc/etc.) via
cast() instead of an unchecked annotation, converting HA device_class
strings to their proper enum types, a resolve_registry callback typed
as `object` instead of `DeviceRegistry | None`, and a couple of other
narrow correctness fixes (CA key type validation, an index-out-of-bounds
false positive from an empty-tuple fallback, a bool/dict argument swap).

Test-file fixes are mechanical: narrowing SamsungEntityDescription to
the correct subclass via isinstance()/cast() before accessing
subclass-only fields, and asserting Optional write_fn/unit_fn fields
are set before calling them.
2026-08-02 23:56:38 +00:00

26 lines
1.0 KiB
Python

"""Tests for the horizontal-swing mapping added to climate.py for issue #75
-- pure dict lookups, testable without a coordinator/entity fixture (see
test_climate_temperature_fallback.py).
The preset side of issue #75 (WindFree/motion convenient modes not
surfacing) is intentionally not addressed here: climate.py's
_preset_to_ha() (issue #91) reads any device preset code straight off the
unit's own supportedModes, replacing the old static _DEVICE_TO_PRESET
table with a generic resolver that covers WindFree/motion generically
instead of a per-model dict -- duplicating that here would just conflict
with it.
"""
from custom_components.localthings.climate import _DEVICE_TO_SWING, _SWING_TO_DEVICE
def test_horizontal_swing_maps_both_directions():
assert _DEVICE_TO_SWING["Left_And_Right"] == "horizontal"
assert _SWING_TO_DEVICE["horizontal"] == "Left_And_Right"
def test_existing_swing_modes_unchanged():
assert _DEVICE_TO_SWING["Fix"] == "off"
assert _DEVICE_TO_SWING["All"] == "both"
assert _DEVICE_TO_SWING["Up_And_Low"] == "vertical"