1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-23 04:19:34 +00:00

Switch tests to use hass objects instead of direct (#37530)

* Switch tests to use hass objects instead of direct

* Make sure sensor update state

* Add some initial binary sensor tests

* Add initial binary sensor tests

* Add tests for pt2262

* Add test for off delay
This commit is contained in:
Joakim Plate
2020-07-05 22:41:11 +02:00
committed by GitHub
parent 3ad59f877c
commit 01fd33f173
11 changed files with 640 additions and 548 deletions

View File

@@ -130,23 +130,17 @@ async def test_fire_event(hass):
calls.append(event)
hass.bus.async_listen(rfxtrx.EVENT_BUTTON_PRESSED, record_event)
await hass.async_block_till_done()
entity = rfxtrx.RFX_DEVICES["213c7f2_16"]
entity.update_state(False, 0)
assert "Test" == entity.name
assert "off" == entity.state
assert entity.should_fire_event
event = rfxtrx.get_rfx_object("0b1100cd0213c7f210010f51")
event.data = bytearray(
[0x0B, 0x11, 0x00, 0x10, 0x01, 0x18, 0xCD, 0xEA, 0x01, 0x01, 0x0F, 0x70]
)
await _signal_event(hass, event)
await hass.async_block_till_done()
state = hass.states.get("switch.test")
assert state
assert state.state == "off"
await _signal_event(hass, "0b1100cd0213c7f210010f51")
state = hass.states.get("switch.test")
assert state
assert state.state == "on"
assert event.values["Command"] == "On"
assert "on" == entity.state
assert hass.states.get("switch.test").state == "on"
assert 1 == len(calls)
assert calls[0].data == {"entity_id": "switch.test", "state": "on"}
@@ -191,11 +185,7 @@ async def test_fire_event_sensor(hass):
calls.append(event)
hass.bus.async_listen("signal_received", record_event)
await hass.async_block_till_done()
event = rfxtrx.get_rfx_object("0a520802060101ff0f0269")
event.data = bytearray(b"\nR\x08\x01\x07\x01\x00\xb8\x1b\x02y")
await _signal_event(hass, event)
await hass.async_block_till_done()
await _signal_event(hass, "0a520802060101ff0f0269")
assert 1 == len(calls)
assert calls[0].data == {"entity_id": "sensor.test_temperature"}