Report modbus buffer too small or too big to unpack (#57838)

This commit is contained in:
jan iversen 2021-10-21 00:22:01 +02:00 committed by GitHub
parent 38586d2cf1
commit cca7da77ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 4 deletions

View file

@ -559,6 +559,44 @@ async def test_all_sensor(hass, mock_do_cycle, expected):
assert hass.states.get(ENTITY_ID).state == expected
@pytest.mark.parametrize(
"do_config",
[
{
CONF_SENSORS: [
{
CONF_NAME: TEST_ENTITY_NAME,
CONF_ADDRESS: 51,
CONF_SCAN_INTERVAL: 1,
},
],
},
],
)
@pytest.mark.parametrize(
"config_addon,register_words",
[
(
{
CONF_COUNT: 1,
CONF_DATA_TYPE: DataType.INT16,
},
[7, 9],
),
(
{
CONF_COUNT: 2,
CONF_DATA_TYPE: DataType.INT32,
},
[7],
),
],
)
async def test_wrong_unpack(hass, mock_do_cycle):
"""Run test for sensor."""
assert hass.states.get(ENTITY_ID).state == STATE_UNAVAILABLE
@pytest.mark.parametrize(
"do_config",
[