mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 12:45:28 +02:00
Update MQTT tests to use the config entry setup (#72373)
* New testframework and tests for fan platform * Merge test_common_new to test_common * Add alarm_control_panel * Add binary_sensor * Add button * Add camera * Add climate * Add config_flow * Add cover * Add device_tracker_disovery * Add device_trigger * Add diagnostics * Add discovery * Add humidifier * Add init * Add lecacy_vacuum * Add light_json * Add light_template * Add light * Add lock * Add number * Add scene * Add select * Add sensor * Add siren * Add state_vacuum * Add subscription * Add switch * Add tag * Add trigger * Add missed tests * Add another missed test * Add device_tracker * Remove commented out code * Correct tests according comments * Improve mqtt_mock_entry and recover tests * Split fixtures with and without yaml setup * Update fixtures manual_mqtt * Update fixtures mqtt_json * Fix test tasmota * Update fixture mqtt_room * Revert fixture changes, improve test * re-add test
This commit is contained in:
@@ -251,16 +251,17 @@ DEFAULT_CONFIG = {
|
||||
}
|
||||
|
||||
|
||||
async def test_fail_setup_if_no_command_topic(hass, mqtt_mock):
|
||||
async def test_fail_setup_if_no_command_topic(hass, mqtt_mock_entry_no_yaml_config):
|
||||
"""Test if command fails with command topic."""
|
||||
assert await async_setup_component(
|
||||
hass, light.DOMAIN, {light.DOMAIN: {"platform": "mqtt", "name": "test"}}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
assert hass.states.get("light.test") is None
|
||||
|
||||
|
||||
async def test_legacy_rgb_white_light(hass, mqtt_mock):
|
||||
async def test_legacy_rgb_white_light(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test legacy RGB + white light flags brightness support."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
@@ -276,6 +277,7 @@ async def test_legacy_rgb_white_light(hass, mqtt_mock):
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
expected_features = (
|
||||
@@ -286,7 +288,9 @@ async def test_legacy_rgb_white_light(hass, mqtt_mock):
|
||||
assert state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == ["hs", "rgbw"]
|
||||
|
||||
|
||||
async def test_no_color_brightness_color_temp_hs_white_xy_if_no_topics(hass, mqtt_mock):
|
||||
async def test_no_color_brightness_color_temp_hs_white_xy_if_no_topics(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test if there is no color and brightness if no topic."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
@@ -301,6 +305,7 @@ async def test_no_color_brightness_color_temp_hs_white_xy_if_no_topics(hass, mqt
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -343,7 +348,9 @@ async def test_no_color_brightness_color_temp_hs_white_xy_if_no_topics(hass, mqt
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
||||
|
||||
async def test_legacy_controlling_state_via_topic(hass, mqtt_mock):
|
||||
async def test_legacy_controlling_state_via_topic(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test the controlling of the state via topic for legacy light (white_value)."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -374,6 +381,7 @@ async def test_legacy_controlling_state_via_topic(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -472,7 +480,7 @@ async def test_legacy_controlling_state_via_topic(hass, mqtt_mock):
|
||||
assert light_state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
|
||||
|
||||
async def test_controlling_state_via_topic(hass, mqtt_mock):
|
||||
async def test_controlling_state_via_topic(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test the controlling of the state via topic."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -505,6 +513,7 @@ async def test_controlling_state_via_topic(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -593,7 +602,9 @@ async def test_controlling_state_via_topic(hass, mqtt_mock):
|
||||
assert light_state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
|
||||
|
||||
async def test_legacy_invalid_state_via_topic(hass, mqtt_mock, caplog):
|
||||
async def test_legacy_invalid_state_via_topic(
|
||||
hass, mqtt_mock_entry_with_yaml_config, caplog
|
||||
):
|
||||
"""Test handling of empty data via topic."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -623,6 +634,7 @@ async def test_legacy_invalid_state_via_topic(hass, mqtt_mock, caplog):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -709,7 +721,7 @@ async def test_legacy_invalid_state_via_topic(hass, mqtt_mock, caplog):
|
||||
assert light_state.attributes["white_value"] == 255
|
||||
|
||||
|
||||
async def test_invalid_state_via_topic(hass, mqtt_mock, caplog):
|
||||
async def test_invalid_state_via_topic(hass, mqtt_mock_entry_with_yaml_config, caplog):
|
||||
"""Test handling of empty data via topic."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -742,6 +754,7 @@ async def test_invalid_state_via_topic(hass, mqtt_mock, caplog):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -843,7 +856,7 @@ async def test_invalid_state_via_topic(hass, mqtt_mock, caplog):
|
||||
assert light_state.attributes["color_temp"] == 153
|
||||
|
||||
|
||||
async def test_brightness_controlling_scale(hass, mqtt_mock):
|
||||
async def test_brightness_controlling_scale(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test the brightness controlling scale."""
|
||||
with assert_setup_component(1, light.DOMAIN):
|
||||
assert await async_setup_component(
|
||||
@@ -865,6 +878,7 @@ async def test_brightness_controlling_scale(hass, mqtt_mock):
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -890,7 +904,9 @@ async def test_brightness_controlling_scale(hass, mqtt_mock):
|
||||
assert light_state.attributes["brightness"] == 255
|
||||
|
||||
|
||||
async def test_brightness_from_rgb_controlling_scale(hass, mqtt_mock):
|
||||
async def test_brightness_from_rgb_controlling_scale(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test the brightness controlling scale."""
|
||||
with assert_setup_component(1, light.DOMAIN):
|
||||
assert await async_setup_component(
|
||||
@@ -911,6 +927,7 @@ async def test_brightness_from_rgb_controlling_scale(hass, mqtt_mock):
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -929,7 +946,9 @@ async def test_brightness_from_rgb_controlling_scale(hass, mqtt_mock):
|
||||
assert state.attributes.get("brightness") == 127
|
||||
|
||||
|
||||
async def test_legacy_white_value_controlling_scale(hass, mqtt_mock):
|
||||
async def test_legacy_white_value_controlling_scale(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test the white_value controlling scale."""
|
||||
with assert_setup_component(1, light.DOMAIN):
|
||||
assert await async_setup_component(
|
||||
@@ -951,6 +970,7 @@ async def test_legacy_white_value_controlling_scale(hass, mqtt_mock):
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -976,7 +996,9 @@ async def test_legacy_white_value_controlling_scale(hass, mqtt_mock):
|
||||
assert light_state.attributes["white_value"] == 255
|
||||
|
||||
|
||||
async def test_legacy_controlling_state_via_topic_with_templates(hass, mqtt_mock):
|
||||
async def test_legacy_controlling_state_via_topic_with_templates(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test the setting of the state with a template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1011,6 +1033,7 @@ async def test_legacy_controlling_state_via_topic_with_templates(hass, mqtt_mock
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1065,7 +1088,9 @@ async def test_legacy_controlling_state_via_topic_with_templates(hass, mqtt_mock
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
||||
|
||||
async def test_controlling_state_via_topic_with_templates(hass, mqtt_mock):
|
||||
async def test_controlling_state_via_topic_with_templates(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test the setting of the state with a template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1104,6 +1129,7 @@ async def test_controlling_state_via_topic_with_templates(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1165,7 +1191,9 @@ async def test_controlling_state_via_topic_with_templates(hass, mqtt_mock):
|
||||
assert state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
|
||||
|
||||
async def test_legacy_sending_mqtt_commands_and_optimistic(hass, mqtt_mock):
|
||||
async def test_legacy_sending_mqtt_commands_and_optimistic(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test the sending of command in optimistic mode."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1204,6 +1232,7 @@ async def test_legacy_sending_mqtt_commands_and_optimistic(hass, mqtt_mock):
|
||||
), assert_setup_component(1, light.DOMAIN):
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_ON
|
||||
@@ -1295,7 +1324,9 @@ async def test_legacy_sending_mqtt_commands_and_optimistic(hass, mqtt_mock):
|
||||
assert state.attributes["color_temp"] == 125
|
||||
|
||||
|
||||
async def test_sending_mqtt_commands_and_optimistic(hass, mqtt_mock):
|
||||
async def test_sending_mqtt_commands_and_optimistic(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test the sending of command in optimistic mode."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1334,6 +1365,7 @@ async def test_sending_mqtt_commands_and_optimistic(hass, mqtt_mock):
|
||||
), assert_setup_component(1, light.DOMAIN):
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_ON
|
||||
@@ -1484,7 +1516,9 @@ async def test_sending_mqtt_commands_and_optimistic(hass, mqtt_mock):
|
||||
assert state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
|
||||
|
||||
async def test_sending_mqtt_rgb_command_with_template(hass, mqtt_mock):
|
||||
async def test_sending_mqtt_rgb_command_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test the sending of RGB command with template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1502,6 +1536,7 @@ async def test_sending_mqtt_rgb_command_with_template(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1521,7 +1556,9 @@ async def test_sending_mqtt_rgb_command_with_template(hass, mqtt_mock):
|
||||
assert state.attributes["rgb_color"] == (255, 128, 64)
|
||||
|
||||
|
||||
async def test_sending_mqtt_rgbw_command_with_template(hass, mqtt_mock):
|
||||
async def test_sending_mqtt_rgbw_command_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test the sending of RGBW command with template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1539,6 +1576,7 @@ async def test_sending_mqtt_rgbw_command_with_template(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1558,7 +1596,9 @@ async def test_sending_mqtt_rgbw_command_with_template(hass, mqtt_mock):
|
||||
assert state.attributes["rgbw_color"] == (255, 128, 64, 32)
|
||||
|
||||
|
||||
async def test_sending_mqtt_rgbww_command_with_template(hass, mqtt_mock):
|
||||
async def test_sending_mqtt_rgbww_command_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test the sending of RGBWW command with template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1576,6 +1616,7 @@ async def test_sending_mqtt_rgbww_command_with_template(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1595,7 +1636,9 @@ async def test_sending_mqtt_rgbww_command_with_template(hass, mqtt_mock):
|
||||
assert state.attributes["rgbww_color"] == (255, 128, 64, 32, 16)
|
||||
|
||||
|
||||
async def test_sending_mqtt_color_temp_command_with_template(hass, mqtt_mock):
|
||||
async def test_sending_mqtt_color_temp_command_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test the sending of Color Temp command with template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1612,6 +1655,7 @@ async def test_sending_mqtt_color_temp_command_with_template(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1631,7 +1675,7 @@ async def test_sending_mqtt_color_temp_command_with_template(hass, mqtt_mock):
|
||||
assert state.attributes["color_temp"] == 100
|
||||
|
||||
|
||||
async def test_on_command_first(hass, mqtt_mock):
|
||||
async def test_on_command_first(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test on command being sent before brightness."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1645,6 +1689,7 @@ async def test_on_command_first(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1667,7 +1712,7 @@ async def test_on_command_first(hass, mqtt_mock):
|
||||
mqtt_mock.async_publish.assert_called_once_with("test_light/set", "OFF", 0, False)
|
||||
|
||||
|
||||
async def test_on_command_last(hass, mqtt_mock):
|
||||
async def test_on_command_last(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test on command being sent after brightness."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1680,6 +1725,7 @@ async def test_on_command_last(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1702,7 +1748,7 @@ async def test_on_command_last(hass, mqtt_mock):
|
||||
mqtt_mock.async_publish.assert_called_once_with("test_light/set", "OFF", 0, False)
|
||||
|
||||
|
||||
async def test_on_command_brightness(hass, mqtt_mock):
|
||||
async def test_on_command_brightness(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test on command being sent as only brightness."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1717,6 +1763,7 @@ async def test_on_command_brightness(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1757,7 +1804,7 @@ async def test_on_command_brightness(hass, mqtt_mock):
|
||||
)
|
||||
|
||||
|
||||
async def test_on_command_brightness_scaled(hass, mqtt_mock):
|
||||
async def test_on_command_brightness_scaled(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test brightness scale."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1773,6 +1820,7 @@ async def test_on_command_brightness_scaled(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1827,7 +1875,7 @@ async def test_on_command_brightness_scaled(hass, mqtt_mock):
|
||||
)
|
||||
|
||||
|
||||
async def test_legacy_on_command_rgb(hass, mqtt_mock):
|
||||
async def test_legacy_on_command_rgb(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test on command in RGB brightness mode."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1841,6 +1889,7 @@ async def test_legacy_on_command_rgb(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1918,7 +1967,7 @@ async def test_legacy_on_command_rgb(hass, mqtt_mock):
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
|
||||
async def test_on_command_rgb(hass, mqtt_mock):
|
||||
async def test_on_command_rgb(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test on command in RGB brightness mode."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -1931,6 +1980,7 @@ async def test_on_command_rgb(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -2008,7 +2058,7 @@ async def test_on_command_rgb(hass, mqtt_mock):
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
|
||||
async def test_on_command_rgbw(hass, mqtt_mock):
|
||||
async def test_on_command_rgbw(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test on command in RGBW brightness mode."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -2021,6 +2071,7 @@ async def test_on_command_rgbw(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -2098,7 +2149,7 @@ async def test_on_command_rgbw(hass, mqtt_mock):
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
|
||||
async def test_on_command_rgbww(hass, mqtt_mock):
|
||||
async def test_on_command_rgbww(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test on command in RGBWW brightness mode."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -2111,6 +2162,7 @@ async def test_on_command_rgbww(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -2188,7 +2240,7 @@ async def test_on_command_rgbww(hass, mqtt_mock):
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
|
||||
|
||||
async def test_on_command_rgb_template(hass, mqtt_mock):
|
||||
async def test_on_command_rgb_template(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test on command in RGB brightness mode with RGB template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -2202,6 +2254,7 @@ async def test_on_command_rgb_template(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -2225,7 +2278,7 @@ async def test_on_command_rgb_template(hass, mqtt_mock):
|
||||
mqtt_mock.async_publish.assert_called_once_with("test_light/set", "OFF", 0, False)
|
||||
|
||||
|
||||
async def test_on_command_rgbw_template(hass, mqtt_mock):
|
||||
async def test_on_command_rgbw_template(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test on command in RGBW brightness mode with RGBW template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -2239,6 +2292,7 @@ async def test_on_command_rgbw_template(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -2261,7 +2315,7 @@ async def test_on_command_rgbw_template(hass, mqtt_mock):
|
||||
mqtt_mock.async_publish.assert_called_once_with("test_light/set", "OFF", 0, False)
|
||||
|
||||
|
||||
async def test_on_command_rgbww_template(hass, mqtt_mock):
|
||||
async def test_on_command_rgbww_template(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test on command in RGBWW brightness mode with RGBWW template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -2275,6 +2329,7 @@ async def test_on_command_rgbww_template(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -2298,7 +2353,7 @@ async def test_on_command_rgbww_template(hass, mqtt_mock):
|
||||
mqtt_mock.async_publish.assert_called_once_with("test_light/set", "OFF", 0, False)
|
||||
|
||||
|
||||
async def test_on_command_white(hass, mqtt_mock):
|
||||
async def test_on_command_white(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test sending commands for RGB + white light."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -2324,6 +2379,7 @@ async def test_on_command_white(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -2375,7 +2431,7 @@ async def test_on_command_white(hass, mqtt_mock):
|
||||
)
|
||||
|
||||
|
||||
async def test_explicit_color_mode(hass, mqtt_mock):
|
||||
async def test_explicit_color_mode(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test explicit color mode over mqtt."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -2409,6 +2465,7 @@ async def test_explicit_color_mode(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -2525,7 +2582,7 @@ async def test_explicit_color_mode(hass, mqtt_mock):
|
||||
assert light_state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
|
||||
|
||||
async def test_explicit_color_mode_templated(hass, mqtt_mock):
|
||||
async def test_explicit_color_mode_templated(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test templated explicit color mode over mqtt."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -2550,6 +2607,7 @@ async def test_explicit_color_mode_templated(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -2606,7 +2664,7 @@ async def test_explicit_color_mode_templated(hass, mqtt_mock):
|
||||
assert light_state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
|
||||
|
||||
async def test_white_state_update(hass, mqtt_mock):
|
||||
async def test_white_state_update(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test state updates for RGB + white light."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -2636,6 +2694,7 @@ async def test_white_state_update(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -2670,7 +2729,7 @@ async def test_white_state_update(hass, mqtt_mock):
|
||||
assert state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
|
||||
|
||||
async def test_effect(hass, mqtt_mock):
|
||||
async def test_effect(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test effect."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -2684,6 +2743,7 @@ async def test_effect(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -2707,77 +2767,91 @@ async def test_effect(hass, mqtt_mock):
|
||||
mqtt_mock.async_publish.assert_called_once_with("test_light/set", "OFF", 0, False)
|
||||
|
||||
|
||||
async def test_availability_when_connection_lost(hass, mqtt_mock):
|
||||
async def test_availability_when_connection_lost(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test availability after MQTT disconnection."""
|
||||
await help_test_availability_when_connection_lost(
|
||||
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_availability_without_topic(hass, mqtt_mock):
|
||||
async def test_availability_without_topic(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test availability without defined availability topic."""
|
||||
await help_test_availability_without_topic(
|
||||
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_default_availability_payload(hass, mqtt_mock):
|
||||
async def test_default_availability_payload(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test availability by default payload with defined topic."""
|
||||
await help_test_default_availability_payload(
|
||||
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_custom_availability_payload(hass, mqtt_mock):
|
||||
async def test_custom_availability_payload(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test availability by custom payload with defined topic."""
|
||||
await help_test_custom_availability_payload(
|
||||
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_setting_attribute_via_mqtt_json_message(hass, mqtt_mock):
|
||||
async def test_setting_attribute_via_mqtt_json_message(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||
await help_test_setting_attribute_via_mqtt_json_message(
|
||||
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_setting_blocked_attribute_via_mqtt_json_message(hass, mqtt_mock):
|
||||
async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||
hass, mqtt_mock_entry_no_yaml_config
|
||||
):
|
||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG, MQTT_LIGHT_ATTRIBUTES_BLOCKED
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
light.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
MQTT_LIGHT_ATTRIBUTES_BLOCKED,
|
||||
)
|
||||
|
||||
|
||||
async def test_setting_attribute_with_template(hass, mqtt_mock):
|
||||
async def test_setting_attribute_with_template(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||
await help_test_setting_attribute_with_template(
|
||||
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_update_with_json_attrs_not_dict(hass, mqtt_mock, caplog):
|
||||
async def test_update_with_json_attrs_not_dict(
|
||||
hass, mqtt_mock_entry_with_yaml_config, caplog
|
||||
):
|
||||
"""Test attributes get extracted from a JSON result."""
|
||||
await help_test_update_with_json_attrs_not_dict(
|
||||
hass, mqtt_mock, caplog, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_with_yaml_config, caplog, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_update_with_json_attrs_bad_JSON(hass, mqtt_mock, caplog):
|
||||
async def test_update_with_json_attrs_bad_JSON(
|
||||
hass, mqtt_mock_entry_with_yaml_config, caplog
|
||||
):
|
||||
"""Test attributes get extracted from a JSON result."""
|
||||
await help_test_update_with_json_attrs_bad_JSON(
|
||||
hass, mqtt_mock, caplog, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_with_yaml_config, caplog, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_attr(hass, mqtt_mock, caplog):
|
||||
async def test_discovery_update_attr(hass, mqtt_mock_entry_no_yaml_config, caplog):
|
||||
"""Test update of discovered MQTTAttributes."""
|
||||
await help_test_discovery_update_attr(
|
||||
hass, mqtt_mock, caplog, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_no_yaml_config, caplog, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_unique_id(hass, mqtt_mock):
|
||||
async def test_unique_id(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test unique id option only creates one light per unique_id."""
|
||||
config = {
|
||||
light.DOMAIN: [
|
||||
@@ -2797,21 +2871,26 @@ async def test_unique_id(hass, mqtt_mock):
|
||||
},
|
||||
]
|
||||
}
|
||||
await help_test_unique_id(hass, mqtt_mock, light.DOMAIN, config)
|
||||
await help_test_unique_id(
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, config
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_removal_light(hass, mqtt_mock, caplog):
|
||||
async def test_discovery_removal_light(hass, mqtt_mock_entry_no_yaml_config, caplog):
|
||||
"""Test removal of discovered light."""
|
||||
data = (
|
||||
'{ "name": "test",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
await help_test_discovery_removal(hass, mqtt_mock, caplog, light.DOMAIN, data)
|
||||
await help_test_discovery_removal(
|
||||
hass, mqtt_mock_entry_no_yaml_config, caplog, light.DOMAIN, data
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_deprecated(hass, mqtt_mock, caplog):
|
||||
async def test_discovery_deprecated(hass, mqtt_mock_entry_no_yaml_config, caplog):
|
||||
"""Test discovery of mqtt light with deprecated platform option."""
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
data = (
|
||||
'{ "name": "Beer",' ' "platform": "mqtt",' ' "command_topic": "test_topic"}'
|
||||
)
|
||||
@@ -2822,7 +2901,9 @@ async def test_discovery_deprecated(hass, mqtt_mock, caplog):
|
||||
assert state.name == "Beer"
|
||||
|
||||
|
||||
async def test_discovery_update_light_topic_and_template(hass, mqtt_mock, caplog):
|
||||
async def test_discovery_update_light_topic_and_template(
|
||||
hass, mqtt_mock_entry_no_yaml_config, caplog
|
||||
):
|
||||
"""Test update of discovered light."""
|
||||
config1 = {
|
||||
"name": "Beer",
|
||||
@@ -3073,7 +3154,7 @@ async def test_discovery_update_light_topic_and_template(hass, mqtt_mock, caplog
|
||||
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
config1,
|
||||
@@ -3083,7 +3164,9 @@ async def test_discovery_update_light_topic_and_template(hass, mqtt_mock, caplog
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_light_template(hass, mqtt_mock, caplog):
|
||||
async def test_discovery_update_light_template(
|
||||
hass, mqtt_mock_entry_no_yaml_config, caplog
|
||||
):
|
||||
"""Test update of discovered light."""
|
||||
config1 = {
|
||||
"name": "Beer",
|
||||
@@ -3292,7 +3375,7 @@ async def test_discovery_update_light_template(hass, mqtt_mock, caplog):
|
||||
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
config1,
|
||||
@@ -3302,7 +3385,9 @@ async def test_discovery_update_light_template(hass, mqtt_mock, caplog):
|
||||
)
|
||||
|
||||
|
||||
async def test_discovery_update_unchanged_light(hass, mqtt_mock, caplog):
|
||||
async def test_discovery_update_unchanged_light(
|
||||
hass, mqtt_mock_entry_no_yaml_config, caplog
|
||||
):
|
||||
"""Test update of discovered light."""
|
||||
data1 = (
|
||||
'{ "name": "Beer",'
|
||||
@@ -3313,12 +3398,17 @@ async def test_discovery_update_unchanged_light(hass, mqtt_mock, caplog):
|
||||
"homeassistant.components.mqtt.light.schema_basic.MqttLight.discovery_update"
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass, mqtt_mock, caplog, light.DOMAIN, data1, discovery_update
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
data1,
|
||||
discovery_update,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.no_fail_on_log_exception
|
||||
async def test_discovery_broken(hass, mqtt_mock, caplog):
|
||||
async def test_discovery_broken(hass, mqtt_mock_entry_no_yaml_config, caplog):
|
||||
"""Test handling of bad discovery message."""
|
||||
data1 = '{ "name": "Beer" }'
|
||||
data2 = (
|
||||
@@ -3327,60 +3417,64 @@ async def test_discovery_broken(hass, mqtt_mock, caplog):
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
await help_test_discovery_broken(
|
||||
hass, mqtt_mock, caplog, light.DOMAIN, data1, data2
|
||||
hass, mqtt_mock_entry_no_yaml_config, caplog, light.DOMAIN, data1, data2
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(hass, mqtt_mock):
|
||||
async def test_entity_device_info_with_connection(hass, mqtt_mock_entry_no_yaml_config):
|
||||
"""Test MQTT light device registry integration."""
|
||||
await help_test_entity_device_info_with_connection(
|
||||
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_identifier(hass, mqtt_mock):
|
||||
async def test_entity_device_info_with_identifier(hass, mqtt_mock_entry_no_yaml_config):
|
||||
"""Test MQTT light device registry integration."""
|
||||
await help_test_entity_device_info_with_identifier(
|
||||
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_device_info_update(hass, mqtt_mock):
|
||||
async def test_entity_device_info_update(hass, mqtt_mock_entry_no_yaml_config):
|
||||
"""Test device registry update."""
|
||||
await help_test_entity_device_info_update(
|
||||
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_device_info_remove(hass, mqtt_mock):
|
||||
async def test_entity_device_info_remove(hass, mqtt_mock_entry_no_yaml_config):
|
||||
"""Test device registry remove."""
|
||||
await help_test_entity_device_info_remove(
|
||||
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_id_update_subscriptions(hass, mqtt_mock):
|
||||
async def test_entity_id_update_subscriptions(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||
await help_test_entity_id_update_subscriptions(
|
||||
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_with_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_id_update_discovery_update(hass, mqtt_mock):
|
||||
async def test_entity_id_update_discovery_update(hass, mqtt_mock_entry_no_yaml_config):
|
||||
"""Test MQTT discovery update when entity_id is updated."""
|
||||
await help_test_entity_id_update_discovery_update(
|
||||
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_debug_info_message(hass, mqtt_mock):
|
||||
async def test_entity_debug_info_message(hass, mqtt_mock_entry_no_yaml_config):
|
||||
"""Test MQTT debug info."""
|
||||
await help_test_entity_debug_info_message(
|
||||
hass, mqtt_mock, light.DOMAIN, DEFAULT_CONFIG, light.SERVICE_TURN_ON
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
light.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
light.SERVICE_TURN_ON,
|
||||
)
|
||||
|
||||
|
||||
async def test_max_mireds(hass, mqtt_mock):
|
||||
async def test_max_mireds(hass, mqtt_mock_entry_with_yaml_config):
|
||||
"""Test setting min_mireds and max_mireds."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -3394,6 +3488,7 @@ async def test_max_mireds(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.attributes.get("min_mireds") == 153
|
||||
@@ -3488,7 +3583,7 @@ async def test_max_mireds(hass, mqtt_mock):
|
||||
)
|
||||
async def test_publishing_with_custom_encoding(
|
||||
hass,
|
||||
mqtt_mock,
|
||||
mqtt_mock_entry_with_yaml_config,
|
||||
caplog,
|
||||
service,
|
||||
topic,
|
||||
@@ -3508,7 +3603,7 @@ async def test_publishing_with_custom_encoding(
|
||||
|
||||
await help_test_publishing_with_custom_encoding(
|
||||
hass,
|
||||
mqtt_mock,
|
||||
mqtt_mock_entry_with_yaml_config,
|
||||
caplog,
|
||||
domain,
|
||||
config,
|
||||
@@ -3522,11 +3617,13 @@ async def test_publishing_with_custom_encoding(
|
||||
)
|
||||
|
||||
|
||||
async def test_reloadable(hass, mqtt_mock, caplog, tmp_path):
|
||||
async def test_reloadable(hass, mqtt_mock_entry_with_yaml_config, caplog, tmp_path):
|
||||
"""Test reloading the MQTT platform."""
|
||||
domain = light.DOMAIN
|
||||
config = DEFAULT_CONFIG[domain]
|
||||
await help_test_reloadable(hass, mqtt_mock, caplog, tmp_path, domain, config)
|
||||
await help_test_reloadable(
|
||||
hass, mqtt_mock_entry_with_yaml_config, caplog, tmp_path, domain, config
|
||||
)
|
||||
|
||||
|
||||
async def test_reloadable_late(hass, mqtt_client_mock, caplog, tmp_path):
|
||||
@@ -3568,7 +3665,14 @@ async def test_reloadable_late(hass, mqtt_client_mock, caplog, tmp_path):
|
||||
],
|
||||
)
|
||||
async def test_encoding_subscribable_topics(
|
||||
hass, mqtt_mock, caplog, topic, value, attribute, attribute_value, init_payload
|
||||
hass,
|
||||
mqtt_mock_entry_with_yaml_config,
|
||||
caplog,
|
||||
topic,
|
||||
value,
|
||||
attribute,
|
||||
attribute_value,
|
||||
init_payload,
|
||||
):
|
||||
"""Test handling of incoming encoded payload."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG[light.DOMAIN])
|
||||
@@ -3587,7 +3691,7 @@ async def test_encoding_subscribable_topics(
|
||||
|
||||
await help_test_encoding_subscribable_topics(
|
||||
hass,
|
||||
mqtt_mock,
|
||||
mqtt_mock_entry_with_yaml_config,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
config,
|
||||
@@ -3599,7 +3703,9 @@ async def test_encoding_subscribable_topics(
|
||||
)
|
||||
|
||||
|
||||
async def test_sending_mqtt_brightness_command_with_template(hass, mqtt_mock):
|
||||
async def test_sending_mqtt_brightness_command_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test the sending of Brightness command with template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -3616,6 +3722,7 @@ async def test_sending_mqtt_brightness_command_with_template(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -3635,7 +3742,9 @@ async def test_sending_mqtt_brightness_command_with_template(hass, mqtt_mock):
|
||||
assert state.attributes["brightness"] == 100
|
||||
|
||||
|
||||
async def test_sending_mqtt_effect_command_with_template(hass, mqtt_mock):
|
||||
async def test_sending_mqtt_effect_command_with_template(
|
||||
hass, mqtt_mock_entry_with_yaml_config
|
||||
):
|
||||
"""Test the sending of Effect command with template."""
|
||||
config = {
|
||||
light.DOMAIN: {
|
||||
@@ -3654,6 +3763,7 @@ async def test_sending_mqtt_effect_command_with_template(hass, mqtt_mock):
|
||||
|
||||
assert await async_setup_component(hass, light.DOMAIN, config)
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
Reference in New Issue
Block a user