Fix remaining pre-existing ty diagnostics in test files
Completes the isinstance/cast narrowing + Optional-field assert pattern across the last batch of test files. custom_components and tests are now both fully clean under ruff check, ruff format --check, and ty check.
This commit is contained in:
5 files changed
+41
-12
No files matched your search
@@ -6,7 +6,9 @@ from custom_components.localthings.registry.entities import ButtonDesc, SelectDe
|
||||
|
||||
|
||||
def test_start_button_writes_run():
|
||||
btn = next(e for e in OPERATIONAL_STATE.entities if e.key == "start" and isinstance(e, ButtonDesc))
|
||||
btn = next(
|
||||
e for e in OPERATIONAL_STATE.entities if e.key == "start" and isinstance(e, ButtonDesc)
|
||||
)
|
||||
assert btn.write_fn is not None
|
||||
assert btn.write_fn("Run", {}) == (
|
||||
["operational", "state", "vs", "0"],
|
||||
@@ -15,7 +17,9 @@ def test_start_button_writes_run():
|
||||
|
||||
|
||||
def test_pause_button_writes_pause():
|
||||
btn = next(e for e in OPERATIONAL_STATE.entities if e.key == "pause" and isinstance(e, ButtonDesc))
|
||||
btn = next(
|
||||
e for e in OPERATIONAL_STATE.entities if e.key == "pause" and isinstance(e, ButtonDesc)
|
||||
)
|
||||
assert btn.write_fn is not None
|
||||
assert btn.write_fn("Pause", {}) == (
|
||||
["operational", "state", "vs", "0"],
|
||||
@@ -24,7 +28,9 @@ def test_pause_button_writes_pause():
|
||||
|
||||
|
||||
def test_stop_button_writes_ready():
|
||||
btn = next(e for e in OPERATIONAL_STATE.entities if e.key == "stop" and isinstance(e, ButtonDesc))
|
||||
btn = next(
|
||||
e for e in OPERATIONAL_STATE.entities if e.key == "stop" and isinstance(e, ButtonDesc)
|
||||
)
|
||||
assert btn.write_fn is not None
|
||||
assert btn.write_fn("Ready", {}) == (
|
||||
["operational", "state", "vs", "0"],
|
||||
@@ -33,7 +39,11 @@ def test_stop_button_writes_ready():
|
||||
|
||||
|
||||
def test_sound_mode_write_valid():
|
||||
desc = next(e for e in laundry.SOUND_MODE.entities if e.key == "sound_mode" and isinstance(e, SelectDesc))
|
||||
desc = next(
|
||||
e
|
||||
for e in laundry.SOUND_MODE.entities
|
||||
if e.key == "sound_mode" and isinstance(e, SelectDesc)
|
||||
)
|
||||
assert desc.write_fn is not None
|
||||
assert desc.write_fn("mute", {}) == (
|
||||
["settings", "sound", "mode", "vs", "0"],
|
||||
@@ -44,7 +54,9 @@ def test_sound_mode_write_valid():
|
||||
|
||||
def test_led_brightness_write_valid():
|
||||
desc = next(
|
||||
e for e in laundry.DOOR_LED.entities if e.key == "led_brightness" and isinstance(e, SelectDesc)
|
||||
e
|
||||
for e in laundry.DOOR_LED.entities
|
||||
if e.key == "led_brightness" and isinstance(e, SelectDesc)
|
||||
)
|
||||
assert desc.write_fn is not None
|
||||
assert desc.write_fn("Low", {}) == (
|
||||
@@ -56,7 +68,9 @@ def test_led_brightness_write_valid():
|
||||
|
||||
def test_led_night_light_write_valid():
|
||||
desc = next(
|
||||
e for e in laundry.DOOR_LED.entities if e.key == "led_night_light" and isinstance(e, SwitchDesc)
|
||||
e
|
||||
for e in laundry.DOOR_LED.entities
|
||||
if e.key == "led_night_light" and isinstance(e, SwitchDesc)
|
||||
)
|
||||
assert desc.write_fn is not None
|
||||
assert desc.write_fn("On", {}) == (
|
||||
|
||||
Reference in new issue
Block a user