mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Improve test coverage mqtt vacuum (#96288)
This commit is contained in:
parent
beff19f93c
commit
f3e55e96f4
@ -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",
|
||||
[
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user