Skip to content

Commit 4c5be85

Browse files
committed
⬆️ Refactor hot water test methods to improve type hinting and return handling
1 parent 92136b7 commit 4c5be85

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

tests/test_bsblan_edge_cases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async def test_validate_api_section_key_error(monkeypatch: Any) -> None:
3737
# Set up basic initialization
3838
bsblan._firmware_version = "1.0.38-20200730234859"
3939
bsblan._api_version = "v3"
40-
bsblan._api_data = {"other_section": {}} # Missing section
40+
bsblan._api_data = {"other_section": {}} # type: ignore[assignment]
4141

4242
# Mock API validator
4343
mock_validator = MagicMock()
@@ -53,7 +53,7 @@ async def test_validate_api_section_key_error(monkeypatch: Any) -> None:
5353
BSBLANError,
5454
match="Section 'nonexistent' not found in API data",
5555
):
56-
await bsblan._validate_api_section("nonexistent")
56+
await bsblan._validate_api_section("nonexistent") # type: ignore[arg-type]
5757

5858

5959
@pytest.mark.asyncio

tests/test_hot_water_additional.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ def mock_request(**kwargs: Any) -> dict[str, Any]:
5454
param_string = kwargs.get("params", {}).get("Parameter", "")
5555
if param_string:
5656
requested_param_ids = param_string.split(",")
57-
return {
57+
result: dict[str, Any] = {
5858
param_id: fixture_data[param_id]
5959
for param_id in requested_param_ids
6060
if param_id in fixture_data
6161
}
62+
return result
6263
return fixture_data
6364

6465
request_mock = AsyncMock(side_effect=mock_request)
@@ -196,11 +197,12 @@ def mock_request(**kwargs: Any) -> dict[str, Any]:
196197
param_string = kwargs.get("params", {}).get("Parameter", "")
197198
if param_string:
198199
requested_param_ids = param_string.split(",")
199-
return {
200+
result: dict[str, Any] = {
200201
param_id: schedule_fixture_data[param_id]
201202
for param_id in requested_param_ids
202203
if param_id in schedule_fixture_data
203204
}
205+
return result
204206
return schedule_fixture_data
205207

206208
request_mock = AsyncMock(side_effect=mock_request)
@@ -278,7 +280,7 @@ async def test_populate_hot_water_cache_no_validator() -> None:
278280
bsblan = BSBLAN(config)
279281

280282
# Ensure no validator is set
281-
bsblan._api_validator = None
283+
bsblan._api_validator = None # type: ignore[assignment]
282284

283285
# Should not raise an error, just return without doing anything
284286
bsblan._populate_hot_water_cache()

tests/test_hotwater_state.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ def mock_request(**kwargs: Any) -> dict[str, Any]:
7373
if param_string:
7474
requested_param_ids = param_string.split(",")
7575
# Return only the requested parameters from the fixture
76-
return {
76+
result: dict[str, Any] = {
7777
param_id: fixture_data[param_id]
7878
for param_id in requested_param_ids
7979
if param_id in fixture_data
8080
}
81+
return result
8182
return fixture_data
8283

8384
request_mock = AsyncMock(side_effect=mock_request)

0 commit comments

Comments
 (0)