Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.4 KiB
Python
Raw Permalink Normal View History

2022-07-24 02:51:14 -05:00
"""Test the Moat sensors."""
2022-07-24 02:51:14 -05:00
from homeassistant.components.moat.const import DOMAIN
from homeassistant.components.sensor import ATTR_STATE_CLASS
from homeassistant.const import ATTR_FRIENDLY_NAME, ATTR_UNIT_OF_MEASUREMENT
from homeassistant.core import HomeAssistant
2022-07-24 02:51:14 -05:00
from . import MOAT_S2_SERVICE_INFO
from tests.common import MockConfigEntry
from tests.components.bluetooth import inject_bluetooth_service_info
2022-07-24 02:51:14 -05:00
async def test_sensors(hass: HomeAssistant) -> None:
2022-07-24 02:51:14 -05:00
"""Test setting up creates the sensors."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id="aa:bb:cc:dd:ee:ff",
2022-07-24 02:51:14 -05:00
)
entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
2022-07-24 02:51:14 -05:00
assert len(hass.states.async_all()) == 0
inject_bluetooth_service_info(hass, MOAT_S2_SERVICE_INFO)
2022-07-24 02:51:14 -05:00
await hass.async_block_till_done()
assert len(hass.states.async_all()) == 4
temp_sensor = hass.states.get("sensor.moat_s2_eeff_voltage")
temp_sensor_attribtes = temp_sensor.attributes
assert temp_sensor.state == "3.061"
assert temp_sensor_attribtes[ATTR_FRIENDLY_NAME] == "Moat S2 EEFF Voltage"
assert temp_sensor_attribtes[ATTR_UNIT_OF_MEASUREMENT] == "V"
assert temp_sensor_attribtes[ATTR_STATE_CLASS] == "measurement"
assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done()