Get Litter-Robot to 100% code coverage and minor code cleanup (#58704)

This commit is contained in:
Nathan Spencer
2021-10-30 08:13:03 -06:00
committed by GitHub
parent bbbbcfbb93
commit aacc009cbb
6 changed files with 35 additions and 18 deletions

View File

@@ -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."""

View File

@@ -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)