mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Do not fail MQTT setup if humidifiers configured via yaml can't be validated (#102312)
Add humidifier
This commit is contained in:
@@ -142,9 +142,8 @@ async def test_fail_setup_if_no_command_topic(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test if command fails with command topic."""
|
||||
with pytest.raises(AssertionError):
|
||||
await mqtt_mock_entry()
|
||||
assert "Invalid config for [mqtt]: required key not provided" in caplog.text
|
||||
assert await mqtt_mock_entry()
|
||||
assert "required key not provided" in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -934,11 +933,11 @@ async def test_attributes(
|
||||
@pytest.mark.parametrize(
|
||||
("hass_config", "valid"),
|
||||
[
|
||||
(
|
||||
( # test valid case 1
|
||||
{
|
||||
mqtt.DOMAIN: {
|
||||
humidifier.DOMAIN: {
|
||||
"name": "test_valid_1",
|
||||
"name": "test",
|
||||
"command_topic": "command-topic",
|
||||
"target_humidity_command_topic": "humidity-command-topic",
|
||||
}
|
||||
@@ -946,11 +945,11 @@ async def test_attributes(
|
||||
},
|
||||
True,
|
||||
),
|
||||
(
|
||||
( # test valid case 2
|
||||
{
|
||||
mqtt.DOMAIN: {
|
||||
humidifier.DOMAIN: {
|
||||
"name": "test_valid_2",
|
||||
"name": "test",
|
||||
"command_topic": "command-topic",
|
||||
"target_humidity_command_topic": "humidity-command-topic",
|
||||
"device_class": "humidifier",
|
||||
@@ -959,11 +958,11 @@ async def test_attributes(
|
||||
},
|
||||
True,
|
||||
),
|
||||
(
|
||||
( # test valid case 3
|
||||
{
|
||||
mqtt.DOMAIN: {
|
||||
humidifier.DOMAIN: {
|
||||
"name": "test_valid_3",
|
||||
"name": "test",
|
||||
"command_topic": "command-topic",
|
||||
"target_humidity_command_topic": "humidity-command-topic",
|
||||
"device_class": "dehumidifier",
|
||||
@@ -972,11 +971,11 @@ async def test_attributes(
|
||||
},
|
||||
True,
|
||||
),
|
||||
(
|
||||
( # test valid case 4
|
||||
{
|
||||
mqtt.DOMAIN: {
|
||||
humidifier.DOMAIN: {
|
||||
"name": "test_valid_4",
|
||||
"name": "test",
|
||||
"command_topic": "command-topic",
|
||||
"target_humidity_command_topic": "humidity-command-topic",
|
||||
"device_class": None,
|
||||
@@ -985,11 +984,11 @@ async def test_attributes(
|
||||
},
|
||||
True,
|
||||
),
|
||||
(
|
||||
( # test invalid device_class
|
||||
{
|
||||
mqtt.DOMAIN: {
|
||||
humidifier.DOMAIN: {
|
||||
"name": "test_invalid_device_class",
|
||||
"name": "test",
|
||||
"command_topic": "command-topic",
|
||||
"target_humidity_command_topic": "humidity-command-topic",
|
||||
"device_class": "notsupporedSpeci@l",
|
||||
@@ -998,11 +997,11 @@ async def test_attributes(
|
||||
},
|
||||
False,
|
||||
),
|
||||
(
|
||||
( # test mode_command_topic without modes
|
||||
{
|
||||
mqtt.DOMAIN: {
|
||||
humidifier.DOMAIN: {
|
||||
"name": "test_mode_command_without_modes",
|
||||
"name": "test",
|
||||
"command_topic": "command-topic",
|
||||
"target_humidity_command_topic": "humidity-command-topic",
|
||||
"mode_command_topic": "mode-command-topic",
|
||||
@@ -1011,11 +1010,11 @@ async def test_attributes(
|
||||
},
|
||||
False,
|
||||
),
|
||||
(
|
||||
( # test invalid humidity min max case 1
|
||||
{
|
||||
mqtt.DOMAIN: {
|
||||
humidifier.DOMAIN: {
|
||||
"name": "test_invalid_humidity_min_max_1",
|
||||
"name": "test",
|
||||
"command_topic": "command-topic",
|
||||
"target_humidity_command_topic": "humidity-command-topic",
|
||||
"min_humidity": 0,
|
||||
@@ -1025,11 +1024,11 @@ async def test_attributes(
|
||||
},
|
||||
False,
|
||||
),
|
||||
(
|
||||
( # test invalid humidity min max case 2
|
||||
{
|
||||
mqtt.DOMAIN: {
|
||||
humidifier.DOMAIN: {
|
||||
"name": "test_invalid_humidity_min_max_2",
|
||||
"name": "test",
|
||||
"command_topic": "command-topic",
|
||||
"target_humidity_command_topic": "humidity-command-topic",
|
||||
"max_humidity": 20,
|
||||
@@ -1039,11 +1038,11 @@ async def test_attributes(
|
||||
},
|
||||
False,
|
||||
),
|
||||
(
|
||||
( # test invalid mode, is reset payload
|
||||
{
|
||||
mqtt.DOMAIN: {
|
||||
humidifier.DOMAIN: {
|
||||
"name": "test_invalid_mode_is_reset",
|
||||
"name": "test",
|
||||
"command_topic": "command-topic",
|
||||
"target_humidity_command_topic": "humidity-command-topic",
|
||||
"mode_command_topic": "mode-command-topic",
|
||||
@@ -1061,11 +1060,9 @@ async def test_validity_configurations(
|
||||
valid: bool,
|
||||
) -> None:
|
||||
"""Test validity of configurations."""
|
||||
if valid:
|
||||
await mqtt_mock_entry()
|
||||
return
|
||||
with pytest.raises(AssertionError):
|
||||
await mqtt_mock_entry()
|
||||
await mqtt_mock_entry()
|
||||
state = hass.states.get("humidifier.test")
|
||||
assert (state is not None) == valid
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -1167,14 +1164,11 @@ async def test_supported_features(
|
||||
features: humidifier.HumidifierEntityFeature | None,
|
||||
) -> None:
|
||||
"""Test supported features."""
|
||||
await mqtt_mock_entry()
|
||||
state = hass.states.get(f"humidifier.{name}")
|
||||
assert (state is not None) == success
|
||||
if success:
|
||||
await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get(f"humidifier.{name}")
|
||||
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == features
|
||||
return
|
||||
with pytest.raises(AssertionError):
|
||||
await mqtt_mock_entry()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG])
|
||||
|
||||
Reference in New Issue
Block a user