Files
core/tests/components/bond/common.py
Eugene Prystupa 1e9bc278e0 Refactor Bond integration to remove duplication (#37740)
* Refactor Bond integration to remove duplication in Entity code and unit tests

* Refactor Bond integration to remove duplication in Entity code and unit tests (PR feedback)
2020-07-10 20:20:50 -05:00

35 lines
1.2 KiB
Python

"""Common methods used across tests for Bond."""
from typing import Any, Dict
from homeassistant import core
from homeassistant.components.bond.const import DOMAIN as BOND_DOMAIN
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST
from homeassistant.setup import async_setup_component
from tests.async_mock import patch
from tests.common import MockConfigEntry
async def setup_platform(
hass: core.HomeAssistant, platform: str, discovered_device: Dict[str, Any]
):
"""Set up the specified Bond platform."""
mock_entry = MockConfigEntry(
domain=BOND_DOMAIN,
data={CONF_HOST: "1.1.1.1", CONF_ACCESS_TOKEN: "test-token"},
)
mock_entry.add_to_hass(hass)
with patch("homeassistant.components.bond.PLATFORMS", [platform]), patch(
"homeassistant.components.bond.Bond.getDeviceIds",
return_value=["bond-device-id"],
), patch(
"homeassistant.components.bond.Bond.getDevice", return_value=discovered_device
), patch(
"homeassistant.components.bond.Bond.getDeviceState", return_value={}
):
assert await async_setup_component(hass, BOND_DOMAIN, {})
await hass.async_block_till_done()
return mock_entry