Change litterrobot integration to cloud_push (#77741)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
0b4e4e81d4
commit
cc51052be5
11 changed files with 77 additions and 167 deletions
|
@ -56,7 +56,7 @@ async def test_entry_not_setup(hass, side_effect, expected_state):
|
|||
entry.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"pylitterbot.Account.connect",
|
||||
"homeassistant.components.litterrobot.hub.Account.connect",
|
||||
side_effect=side_effect,
|
||||
):
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
"""Test the Litter-Robot select entity."""
|
||||
from datetime import timedelta
|
||||
|
||||
from pylitterbot import LitterRobot3
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.litterrobot.entity import REFRESH_WAIT_TIME_SECONDS
|
||||
from homeassistant.components.select import (
|
||||
ATTR_OPTION,
|
||||
DOMAIN as PLATFORM_DOMAIN,
|
||||
|
@ -14,12 +11,9 @@ from homeassistant.const import ATTR_ENTITY_ID
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from .conftest import setup_integration
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
SELECT_ENTITY_ID = "select.test_clean_cycle_wait_time_minutes"
|
||||
|
||||
|
||||
|
@ -49,8 +43,6 @@ async def test_wait_time_select(hass: HomeAssistant, mock_account):
|
|||
blocking=True,
|
||||
)
|
||||
|
||||
future = utcnow() + timedelta(seconds=REFRESH_WAIT_TIME_SECONDS)
|
||||
async_fire_time_changed(hass, future)
|
||||
assert mock_account.robots[0].set_wait_time.call_count == count
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
"""Test the Litter-Robot switch entity."""
|
||||
from datetime import timedelta
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from pylitterbot import Robot
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.litterrobot.entity import REFRESH_WAIT_TIME_SECONDS
|
||||
from homeassistant.components.switch import (
|
||||
DOMAIN as PLATFORM_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
|
@ -14,12 +13,9 @@ from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from .conftest import setup_integration
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
NIGHT_LIGHT_MODE_ENTITY_ID = "switch.test_night_light_mode"
|
||||
PANEL_LOCKOUT_ENTITY_ID = "switch.test_panel_lockout"
|
||||
|
||||
|
@ -39,17 +35,22 @@ async def test_switch(hass: HomeAssistant, mock_account: MagicMock):
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"entity_id,robot_command",
|
||||
"entity_id,robot_command,updated_field",
|
||||
[
|
||||
(NIGHT_LIGHT_MODE_ENTITY_ID, "set_night_light"),
|
||||
(PANEL_LOCKOUT_ENTITY_ID, "set_panel_lockout"),
|
||||
(NIGHT_LIGHT_MODE_ENTITY_ID, "set_night_light", "nightLightActive"),
|
||||
(PANEL_LOCKOUT_ENTITY_ID, "set_panel_lockout", "panelLockActive"),
|
||||
],
|
||||
)
|
||||
async def test_on_off_commands(
|
||||
hass: HomeAssistant, mock_account: MagicMock, entity_id: str, robot_command: str
|
||||
hass: HomeAssistant,
|
||||
mock_account: MagicMock,
|
||||
entity_id: str,
|
||||
robot_command: str,
|
||||
updated_field: str,
|
||||
):
|
||||
"""Test sending commands to the switch."""
|
||||
await setup_integration(hass, mock_account, PLATFORM_DOMAIN)
|
||||
robot: Robot = mock_account.robots[0]
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
assert state
|
||||
|
@ -57,19 +58,17 @@ async def test_on_off_commands(
|
|||
data = {ATTR_ENTITY_ID: entity_id}
|
||||
|
||||
count = 0
|
||||
for service in [SERVICE_TURN_ON, SERVICE_TURN_OFF]:
|
||||
for service in (SERVICE_TURN_ON, SERVICE_TURN_OFF):
|
||||
count += 1
|
||||
|
||||
await hass.services.async_call(
|
||||
PLATFORM_DOMAIN,
|
||||
service,
|
||||
data,
|
||||
blocking=True,
|
||||
)
|
||||
robot._update_data({updated_field: 1 if service == SERVICE_TURN_ON else 0})
|
||||
|
||||
future = utcnow() + timedelta(seconds=REFRESH_WAIT_TIME_SECONDS)
|
||||
async_fire_time_changed(hass, future)
|
||||
assert getattr(mock_account.robots[0], robot_command).call_count == count
|
||||
assert getattr(robot, robot_command).call_count == count
|
||||
state = hass.states.get(entity_id)
|
||||
assert state
|
||||
assert state.state == STATE_ON if service == SERVICE_TURN_ON else STATE_OFF
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
"""Test the Litter-Robot vacuum entity."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.litterrobot import DOMAIN
|
||||
from homeassistant.components.litterrobot.entity import REFRESH_WAIT_TIME_SECONDS
|
||||
from homeassistant.components.litterrobot.vacuum import SERVICE_SET_SLEEP_MODE
|
||||
from homeassistant.components.vacuum import (
|
||||
ATTR_STATUS,
|
||||
|
@ -22,13 +20,10 @@ from homeassistant.components.vacuum import (
|
|||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.entity_registry as er
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from .common import VACUUM_ENTITY_ID
|
||||
from .conftest import setup_integration
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
VACUUM_UNIQUE_ID_OLD = "LR3C012345-Litter Box"
|
||||
VACUUM_UNIQUE_ID_NEW = "LR3C012345-litter_box"
|
||||
|
||||
|
@ -141,7 +136,5 @@ async def test_commands(
|
|||
data,
|
||||
blocking=True,
|
||||
)
|
||||
future = utcnow() + timedelta(seconds=REFRESH_WAIT_TIME_SECONDS)
|
||||
async_fire_time_changed(hass, future)
|
||||
getattr(mock_account.robots[0], command).assert_called_once()
|
||||
assert (f"'{DOMAIN}.{service}' service is deprecated" in caplog.text) is deprecated
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue