hass-core/tests/components/onewire/test_sensor.py
epenet 3cba25a892
Add test coverage for onewire (#40786)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-10-14 10:19:12 +02:00

43 lines
1.6 KiB
Python

"""Tests for 1-Wire sensor platform."""
from homeassistant.components.onewire.const import DEFAULT_SYSBUS_MOUNT_DIR
import homeassistant.components.sensor as sensor
from homeassistant.setup import async_setup_component
from tests.common import assert_setup_component
async def test_setup_minimum(hass):
"""Test setup with minimum configuration."""
config = {"sensor": {"platform": "onewire"}}
with assert_setup_component(1, "sensor"):
assert await async_setup_component(hass, sensor.DOMAIN, config)
await hass.async_block_till_done()
async def test_setup_sysbus(hass):
"""Test setup with SysBus configuration."""
config = {
"sensor": {
"platform": "onewire",
"mount_dir": DEFAULT_SYSBUS_MOUNT_DIR,
}
}
with assert_setup_component(1, "sensor"):
assert await async_setup_component(hass, sensor.DOMAIN, config)
await hass.async_block_till_done()
async def test_setup_owserver(hass):
"""Test setup with OWServer configuration."""
config = {"sensor": {"platform": "onewire", "host": "localhost"}}
with assert_setup_component(1, "sensor"):
assert await async_setup_component(hass, sensor.DOMAIN, config)
await hass.async_block_till_done()
async def test_setup_owserver_with_port(hass):
"""Test setup with OWServer configuration."""
config = {"sensor": {"platform": "onewire", "host": "localhost", "port": "1234"}}
with assert_setup_component(1, "sensor"):
assert await async_setup_component(hass, sensor.DOMAIN, config)
await hass.async_block_till_done()