test: add firmware capture fixtures and stdlib-level unit tests for parsers, intents, running apps
This commit is contained in:
1 parent
f829ef7a40
commit
a2f1948a88
7 files changed
+198
No files matched your search
@@ -0,0 +1,32 @@
|
||||
"""Tests for the PlaybackIntent dataclass (optimistic state tracking)."""
|
||||
|
||||
from ha_adb_common.intent import PlaybackIntent
|
||||
|
||||
|
||||
def test_create_captures_fields():
|
||||
intent = PlaybackIntent.create(
|
||||
target_state="paused", command="media_pause", prior_state="playing"
|
||||
)
|
||||
assert intent.target_state == "paused"
|
||||
assert intent.command == "media_pause"
|
||||
assert intent.prior_state == "playing"
|
||||
assert intent.retry_count == 0
|
||||
assert intent.created_at > 0
|
||||
|
||||
|
||||
def test_debug_dict_shape():
|
||||
intent = PlaybackIntent.create(target_state="playing", command="media_play")
|
||||
debug = intent.to_debug_dict()
|
||||
assert debug["target"] == "playing"
|
||||
assert debug["command"] == "media_play"
|
||||
assert debug["retries"] == 0
|
||||
assert "age_s" in debug
|
||||
|
||||
|
||||
def test_age_increases():
|
||||
import time
|
||||
|
||||
intent = PlaybackIntent.create(target_state="playing", command="media_play")
|
||||
before = intent.age_seconds
|
||||
time.sleep(0.01)
|
||||
assert intent.age_seconds >= before
|
||||
Reference in new issue
Block a user