mirror of
https://github.com/esphome/esphome.git
synced 2026-10-10 21:39:06 +00:00
[uart] Share uart_tcp's write pacing and uart_id matcher (#20464)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
"""Tests for the uart helpers shared by components that own a UART."""
|
||||
|
||||
from esphome.components.uart import subtree_references_uart
|
||||
from esphome.core import ID
|
||||
|
||||
|
||||
def test_finds_a_nested_uart_id() -> None:
|
||||
config = {"modbus": [{"id": ID("hub"), "uart_id": ID("bus")}]}
|
||||
assert subtree_references_uart(config, "bus")
|
||||
|
||||
|
||||
def test_ignores_other_uarts_and_other_keys() -> None:
|
||||
config = {"modbus": [{"uart_id": ID("other")}], "sensor": [{"id": ID("bus")}]}
|
||||
assert not subtree_references_uart(config, "bus")
|
||||
|
||||
|
||||
def test_finds_another_key() -> None:
|
||||
config = {"modbus_tcp_uart": [{"tcp_uart_id": ID("bus")}]}
|
||||
assert subtree_references_uart(config, "bus", "tcp_uart_id")
|
||||
assert not subtree_references_uart(config, "bus")
|
||||
|
||||
|
||||
def test_handles_scalars() -> None:
|
||||
assert not subtree_references_uart("bus", "bus")
|
||||
Reference in New Issue
Block a user