Add coverage for scanning tags with ESPHome (#107337)

This commit is contained in:
J. Nick Koston 2024-01-07 22:20:27 -10:00 committed by GitHub
parent 1171a7a3d9
commit 3eb81bc461
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -87,6 +87,7 @@ async def test_esphome_device_service_calls_allowed(
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test a device with service calls are allowed."""
await async_setup_component(hass, "tag", {})
entity_info = []
states = []
user_service = []
@ -202,6 +203,23 @@ async def test_esphome_device_service_calls_allowed(
events.clear()
caplog.clear()
# Try scanning a tag
events = async_capture_events(hass, "tag_scanned")
device.mock_service_call(
HomeassistantServiceCall(
service="esphome.tag_scanned",
is_event=True,
data={"tag_id": "1234"},
)
)
await hass.async_block_till_done()
assert len(events) == 1
event = events[0]
assert event.event_type == "tag_scanned"
assert event.data["tag_id"] == "1234"
events.clear()
caplog.clear()
# Try firing events for disallowed domain
events = async_capture_events(hass, "wrong.test")
device.mock_service_call(