Replace the usage of unit constants by enumerations in Tests [h-l] (#85934)

This commit is contained in:
Michael
2023-01-15 14:52:55 +01:00
committed by GitHub
parent 72d3fa6d89
commit e35ab75c0b
16 changed files with 174 additions and 150 deletions

View File

@@ -48,8 +48,7 @@ from homeassistant.const import (
CONF_PORT,
CONF_TYPE,
STATE_UNKNOWN,
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
UnitOfTemperature,
)
from homeassistant.core import State
@@ -211,14 +210,14 @@ def test_cleanup_name_for_homekit():
def test_temperature_to_homekit():
"""Test temperature conversion from HA to HomeKit."""
assert temperature_to_homekit(20.46, TEMP_CELSIUS) == 20.5
assert temperature_to_homekit(92.1, TEMP_FAHRENHEIT) == 33.4
assert temperature_to_homekit(20.46, UnitOfTemperature.CELSIUS) == 20.5
assert temperature_to_homekit(92.1, UnitOfTemperature.FAHRENHEIT) == 33.4
def test_temperature_to_states():
"""Test temperature conversion from HomeKit to HA."""
assert temperature_to_states(20, TEMP_CELSIUS) == 20.0
assert temperature_to_states(20.2, TEMP_FAHRENHEIT) == 68.5
assert temperature_to_states(20, UnitOfTemperature.CELSIUS) == 20.0
assert temperature_to_states(20.2, UnitOfTemperature.FAHRENHEIT) == 68.5
def test_density_to_air_quality():