* create foundation for Bond integration * add Bond hub integration (fix lint) * Update homeassistant/components/bond/__init__.py adding async_unload_entry per PR review suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * add Bond hub integration (fix missing import after applying PR suggestion) * Update tests/components/bond/test_init.py add a unit for unloading per PR review suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update tests/components/bond/test_init.py add unit test for unload per PR review suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update tests/components/bond/test_init.py PR review suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update tests/components/bond/test_init.py PR review suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update tests/components/bond/test_init.py PR review suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * add Bond hub integration (fix formatting) * Update homeassistant/components/bond/manifest.json PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update homeassistant/components/bond/manifest.json PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update homeassistant/components/bond/manifest.json PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update homeassistant/components/bond/strings.json PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update homeassistant/components/bond/manifest.json PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update requirements_all.txt PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update homeassistant/components/bond/manifest.json PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update requirements_test_all.txt PR suggestion Co-authored-by: Chris Talkington <chris@talkingtontech.com> * add Bond hub integration (remove friendly name from config per PR suggestion) * Update homeassistant/components/bond/__init__.py add per PR review feedback Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update homeassistant/components/bond/__init__.py remove per PR review feedback Co-authored-by: Chris Talkington <chris@talkingtontech.com> * Update tests/components/bond/test_init.py fix unit test Co-authored-by: Chris Talkington <chris@talkingtontech.com> Co-authored-by: Chris Talkington <chris@talkingtontech.com>
56 lines
2.1 KiB
Python
56 lines
2.1 KiB
Python
"""Tests for the Bond module."""
|
|
from homeassistant.components.bond.const import DOMAIN
|
|
from homeassistant.config_entries import ENTRY_STATE_LOADED, ENTRY_STATE_NOT_LOADED
|
|
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.setup import async_setup_component
|
|
|
|
from tests.async_mock import patch
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
async def test_async_setup_no_domain_config(hass: HomeAssistant):
|
|
"""Test setup without configuration is noop."""
|
|
result = await async_setup_component(hass, DOMAIN, {})
|
|
|
|
assert result is True
|
|
|
|
|
|
async def test_async_setup_entry_sets_up_supported_domains(hass: HomeAssistant):
|
|
"""Test that configuring entry sets up cover domain."""
|
|
config_entry = MockConfigEntry(
|
|
domain=DOMAIN, data={CONF_HOST: "1.1.1.1", CONF_ACCESS_TOKEN: "test-token"},
|
|
)
|
|
config_entry.add_to_hass(hass)
|
|
|
|
with patch(
|
|
"homeassistant.components.bond.cover.async_setup_entry"
|
|
) as mock_cover_async_setup_entry:
|
|
result = await hass.config_entries.async_setup(config_entry.entry_id)
|
|
assert result is True
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
assert len(mock_cover_async_setup_entry.mock_calls) == 1
|
|
|
|
|
|
async def test_unload_config_entry(hass: HomeAssistant):
|
|
"""Test that configuration entry supports unloading."""
|
|
config_entry = MockConfigEntry(
|
|
domain=DOMAIN, data={CONF_HOST: "1.1.1.1", CONF_ACCESS_TOKEN: "test-token"},
|
|
)
|
|
config_entry.add_to_hass(hass)
|
|
with patch(
|
|
"homeassistant.components.bond.cover.async_setup_entry", return_value=True
|
|
):
|
|
result = await hass.config_entries.async_setup(config_entry.entry_id)
|
|
assert result is True
|
|
await hass.async_block_till_done()
|
|
assert config_entry.entry_id in hass.data[DOMAIN]
|
|
assert config_entry.state == ENTRY_STATE_LOADED
|
|
|
|
await hass.config_entries.async_unload(config_entry.entry_id)
|
|
await hass.async_block_till_done()
|
|
|
|
assert config_entry.entry_id not in hass.data[DOMAIN]
|
|
assert config_entry.state == ENTRY_STATE_NOT_LOADED
|