Add test coverage for onewire (#40786)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
epenetandMartin Hjelmare authored and GitHub committed 2020-10-14 10:19:12 +02:00
1 parent 6d05729e48
commit 3cba25a892
6 files changed
+357 -123

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
"""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()