mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Add basic tests for temper USB temperature sensor integration (#80220)
* Add basic tests * Updated requriements_test_all.txt * Update temperusb version * Add type hints Co-authored-by: Christian Knittl-Frank <lcnittl@gmail.com> * Add type hints Co-authored-by: Christian Knittl-Frank <lcnittl@gmail.com> * Correct typo in type hint * Fix isort * Fix requirements_test_all.txt --------- Co-authored-by: Dave T <davet2001@users.noreply.github.com> Co-authored-by: Christian Knittl-Frank <lcnittl@gmail.com>
This commit is contained in:
parent
866518c5a0
commit
f081fa8feb
@ -1760,6 +1760,9 @@ tellduslive==0.10.11
|
|||||||
# homeassistant.components.lg_soundbar
|
# homeassistant.components.lg_soundbar
|
||||||
temescal==0.5
|
temescal==0.5
|
||||||
|
|
||||||
|
# homeassistant.components.temper
|
||||||
|
temperusb==1.6.0
|
||||||
|
|
||||||
# homeassistant.components.powerwall
|
# homeassistant.components.powerwall
|
||||||
tesla-powerwall==0.3.19
|
tesla-powerwall==0.3.19
|
||||||
|
|
||||||
|
1
tests/components/temper/__init__.py
Normal file
1
tests/components/temper/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
"""Tests for the temper integration."""
|
35
tests/components/temper/test_sensor.py
Normal file
35
tests/components/temper/test_sensor.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
"""The tests for the temper (USB temperature sensor) component."""
|
||||||
|
from datetime import timedelta
|
||||||
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.setup import async_setup_component
|
||||||
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
|
from tests.common import async_fire_time_changed
|
||||||
|
|
||||||
|
|
||||||
|
async def test_temperature_readback(hass: HomeAssistant) -> None:
|
||||||
|
"""Test for reading sensors."""
|
||||||
|
mock_temper_device = Mock()
|
||||||
|
mock_temper_device.get_temperature.return_value = 12.3
|
||||||
|
|
||||||
|
utcnow = dt_util.utcnow()
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
"temperusb.temper.TemperHandler.get_devices",
|
||||||
|
return_value=[mock_temper_device],
|
||||||
|
):
|
||||||
|
await async_setup_component(
|
||||||
|
hass,
|
||||||
|
"sensor",
|
||||||
|
{"sensor": {"platform": "temper", "name": "mydevicename"}},
|
||||||
|
)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
async_fire_time_changed(hass, utcnow + timedelta(seconds=70))
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
temperature = hass.states.get("sensor.mydevicename")
|
||||||
|
assert temperature
|
||||||
|
assert temperature.state == "12.3"
|
Loading…
x
Reference in New Issue
Block a user