From 505c4b0f770f60825ca7b2fce424bda0e37e55db Mon Sep 17 00:00:00 2001 From: Franck Nijhof <git@frenck.dev> Date: Wed, 22 Jun 2022 11:50:34 +0200 Subject: [PATCH] Fix MQTT tests for RC --- tests/components/mqtt/test_init.py | 35 +++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/tests/components/mqtt/test_init.py b/tests/components/mqtt/test_init.py index e9625e0fdb2..eb392f8c4f8 100644 --- a/tests/components/mqtt/test_init.py +++ b/tests/components/mqtt/test_init.py @@ -1362,35 +1362,50 @@ async def test_setup_override_configuration(hass, caplog, tmp_path): assert calls_username_password_set[0][1] == "somepassword" -@patch("homeassistant.components.mqtt.PLATFORMS", []) -async def test_setup_manual_mqtt_with_platform_key(hass, caplog): +async def test_setup_manual_mqtt_with_platform_key(hass, caplog, tmp_path): """Test set up a manual MQTT item with a platform key.""" config = {"platform": "mqtt", "name": "test", "command_topic": "test-topic"} with pytest.raises(AssertionError): - await help_test_setup_manual_entity_from_yaml(hass, "light", config) + await help_test_setup_manual_entity_from_yaml( + hass, + caplog, + tmp_path, + "light", + config, + ) assert ( "Invalid config for [mqtt]: [platform] is an invalid option for [mqtt]" in caplog.text ) -@patch("homeassistant.components.mqtt.PLATFORMS", []) -async def test_setup_manual_mqtt_with_invalid_config(hass, caplog): +async def test_setup_manual_mqtt_with_invalid_config(hass, caplog, tmp_path): """Test set up a manual MQTT item with an invalid config.""" config = {"name": "test"} with pytest.raises(AssertionError): - await help_test_setup_manual_entity_from_yaml(hass, "light", config) + await help_test_setup_manual_entity_from_yaml( + hass, + caplog, + tmp_path, + "light", + config, + ) assert ( "Invalid config for [mqtt]: required key not provided @ data['mqtt']['light'][0]['command_topic']." " Got None. (See ?, line ?)" in caplog.text ) -@patch("homeassistant.components.mqtt.PLATFORMS", []) -async def test_setup_manual_mqtt_empty_platform(hass, caplog): +async def test_setup_manual_mqtt_empty_platform(hass, caplog, tmp_path): """Test set up a manual MQTT platform without items.""" - config = [] - await help_test_setup_manual_entity_from_yaml(hass, "light", config) + config = None + await help_test_setup_manual_entity_from_yaml( + hass, + caplog, + tmp_path, + "light", + config, + ) assert "voluptuous.error.MultipleInvalid" not in caplog.text