diff --git a/tests/components/mqtt/test_legacy_vacuum.py b/tests/components/mqtt/test_legacy_vacuum.py index 8034d42ecbe..6b1a74f256d 100644 --- a/tests/components/mqtt/test_legacy_vacuum.py +++ b/tests/components/mqtt/test_legacy_vacuum.py @@ -321,6 +321,41 @@ async def test_commands_without_supported_features( mqtt_mock.async_publish.reset_mock() +@pytest.mark.parametrize( + "hass_config", + [ + { + "mqtt": { + "vacuum": { + "name": "test", + "schema": "legacy", + mqttvacuum.CONF_SUPPORTED_FEATURES: services_to_strings( + ALL_SERVICES, SERVICE_TO_STRING + ), + } + } + } + ], +) +async def test_command_without_command_topic( + hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator +) -> None: + """Test commands which are not supported by the vacuum.""" + mqtt_mock = await mqtt_mock_entry() + + await common.async_turn_on(hass, "vacuum.test") + mqtt_mock.async_publish.assert_not_called() + mqtt_mock.async_publish.reset_mock() + + await common.async_set_fan_speed(hass, "low", "vacuum.test") + mqtt_mock.async_publish.assert_not_called() + mqtt_mock.async_publish.reset_mock() + + await common.async_send_command(hass, "some command", "vacuum.test") + mqtt_mock.async_publish.assert_not_called() + mqtt_mock.async_publish.reset_mock() + + @pytest.mark.parametrize( "hass_config", [ diff --git a/tests/components/mqtt/test_state_vacuum.py b/tests/components/mqtt/test_state_vacuum.py index 38baf591094..b22fb96aa13 100644 --- a/tests/components/mqtt/test_state_vacuum.py +++ b/tests/components/mqtt/test_state_vacuum.py @@ -11,7 +11,10 @@ from homeassistant.components.mqtt.const import CONF_COMMAND_TOPIC, CONF_STATE_T from homeassistant.components.mqtt.vacuum import CONF_SCHEMA, schema_state as mqttvacuum from homeassistant.components.mqtt.vacuum.const import MQTT_VACUUM_ATTRIBUTES_BLOCKED from homeassistant.components.mqtt.vacuum.schema import services_to_strings -from homeassistant.components.mqtt.vacuum.schema_state import SERVICE_TO_STRING +from homeassistant.components.mqtt.vacuum.schema_state import ( + ALL_SERVICES, + SERVICE_TO_STRING, +) from homeassistant.components.vacuum import ( ATTR_BATTERY_ICON, ATTR_BATTERY_LEVEL, @@ -255,6 +258,41 @@ async def test_commands_without_supported_features( mqtt_mock.async_publish.assert_not_called() +@pytest.mark.parametrize( + "hass_config", + [ + { + "mqtt": { + "vacuum": { + "name": "test", + "schema": "state", + mqttvacuum.CONF_SUPPORTED_FEATURES: services_to_strings( + ALL_SERVICES, SERVICE_TO_STRING + ), + } + } + } + ], +) +async def test_command_without_command_topic( + hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator +) -> None: + """Test commands which are not supported by the vacuum.""" + mqtt_mock = await mqtt_mock_entry() + + await common.async_start(hass, "vacuum.test") + mqtt_mock.async_publish.assert_not_called() + mqtt_mock.async_publish.reset_mock() + + await common.async_set_fan_speed(hass, "low", "vacuum.test") + mqtt_mock.async_publish.assert_not_called() + mqtt_mock.async_publish.reset_mock() + + await common.async_send_command(hass, "some command", "vacuum.test") + mqtt_mock.async_publish.assert_not_called() + mqtt_mock.async_publish.reset_mock() + + @pytest.mark.parametrize("hass_config", [CONFIG_ALL_SERVICES]) async def test_status( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator