Break out mock of pymodbus return from mock_modbus to new fixture (#55063)

* Remove unused mock_modbus.

* Break out mock pymodbus return values.

* Review comments.
This commit is contained in:
jan iversen 2021-08-23 23:55:57 +02:00 committed by GitHub
parent 7314b1c8e1
commit f91d214ba4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 98 additions and 37 deletions

View file

@ -171,36 +171,41 @@ async def test_config_switch(hass, mock_modbus):
],
)
@pytest.mark.parametrize(
"register_words,config_addon,expected",
"register_words,do_exception,config_addon,expected",
[
(
[0x00],
False,
{CONF_VERIFY: {}},
STATE_OFF,
),
(
[0x01],
False,
{CONF_VERIFY: {}},
STATE_ON,
),
(
[0xFE],
False,
{CONF_VERIFY: {}},
STATE_OFF,
),
(
None,
[0x00],
True,
{CONF_VERIFY: {}},
STATE_UNAVAILABLE,
),
(
None,
[0x00],
True,
None,
STATE_OFF,
),
],
)
async def test_all_switch(hass, mock_modbus, mock_do_cycle, expected):
async def test_all_switch(hass, mock_do_cycle, expected):
"""Run test for given config."""
assert hass.states.get(ENTITY_ID).state == expected