mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 04:50:05 +00:00
Avoid using implementation internal to trigger events (#38041)
This uses the moxking in fixture to trigger events.
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
"""The tests for the Rfxtrx component."""
|
||||
|
||||
from homeassistant.components import rfxtrx
|
||||
from homeassistant.components.rfxtrx.const import EVENT_RFXTRX_EVENT
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from . import _signal_event
|
||||
|
||||
from tests.async_mock import call
|
||||
|
||||
|
||||
@@ -55,7 +53,7 @@ async def test_invalid_config(hass):
|
||||
)
|
||||
|
||||
|
||||
async def test_fire_event(hass):
|
||||
async def test_fire_event(hass, rfxtrx):
|
||||
"""Test fire event."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
@@ -66,8 +64,8 @@ async def test_fire_event(hass):
|
||||
+ "-RFXCOM_RFXtrx433_A1Y0NJGR-if00-port0",
|
||||
"automatic_add": True,
|
||||
"devices": {
|
||||
"0b1100cd0213c7f210010f51": {rfxtrx.CONF_FIRE_EVENT: True},
|
||||
"0716000100900970": {rfxtrx.CONF_FIRE_EVENT: True},
|
||||
"0b1100cd0213c7f210010f51": {"fire_event": True},
|
||||
"0716000100900970": {"fire_event": True},
|
||||
},
|
||||
}
|
||||
},
|
||||
@@ -83,10 +81,10 @@ async def test_fire_event(hass):
|
||||
assert event.event_type == "rfxtrx_event"
|
||||
calls.append(event.data)
|
||||
|
||||
hass.bus.async_listen(rfxtrx.const.EVENT_RFXTRX_EVENT, record_event)
|
||||
hass.bus.async_listen(EVENT_RFXTRX_EVENT, record_event)
|
||||
|
||||
await _signal_event(hass, "0b1100cd0213c7f210010f51")
|
||||
await _signal_event(hass, "0716000100900970")
|
||||
await rfxtrx.signal("0b1100cd0213c7f210010f51")
|
||||
await rfxtrx.signal("0716000100900970")
|
||||
|
||||
assert calls == [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user