Skip to content

Commit

Permalink
refactor fixtures in conftest.py and test_set_hotwater.py; improve ty…
Browse files Browse the repository at this point in the history
…pe hinting and code clarity
  • Loading branch information
liudger committed Sep 30, 2024
1 parent faf5c16 commit 072faf1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 4 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Fixtures for the BSBLAN tests."""

import json
from typing import Any, AsyncGenerator
from unittest.mock import AsyncMock
Expand All @@ -12,9 +13,9 @@


@pytest.fixture

async def mock_bsblan(
aresponses: ResponsesMockServer, monkeypatch: Any,
aresponses: ResponsesMockServer,
monkeypatch: Any,
) -> AsyncGenerator[BSBLAN, Any]:
"""Fixture to create a mocked BSBLAN instance."""
monkeypatch.setenv("BSBLAN_PASS", "your_password")
Expand All @@ -34,6 +35,6 @@ async def mock_bsblan(
monkeypatch.setattr(bsblan, "_firmware_version", "1.0.38-20200730234859")
monkeypatch.setattr(bsblan, "_api_version", "v3")
monkeypatch.setattr(bsblan, "_api_data", API_V3)
request_mock = AsyncMock(return_value={"status": "ok"})
request_mock: AsyncMock = AsyncMock(return_value={"status": "ok"})
monkeypatch.setattr(bsblan, "_request", request_mock)
yield bsblan
2 changes: 0 additions & 2 deletions tests/test_set_hotwater.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
from bsblan import BSBLAN, BSBLANError
from bsblan.constants import MULTI_PARAMETER_ERROR_MSG, NO_STATE_ERROR_MSG

request_mock: AsyncMock = AsyncMock(return_value={"status": "ok"})


@pytest.mark.asyncio
async def test_set_hot_water(mock_bsblan: BSBLAN) -> None:
Expand Down

0 comments on commit 072faf1

Please sign in to comment.