11"""Tests for temperature unit handling in BSBLAN."""
2+ # pylint: disable=protected-access
23
34from unittest .mock import AsyncMock , patch
45
@@ -14,10 +15,10 @@ async def test_temperature_unit_getter() -> None:
1415 """Test the get_temperature_unit property."""
1516 config = BSBLANConfig (host = "example.com" )
1617 bsblan = BSBLAN (config )
17-
18+
1819 # Test default unit
1920 assert bsblan .get_temperature_unit == "°C"
20-
21+
2122 # Test with custom unit set
2223 bsblan ._temperature_unit = "°F"
2324 assert bsblan .get_temperature_unit == "°F"
@@ -28,16 +29,16 @@ async def test_initialize_temperature_range_celsius() -> None:
2829 """Test initialization of temperature range with Celsius unit."""
2930 config = BSBLANConfig (host = "example.com" )
3031 bsblan = BSBLAN (config )
31-
32+
3233 # Create mock static values with Celsius unit
3334 min_temp = EntityInfo (name = "Min Temp" , value = "10" , unit = "°C" , desc = "" , data_type = 0 )
3435 max_temp = EntityInfo (name = "Max Temp" , value = "30" , unit = "°C" , desc = "" , data_type = 0 )
3536 static_values = StaticState (min_temp = min_temp , max_temp = max_temp )
36-
37+
3738 # Mock static_values method to return our test data
3839 with patch .object (bsblan , "static_values" , AsyncMock (return_value = static_values )):
3940 await bsblan ._initialize_temperature_range ()
40-
41+
4142 # Verify temperature range was set correctly
4243 assert bsblan ._min_temp == 10.0
4344 assert bsblan ._max_temp == 30.0
@@ -50,16 +51,16 @@ async def test_initialize_temperature_range_fahrenheit() -> None:
5051 """Test initialization of temperature range with Fahrenheit unit."""
5152 config = BSBLANConfig (host = "example.com" )
5253 bsblan = BSBLAN (config )
53-
54+
5455 # Create mock static values with Fahrenheit unit
5556 min_temp = EntityInfo (name = "Min Temp" , value = "50" , unit = "°F" , desc = "" , data_type = 0 )
5657 max_temp = EntityInfo (name = "Max Temp" , value = "86" , unit = "°F" , desc = "" , data_type = 0 )
5758 static_values = StaticState (min_temp = min_temp , max_temp = max_temp )
58-
59+
5960 # Mock static_values method to return our test data
6061 with patch .object (bsblan , "static_values" , AsyncMock (return_value = static_values )):
6162 await bsblan ._initialize_temperature_range ()
62-
63+
6364 # Verify temperature range was set correctly
6465 assert bsblan ._min_temp == 50.0
6566 assert bsblan ._max_temp == 86.0
@@ -69,21 +70,28 @@ async def test_initialize_temperature_range_fahrenheit() -> None:
6970
7071@pytest .mark .asyncio
7172async def test_initialize_temperature_range_alternate_celsius_format () -> None :
72- """Test initialization of temperature range with alternate Celsius format (°C)."""
73+ """Test initialization of temperature range with alternate Celsius format.
74+
75+ Tests with HTML entity format (°C) instead of unicode character.
76+ """
7377 config = BSBLANConfig (host = "example.com" )
7478 bsblan = BSBLAN (config )
75-
79+
7680 # Create mock static values with HTML degree symbol
77- min_temp = EntityInfo (name = "Min Temp" , value = "10" , unit = "°C" , desc = "" , data_type = 0 )
78- max_temp = EntityInfo (name = "Max Temp" , value = "30" , unit = "°C" , desc = "" , data_type = 0 )
81+ min_temp = EntityInfo (
82+ name = "Min Temp" , value = "10" , unit = "°C" , desc = "" , data_type = 0
83+ )
84+ max_temp = EntityInfo (
85+ name = "Max Temp" , value = "30" , unit = "°C" , desc = "" , data_type = 0
86+ )
7987 static_values = StaticState (min_temp = min_temp , max_temp = max_temp )
80-
88+
8189 # Mock static_values method to return our test data
8290 with patch .object (bsblan , "static_values" , AsyncMock (return_value = static_values )):
8391 await bsblan ._initialize_temperature_range ()
84-
92+
8593 # Verify temperature range was set correctly
8694 assert bsblan ._min_temp == 10.0
8795 assert bsblan ._max_temp == 30.0
8896 assert bsblan ._temperature_range_initialized is True
89- assert bsblan ._temperature_unit == "°C"
97+ assert bsblan ._temperature_unit == "°C"
0 commit comments