Skip to content

Commit

Permalink
Reuse fixtures in config flow tests for Whirlpool (#136489)
Browse files Browse the repository at this point in the history
* Use fixtures in config flow tests for Whirlpool

* Keep old tests; new one will go to separate PR
  • Loading branch information
abmantis authored Jan 25, 2025
1 parent 821abc8 commit 42f7bd0
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 168 deletions.
31 changes: 24 additions & 7 deletions tests/components/whirlpool/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ def fixture_brand(request: pytest.FixtureRequest) -> tuple[str, Brand]:
@pytest.fixture(name="mock_auth_api")
def fixture_mock_auth_api():
"""Set up Auth fixture."""
with mock.patch("homeassistant.components.whirlpool.Auth") as mock_auth:
with (
mock.patch("homeassistant.components.whirlpool.Auth") as mock_auth,
mock.patch(
"homeassistant.components.whirlpool.config_flow.Auth", new=mock_auth
),
):
mock_auth.return_value.do_auth = AsyncMock()
mock_auth.return_value.is_access_token_valid.return_value = True
yield mock_auth
Expand All @@ -48,9 +53,15 @@ def fixture_mock_auth_api():
@pytest.fixture(name="mock_appliances_manager_api")
def fixture_mock_appliances_manager_api():
"""Set up AppliancesManager fixture."""
with mock.patch(
"homeassistant.components.whirlpool.AppliancesManager"
) as mock_appliances_manager:
with (
mock.patch(
"homeassistant.components.whirlpool.AppliancesManager"
) as mock_appliances_manager,
mock.patch(
"homeassistant.components.whirlpool.config_flow.AppliancesManager",
new=mock_appliances_manager,
),
):
mock_appliances_manager.return_value.fetch_appliances = AsyncMock()
mock_appliances_manager.return_value.aircons = [
{"SAID": MOCK_SAID1, "NAME": "TestZone"},
Expand Down Expand Up @@ -81,9 +92,15 @@ def fixture_mock_appliances_manager_laundry_api():
@pytest.fixture(name="mock_backend_selector_api")
def fixture_mock_backend_selector_api():
"""Set up BackendSelector fixture."""
with mock.patch(
"homeassistant.components.whirlpool.BackendSelector"
) as mock_backend_selector:
with (
mock.patch(
"homeassistant.components.whirlpool.BackendSelector"
) as mock_backend_selector,
mock.patch(
"homeassistant.components.whirlpool.config_flow.BackendSelector",
new=mock_backend_selector,
),
):
yield mock_backend_selector


Expand Down
Loading

0 comments on commit 42f7bd0

Please sign in to comment.