mirror of
https://github.com/home-assistant/core.git
synced 2025-07-31 19:25:12 +02:00
Rename MQTT entry mock and cleanup (#91223)
Rename to mqtt_mock_entry and cleanup
This commit is contained in:
@@ -192,12 +192,12 @@ class JsonValidator:
|
||||
)
|
||||
async def test_fail_setup_if_no_command_topic(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test if setup fails with no command topic."""
|
||||
with pytest.raises(AssertionError):
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
await mqtt_mock_entry()
|
||||
assert (
|
||||
"Invalid config for [mqtt]: required key not provided @ data['mqtt']['light'][0]['command_topic']. Got None."
|
||||
in caplog.text
|
||||
@@ -215,12 +215,12 @@ async def test_fail_setup_if_no_command_topic(
|
||||
)
|
||||
async def test_fail_setup_if_color_mode_deprecated(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test if setup fails if color mode is combined with deprecated config keys."""
|
||||
with pytest.raises(AssertionError):
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
await mqtt_mock_entry()
|
||||
assert (
|
||||
"Invalid config for [mqtt]: color_mode must not be combined with any of"
|
||||
in caplog.text
|
||||
@@ -258,13 +258,13 @@ async def test_fail_setup_if_color_mode_deprecated(
|
||||
)
|
||||
async def test_fail_setup_if_color_modes_invalid(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
error: str,
|
||||
) -> None:
|
||||
"""Test if setup fails if supported color modes is invalid."""
|
||||
with pytest.raises(AssertionError):
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
await mqtt_mock_entry()
|
||||
assert error in caplog.text
|
||||
|
||||
|
||||
@@ -284,10 +284,10 @@ async def test_fail_setup_if_color_modes_invalid(
|
||||
],
|
||||
)
|
||||
async def test_legacy_rgb_light(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test legacy RGB light flags expected features and color modes."""
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
color_modes = [light.ColorMode.HS]
|
||||
@@ -312,10 +312,10 @@ async def test_legacy_rgb_light(
|
||||
],
|
||||
)
|
||||
async def test_no_color_brightness_color_temp_if_no_topics(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test for no RGB, brightness, color temp, effector XY."""
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -373,10 +373,10 @@ async def test_no_color_brightness_color_temp_if_no_topics(
|
||||
],
|
||||
)
|
||||
async def test_controlling_state_via_topic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test the controlling of the state via topic."""
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -504,12 +504,12 @@ async def test_controlling_state_via_topic(
|
||||
)
|
||||
async def test_controlling_state_via_topic2(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test the controlling of the state via topic for a light supporting color mode."""
|
||||
supported_color_modes = ["color_temp", "hs", "rgb", "rgbw", "rgbww", "white", "xy"]
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -681,7 +681,7 @@ async def test_controlling_state_via_topic2(
|
||||
],
|
||||
)
|
||||
async def test_sending_mqtt_commands_and_optimistic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test the sending of command in optimistic mode."""
|
||||
fake_state = State(
|
||||
@@ -696,7 +696,7 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||
)
|
||||
mock_restore_cache(hass, (fake_state,))
|
||||
|
||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_ON
|
||||
@@ -834,7 +834,7 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||
],
|
||||
)
|
||||
async def test_sending_mqtt_commands_and_optimistic2(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test the sending of command in optimistic mode for a light supporting color mode."""
|
||||
supported_color_modes = ["color_temp", "hs", "rgb", "rgbw", "rgbww", "white", "xy"]
|
||||
@@ -851,7 +851,7 @@ async def test_sending_mqtt_commands_and_optimistic2(
|
||||
)
|
||||
mock_restore_cache(hass, (fake_state,))
|
||||
|
||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_ON
|
||||
@@ -1063,10 +1063,10 @@ async def test_sending_mqtt_commands_and_optimistic2(
|
||||
],
|
||||
)
|
||||
async def test_sending_hs_color(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test light.turn_on with hs color sends hs color parameters."""
|
||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1125,11 +1125,11 @@ async def test_sending_hs_color(
|
||||
],
|
||||
)
|
||||
async def test_sending_rgb_color_no_brightness(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test light.turn_on with hs color sends rgb color parameters."""
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1184,10 +1184,10 @@ async def test_sending_rgb_color_no_brightness(
|
||||
],
|
||||
)
|
||||
async def test_sending_rgb_color_no_brightness2(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test light.turn_on with hs color sends rgb color parameters."""
|
||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1264,10 +1264,10 @@ async def test_sending_rgb_color_no_brightness2(
|
||||
],
|
||||
)
|
||||
async def test_sending_rgb_color_with_brightness(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test light.turn_on with hs color sends rgb color parameters."""
|
||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1333,11 +1333,11 @@ async def test_sending_rgb_color_with_brightness(
|
||||
],
|
||||
)
|
||||
async def test_sending_rgb_color_with_scaled_brightness(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test light.turn_on with hs color sends rgb color parameters."""
|
||||
await hass.async_block_till_done()
|
||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1405,10 +1405,10 @@ async def test_sending_rgb_color_with_scaled_brightness(
|
||||
],
|
||||
)
|
||||
async def test_sending_scaled_white(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test light.turn_on with scaled white."""
|
||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1449,10 +1449,10 @@ async def test_sending_scaled_white(
|
||||
],
|
||||
)
|
||||
async def test_sending_xy_color(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test light.turn_on with hs color sends xy color parameters."""
|
||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1511,10 +1511,10 @@ async def test_sending_xy_color(
|
||||
],
|
||||
)
|
||||
async def test_effect(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test for effect being sent when included."""
|
||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1578,10 +1578,10 @@ async def test_effect(
|
||||
],
|
||||
)
|
||||
async def test_flash_short_and_long(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test for flash length being sent when included."""
|
||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1641,10 +1641,10 @@ async def test_flash_short_and_long(
|
||||
],
|
||||
)
|
||||
async def test_transition(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test for transition time being sent when included."""
|
||||
mqtt_mock = await mqtt_mock_entry_no_yaml_config()
|
||||
mqtt_mock = await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1693,10 +1693,10 @@ async def test_transition(
|
||||
],
|
||||
)
|
||||
async def test_brightness_scale(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test for brightness scaling."""
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1741,10 +1741,10 @@ async def test_brightness_scale(
|
||||
],
|
||||
)
|
||||
async def test_white_scale(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test for white scaling."""
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1801,10 +1801,10 @@ async def test_white_scale(
|
||||
],
|
||||
)
|
||||
async def test_invalid_values(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test that invalid color/brightness/etc. values are ignored."""
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
@@ -1912,58 +1912,58 @@ async def test_invalid_values(
|
||||
|
||||
@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG])
|
||||
async def test_availability_when_connection_lost(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test availability after MQTT disconnection."""
|
||||
await help_test_availability_when_connection_lost(
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN
|
||||
hass, mqtt_mock_entry, light.DOMAIN
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG])
|
||||
async def test_availability_without_topic(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test availability without defined availability topic."""
|
||||
await help_test_availability_without_topic(
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_default_availability_payload(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test availability by default payload with defined topic."""
|
||||
await help_test_default_availability_payload(
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_custom_availability_payload(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test availability by custom payload with defined topic."""
|
||||
await help_test_custom_availability_payload(
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_setting_attribute_via_mqtt_json_message(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||
await help_test_setting_attribute_via_mqtt_json_message(
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||
await help_test_setting_blocked_attribute_via_mqtt_json_message(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
light.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
MQTT_LIGHT_ATTRIBUTES_BLOCKED,
|
||||
@@ -1971,23 +1971,23 @@ async def test_setting_blocked_attribute_via_mqtt_json_message(
|
||||
|
||||
|
||||
async def test_setting_attribute_with_template(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test the setting of attribute via MQTT with JSON payload."""
|
||||
await help_test_setting_attribute_with_template(
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_update_with_json_attrs_not_dict(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test attributes get extracted from a JSON result."""
|
||||
await help_test_update_with_json_attrs_not_dict(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
@@ -1996,13 +1996,13 @@ async def test_update_with_json_attrs_not_dict(
|
||||
|
||||
async def test_update_with_json_attrs_bad_json(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test attributes get extracted from a JSON result."""
|
||||
await help_test_update_with_json_attrs_bad_json(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
@@ -2011,13 +2011,13 @@ async def test_update_with_json_attrs_bad_json(
|
||||
|
||||
async def test_discovery_update_attr(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update of discovered MQTTAttributes."""
|
||||
await help_test_discovery_update_attr(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
@@ -2050,22 +2050,22 @@ async def test_discovery_update_attr(
|
||||
],
|
||||
)
|
||||
async def test_unique_id(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test unique id option only creates one light per unique_id."""
|
||||
await help_test_unique_id(hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN)
|
||||
await help_test_unique_id(hass, mqtt_mock_entry, light.DOMAIN)
|
||||
|
||||
|
||||
async def test_discovery_removal(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test removal of discovered mqtt_json lights."""
|
||||
data = '{ "name": "test", "schema": "json", "command_topic": "test_topic" }'
|
||||
await help_test_discovery_removal(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
data,
|
||||
@@ -2074,7 +2074,7 @@ async def test_discovery_removal(
|
||||
|
||||
async def test_discovery_update_light(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update of discovered light."""
|
||||
@@ -2092,7 +2092,7 @@ async def test_discovery_update_light(
|
||||
}
|
||||
await help_test_discovery_update(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
config1,
|
||||
@@ -2102,7 +2102,7 @@ async def test_discovery_update_light(
|
||||
|
||||
async def test_discovery_update_unchanged_light(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test update of discovered light."""
|
||||
@@ -2117,7 +2117,7 @@ async def test_discovery_update_unchanged_light(
|
||||
) as discovery_update:
|
||||
await help_test_discovery_update_unchanged(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
data1,
|
||||
@@ -2128,7 +2128,7 @@ async def test_discovery_update_unchanged_light(
|
||||
@pytest.mark.no_fail_on_log_exception
|
||||
async def test_discovery_broken(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test handling of bad discovery message."""
|
||||
@@ -2141,7 +2141,7 @@ async def test_discovery_broken(
|
||||
)
|
||||
await help_test_discovery_broken(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
light.DOMAIN,
|
||||
data1,
|
||||
@@ -2150,78 +2150,78 @@ async def test_discovery_broken(
|
||||
|
||||
|
||||
async def test_entity_device_info_with_connection(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test MQTT light device registry integration."""
|
||||
await help_test_entity_device_info_with_connection(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
light.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_device_info_with_identifier(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test MQTT light device registry integration."""
|
||||
await help_test_entity_device_info_with_identifier(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
light.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_device_info_update(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test device registry update."""
|
||||
await help_test_entity_device_info_update(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
light.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_device_info_remove(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test device registry remove."""
|
||||
await help_test_entity_device_info_remove(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
light.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_id_update_subscriptions(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test MQTT subscriptions are managed when entity_id is updated."""
|
||||
await help_test_entity_id_update_subscriptions(
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_id_update_discovery_update(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test MQTT discovery update when entity_id is updated."""
|
||||
await help_test_entity_id_update_discovery_update(
|
||||
hass, mqtt_mock_entry_no_yaml_config, light.DOMAIN, DEFAULT_CONFIG
|
||||
hass, mqtt_mock_entry, light.DOMAIN, DEFAULT_CONFIG
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_debug_info_message(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test MQTT debug info."""
|
||||
await help_test_entity_debug_info_message(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
light.DOMAIN,
|
||||
DEFAULT_CONFIG,
|
||||
light.SERVICE_TURN_ON,
|
||||
@@ -2247,10 +2247,10 @@ async def test_entity_debug_info_message(
|
||||
],
|
||||
)
|
||||
async def test_max_mireds(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setting min_mireds and max_mireds."""
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.attributes.get("min_mireds") == 153
|
||||
@@ -2282,7 +2282,7 @@ async def test_max_mireds(
|
||||
)
|
||||
async def test_publishing_with_custom_encoding(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
service: str,
|
||||
topic: str,
|
||||
@@ -2300,7 +2300,7 @@ async def test_publishing_with_custom_encoding(
|
||||
|
||||
await help_test_publishing_with_custom_encoding(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
caplog,
|
||||
domain,
|
||||
config,
|
||||
@@ -2338,7 +2338,7 @@ async def test_reloadable(
|
||||
)
|
||||
async def test_encoding_subscribable_topics(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
topic: str,
|
||||
value: str,
|
||||
attribute: str | None,
|
||||
@@ -2358,7 +2358,7 @@ async def test_encoding_subscribable_topics(
|
||||
]
|
||||
await help_test_encoding_subscribable_topics(
|
||||
hass,
|
||||
mqtt_mock_entry_no_yaml_config,
|
||||
mqtt_mock_entry,
|
||||
light.DOMAIN,
|
||||
config,
|
||||
topic,
|
||||
@@ -2372,9 +2372,9 @@ async def test_encoding_subscribable_topics(
|
||||
|
||||
@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG])
|
||||
async def test_setup_manual_entity_from_yaml(
|
||||
hass: HomeAssistant, mqtt_mock_entry_no_yaml_config: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test setup manual configured MQTT entity."""
|
||||
await mqtt_mock_entry_no_yaml_config()
|
||||
await mqtt_mock_entry()
|
||||
platform = light.DOMAIN
|
||||
assert hass.states.get(f"{platform}.test")
|
||||
|
Reference in New Issue
Block a user