Use helper on tests MQTT fan platform (#90196)

Use helper on tests fan
This commit is contained in:
Jan Bouwhuis 2023-03-24 08:42:23 +01:00 committed by GitHub
parent f2b4c95a04
commit 1224b1aff6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,6 +34,7 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from .test_common import ( from .test_common import (
help_custom_config,
help_test_availability_when_connection_lost, help_test_availability_when_connection_lost,
help_test_availability_without_topic, help_test_availability_without_topic,
help_test_custom_availability_payload, help_test_custom_availability_payload,
@ -226,36 +227,37 @@ async def test_controlling_state_via_topic(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"hass_config", "hass_config",
[ [
{ help_custom_config(
mqtt.DOMAIN: { fan.DOMAIN,
fan.DOMAIN: [ {
{ mqtt.DOMAIN: {
"name": "test1", fan.DOMAIN: {
"command_topic": "command-topic", "command_topic": "command-topic",
"percentage_state_topic": "percentage-state-topic1", "percentage_command_topic": "percentage-command-topic",
"percentage_command_topic": "percentage-command-topic1", }
"speed_range_min": 1, }
"speed_range_max": 100, },
}, (
{ {
"name": "test2", "name": "test1",
"command_topic": "command-topic", "percentage_state_topic": "percentage-state-topic1",
"percentage_state_topic": "percentage-state-topic2", "speed_range_min": 1,
"percentage_command_topic": "percentage-command-topic2", "speed_range_max": 100,
"speed_range_min": 1, },
"speed_range_max": 200, {
}, "name": "test2",
{ "percentage_state_topic": "percentage-state-topic2",
"name": "test3", "speed_range_min": 1,
"command_topic": "command-topic", "speed_range_max": 200,
"percentage_state_topic": "percentage-state-topic3", },
"percentage_command_topic": "percentage-command-topic3", {
"speed_range_min": 81, "name": "test3",
"speed_range_max": 1023, "percentage_state_topic": "percentage-state-topic3",
}, "speed_range_min": 81,
] "speed_range_max": 1023,
} },
} ),
),
], ],
) )
async def test_controlling_state_via_topic_with_different_speed_range( async def test_controlling_state_via_topic_with_different_speed_range(
@ -672,36 +674,40 @@ async def test_sending_mqtt_commands_and_optimistic(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"hass_config", "hass_config",
[ [
{ help_custom_config(
mqtt.DOMAIN: { fan.DOMAIN,
fan.DOMAIN: [ {
{ mqtt.DOMAIN: {
fan.DOMAIN: {
"name": "test1", "name": "test1",
"command_topic": "command-topic", "command_topic": "command-topic",
"percentage_state_topic": "percentage-state-topic1", "percentage_state_topic": "percentage-state-topic",
"percentage_command_topic": "percentage-command-topic1",
"speed_range_min": 1, "speed_range_min": 1,
"speed_range_max": 3, "speed_range_max": 3,
}, }
{ }
"name": "test2", },
"command_topic": "command-topic", (
"percentage_state_topic": "percentage-state-topic2", {
"percentage_command_topic": "percentage-command-topic2", "name": "test1",
"speed_range_min": 1, "percentage_command_topic": "percentage-command-topic1",
"speed_range_max": 200, "speed_range_min": 1,
}, "speed_range_max": 3,
{ },
"name": "test3", {
"command_topic": "command-topic", "name": "test2",
"percentage_state_topic": "percentage-state-topic3", "percentage_command_topic": "percentage-command-topic2",
"percentage_command_topic": "percentage-command-topic3", "speed_range_min": 1,
"speed_range_min": 81, "speed_range_max": 200,
"speed_range_max": 1023, },
}, {
] "name": "test3",
} "percentage_command_topic": "percentage-command-topic3",
} "speed_range_min": 81,
"speed_range_max": 1023,
},
),
),
], ],
) )
async def test_sending_mqtt_commands_with_alternate_speed_range( async def test_sending_mqtt_commands_with_alternate_speed_range(
@ -1460,7 +1466,7 @@ async def test_attributes(
} }
}, },
True, True,
0, fan.FanEntityFeature(0),
), ),
( (
"test2", "test2",