hass-core/tests/components/roborock/test_init.py
Luke b4e0a1f1fc
Add new Roborock Integration (#89456)
* init roborock commit

* init commit of roborock

* removed some non-vacuum related code

* removed some non-needed constants

* removed translations

* removed options flow

* removed manual control

* remove password login

* removed go-to

* removed unneeded function and improved device_stat

* removed utils as it is unused

* typing changes in vacuum.py

* fixed test patch paths

* removed unneeded records

* removing unneeded code in tests

* remove password from strings

* removed maps in code

* changed const, reworked functions

* remove menu

* fixed tests

* 100% code coverage config_flow

* small changes

* removed unneeded patch

* bump to 0.1.7

* removed services

* removed extra functions and mop

* add () to configEntryNotReady

* moved coordinator into seperate file

* update roborock testing

* removed stale options code

* normalize username for unique id

* removed unneeded variables

* fixed linter problems

* removed stale comment

* additional pr changes

* simplify config_flow

* fix config flow test

* Apply suggestions from code review

Co-authored-by: Allen Porter <allen.porter@gmail.com>

* First pass at resolving PR comments

* reworked config flow

* moving vacuum attr

* attempt to clean up conflig flow more

* update package and use offline functionality

* Fixed errors and fan bug

* rework model and some other small changes

* bump version

* used default factory

* moved some client creation into coord

* fixed patch

* Update homeassistant/components/roborock/coordinator.py

Co-authored-by: Allen Porter <allen.porter@gmail.com>

* moved async functions into gather

* reworked gathers

* removed random line

* error catch if networking doesn't exist or timeout

* bump to 0.6.5

* fixed mocked data reference url

* change checking if we have no network information

Co-authored-by: Allen Porter <allen.porter@gmail.com>

---------

Co-authored-by: Allen Porter <allen.porter@gmail.com>
Co-authored-by: Allen Porter <allen@thebends.org>
2023-04-20 07:02:58 -07:00

35 lines
1.4 KiB
Python

"""Test for Roborock init."""
from unittest.mock import patch
from homeassistant.components.roborock.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import UpdateFailed
from .common import setup_platform
async def test_unload_entry(hass: HomeAssistant, bypass_api_fixture) -> None:
"""Test unloading roboorck integration."""
entry = await setup_platform(hass, Platform.VACUUM)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state is ConfigEntryState.LOADED
with patch(
"homeassistant.components.roborock.coordinator.RoborockLocalClient.async_disconnect"
) as mock_disconnect:
assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done()
assert mock_disconnect.call_count == 1
assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN)
async def test_config_entry_not_ready(hass: HomeAssistant) -> None:
"""Test that when coordinator update fails, entry retries."""
with patch(
"homeassistant.components.roborock.RoborockDataUpdateCoordinator._async_update_data",
side_effect=UpdateFailed(),
):
entry = await setup_platform(hass, Platform.VACUUM)
assert entry.state is ConfigEntryState.SETUP_RETRY