mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 10:29:27 +00:00
Get Litter-Robot to 100% code coverage and minor code cleanup (#58704)
This commit is contained in:
@@ -59,6 +59,12 @@ def mock_account_with_no_robots() -> MagicMock:
|
||||
return create_mock_account(skip_robots=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_account_with_sleeping_robot() -> MagicMock:
|
||||
"""Mock a Litter-Robot account with a sleeping robot."""
|
||||
return create_mock_account({"sleepModeActive": "102:00:00"})
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_account_with_error() -> MagicMock:
|
||||
"""Mock a Litter-Robot account with error."""
|
||||
|
||||
@@ -12,6 +12,7 @@ from homeassistant.components.litterrobot.vacuum import (
|
||||
SERVICE_SET_WAIT_TIME,
|
||||
)
|
||||
from homeassistant.components.vacuum import (
|
||||
ATTR_STATUS,
|
||||
DOMAIN as PLATFORM_DOMAIN,
|
||||
SERVICE_START,
|
||||
SERVICE_TURN_OFF,
|
||||
@@ -46,6 +47,17 @@ async def test_vacuum(hass: HomeAssistant, mock_account):
|
||||
assert vacuum.attributes["is_sleeping"] is False
|
||||
|
||||
|
||||
async def test_vacuum_status_when_sleeping(
|
||||
hass: HomeAssistant, mock_account_with_sleeping_robot
|
||||
):
|
||||
"""Tests the vacuum status when sleeping."""
|
||||
await setup_integration(hass, mock_account_with_sleeping_robot, PLATFORM_DOMAIN)
|
||||
|
||||
vacuum = hass.states.get(VACUUM_ENTITY_ID)
|
||||
assert vacuum
|
||||
assert vacuum.attributes.get(ATTR_STATUS) == "Ready (Sleeping)"
|
||||
|
||||
|
||||
async def test_no_robots(hass: HomeAssistant, mock_account_with_no_robots):
|
||||
"""Tests the vacuum entity was set up."""
|
||||
await setup_integration(hass, mock_account_with_no_robots, PLATFORM_DOMAIN)
|
||||
|
||||
Reference in New Issue
Block a user