Switch to dataclass from dictionary for climacell sensor definitions (#53168)
* Switch to dataclass from dictionary for climacell sensor definitions * fix post_init * fix dataclass and add test * Update homeassistant/components/climacell/sensor.py Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> * Update homeassistant/components/climacell/const.py Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> * simplify logic * use tuple * simplify unit of measurement and use class attributes * Switch from UnitT to str Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
This commit is contained in:
parent
7711ac901c
commit
562aa74c77
4 changed files with 282 additions and 317 deletions
12
tests/components/climacell/test_const.py
Normal file
12
tests/components/climacell/test_const.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
"""Tests for ClimaCell const."""
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.climacell.const import ClimaCellSensorMetadata
|
||||
from homeassistant.const import TEMP_FAHRENHEIT
|
||||
|
||||
|
||||
async def test_post_init():
|
||||
"""Test post initiailization check for ClimaCellSensorMetadata."""
|
||||
|
||||
with pytest.raises(RuntimeError):
|
||||
ClimaCellSensorMetadata("a", "b", unit_imperial=TEMP_FAHRENHEIT)
|
Loading…
Add table
Add a link
Reference in a new issue