Cleanup modbus test mocks (#115412)
This commit is contained in:
parent
dcd61ac086
commit
3202743b6c
9 changed files with 96 additions and 137 deletions
|
@ -262,7 +262,6 @@ async def test_light_service_turn(
|
|||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
mock_modbus,
|
||||
mock_pymodbus_return,
|
||||
) -> None:
|
||||
"""Run test for service turn_on/turn_off."""
|
||||
|
||||
|
@ -300,12 +299,6 @@ async def test_light_service_turn(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(ENTITY_ID2).state == STATE_UNAVAILABLE
|
||||
mock_modbus.write_coil.side_effect = ModbusException("fail write_")
|
||||
await hass.services.async_call(
|
||||
"light", "turn_off", service_data={"entity_id": ENTITY_ID}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(ENTITY_ID).state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -323,13 +316,13 @@ async def test_light_service_turn(
|
|||
},
|
||||
],
|
||||
)
|
||||
async def test_service_light_update(hass: HomeAssistant, mock_modbus, mock_ha) -> None:
|
||||
async def test_service_light_update(hass: HomeAssistant, mock_modbus_ha) -> None:
|
||||
"""Run test for service homeassistant.update_entity."""
|
||||
await hass.services.async_call(
|
||||
"homeassistant", "update_entity", {"entity_id": ENTITY_ID}, blocking=True
|
||||
)
|
||||
assert hass.states.get(ENTITY_ID).state == STATE_OFF
|
||||
mock_modbus.read_coils.return_value = ReadResult([0x01])
|
||||
mock_modbus_ha.read_coils.return_value = ReadResult([0x01])
|
||||
await hass.services.async_call(
|
||||
"homeassistant", "update_entity", {"entity_id": ENTITY_ID}, blocking=True
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue