Add support for Dyad vacuums to Roborock (#115331)
This commit is contained in:
parent
4defc4a58f
commit
d0f82d6f02
19 changed files with 874 additions and 117 deletions
|
@ -1,7 +1,9 @@
|
|||
"""Test for Roborock init."""
|
||||
|
||||
from copy import deepcopy
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from roborock import RoborockException, RoborockInvalidCredentials
|
||||
|
||||
from homeassistant.components.roborock.const import DOMAIN
|
||||
|
@ -9,6 +11,8 @@ from homeassistant.config_entries import ConfigEntryState
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .mock_data import HOME_DATA
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
|
@ -34,7 +38,7 @@ async def test_config_entry_not_ready(
|
|||
"""Test that when coordinator update fails, entry retries."""
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.roborock.RoborockApiClient.get_home_data",
|
||||
"homeassistant.components.roborock.RoborockApiClient.get_home_data_v2",
|
||||
),
|
||||
patch(
|
||||
"homeassistant.components.roborock.coordinator.RoborockLocalClientV1.get_prop",
|
||||
|
@ -51,7 +55,7 @@ async def test_config_entry_not_ready_home_data(
|
|||
"""Test that when we fail to get home data, entry retries."""
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.roborock.RoborockApiClient.get_home_data",
|
||||
"homeassistant.components.roborock.RoborockApiClient.get_home_data_v2",
|
||||
side_effect=RoborockException(),
|
||||
),
|
||||
patch(
|
||||
|
@ -64,7 +68,9 @@ async def test_config_entry_not_ready_home_data(
|
|||
|
||||
|
||||
async def test_get_networking_fails(
|
||||
hass: HomeAssistant, mock_roborock_entry: MockConfigEntry, bypass_api_fixture
|
||||
hass: HomeAssistant,
|
||||
mock_roborock_entry: MockConfigEntry,
|
||||
bypass_api_fixture_v1_only,
|
||||
) -> None:
|
||||
"""Test that when networking fails, we attempt to retry."""
|
||||
with patch(
|
||||
|
@ -76,7 +82,9 @@ async def test_get_networking_fails(
|
|||
|
||||
|
||||
async def test_get_networking_fails_none(
|
||||
hass: HomeAssistant, mock_roborock_entry: MockConfigEntry, bypass_api_fixture
|
||||
hass: HomeAssistant,
|
||||
mock_roborock_entry: MockConfigEntry,
|
||||
bypass_api_fixture_v1_only,
|
||||
) -> None:
|
||||
"""Test that when networking returns None, we attempt to retry."""
|
||||
with patch(
|
||||
|
@ -88,7 +96,9 @@ async def test_get_networking_fails_none(
|
|||
|
||||
|
||||
async def test_cloud_client_fails_props(
|
||||
hass: HomeAssistant, mock_roborock_entry: MockConfigEntry, bypass_api_fixture
|
||||
hass: HomeAssistant,
|
||||
mock_roborock_entry: MockConfigEntry,
|
||||
bypass_api_fixture_v1_only,
|
||||
) -> None:
|
||||
"""Test that if networking succeeds, but we can't communicate with the vacuum, we can't get props, fail."""
|
||||
with (
|
||||
|
@ -106,7 +116,9 @@ async def test_cloud_client_fails_props(
|
|||
|
||||
|
||||
async def test_local_client_fails_props(
|
||||
hass: HomeAssistant, mock_roborock_entry: MockConfigEntry, bypass_api_fixture
|
||||
hass: HomeAssistant,
|
||||
mock_roborock_entry: MockConfigEntry,
|
||||
bypass_api_fixture_v1_only,
|
||||
) -> None:
|
||||
"""Test that if networking succeeds, but we can't communicate locally with the vacuum, we can't get props, fail."""
|
||||
with patch(
|
||||
|
@ -118,7 +130,9 @@ async def test_local_client_fails_props(
|
|||
|
||||
|
||||
async def test_fails_maps_continue(
|
||||
hass: HomeAssistant, mock_roborock_entry: MockConfigEntry, bypass_api_fixture
|
||||
hass: HomeAssistant,
|
||||
mock_roborock_entry: MockConfigEntry,
|
||||
bypass_api_fixture_v1_only,
|
||||
) -> None:
|
||||
"""Test that if we fail to get the maps, we still setup."""
|
||||
with patch(
|
||||
|
@ -136,7 +150,7 @@ async def test_reauth_started(
|
|||
) -> None:
|
||||
"""Test reauth flow started."""
|
||||
with patch(
|
||||
"homeassistant.components.roborock.RoborockApiClient.get_home_data",
|
||||
"homeassistant.components.roborock.RoborockApiClient.get_home_data_v2",
|
||||
side_effect=RoborockInvalidCredentials(),
|
||||
):
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
|
@ -145,3 +159,21 @@ async def test_reauth_started(
|
|||
flows = hass.config_entries.flow.async_progress()
|
||||
assert len(flows) == 1
|
||||
assert flows[0]["step_id"] == "reauth_confirm"
|
||||
|
||||
|
||||
async def test_not_supported_protocol(
|
||||
hass: HomeAssistant,
|
||||
bypass_api_fixture,
|
||||
mock_roborock_entry: MockConfigEntry,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test that we output a message on incorrect protocol."""
|
||||
home_data_copy = deepcopy(HOME_DATA)
|
||||
home_data_copy.received_devices[0].pv = "random"
|
||||
with patch(
|
||||
"homeassistant.components.roborock.RoborockApiClient.get_home_data_v2",
|
||||
return_value=home_data_copy,
|
||||
):
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
await hass.async_block_till_done()
|
||||
assert "because its protocol version random" in caplog.text
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue