mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 03:16:37 +00:00
[remote_base] Make protocol methods non-virtual and size receiver lists from codegen (#19084)
This commit is contained in:
@@ -187,6 +187,31 @@ def test_slot_counter_emits_requested_count() -> None:
|
||||
assert _define_value("TEST_SLOT_COUNT") == "2"
|
||||
|
||||
|
||||
def test_slot_counter_keyed_emits_largest_count() -> None:
|
||||
"""Keyed requests size storage every key declares at the same capacity:
|
||||
the define is the busiest key's count, not the total over all keys."""
|
||||
request = ch.slot_counter("TEST_SLOT_COUNT_KEYED")
|
||||
request("rx_a")
|
||||
request("rx_a")
|
||||
request("rx_a")
|
||||
request("rx_b")
|
||||
assert ch.get_slot_count("TEST_SLOT_COUNT_KEYED") == 3
|
||||
ch.CORE.flush_tasks()
|
||||
assert _define_value("TEST_SLOT_COUNT_KEYED") == "3"
|
||||
|
||||
|
||||
def test_slot_counter_rejects_mixed_keyed_and_unkeyed_requests() -> None:
|
||||
"""A keyed and an unkeyed request for one define cannot be sized together."""
|
||||
request = ch.slot_counter("TEST_SLOT_COUNT_MIXED")
|
||||
request("rx_a")
|
||||
with pytest.raises(ValueError, match="TEST_SLOT_COUNT_MIXED"):
|
||||
request()
|
||||
unkeyed = ch.slot_counter("TEST_SLOT_COUNT_MIXED_2")
|
||||
unkeyed()
|
||||
with pytest.raises(ValueError, match="TEST_SLOT_COUNT_MIXED_2"):
|
||||
unkeyed("rx_a")
|
||||
|
||||
|
||||
def test_slot_counter_without_requests_emits_nothing() -> None:
|
||||
"""No requests, no job, no define — the guarded storage compiles out."""
|
||||
ch.slot_counter("TEST_SLOT_COUNT_UNUSED")
|
||||
|
||||
Reference in New Issue
Block a user