Skip to content

Commit

Permalink
Fix patch of PLATFORMS constant in netatmo (home-assistant#101038)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Sep 29, 2023
1 parent b8a7ad9 commit 5082740
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions tests/components/netatmo/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ async def simulate_webhook(hass, webhook_id, response):
@contextmanager
def selected_platforms(platforms):
"""Restrict loaded platforms to list given."""
with patch("homeassistant.components.netatmo.PLATFORMS", platforms), patch(
with patch(
"homeassistant.components.netatmo.data_handler.PLATFORMS", platforms
), patch(
"homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation",
), patch("homeassistant.components.netatmo.webhook_generate_url"):
), patch(
"homeassistant.components.netatmo.webhook_generate_url"
):
yield
4 changes: 2 additions & 2 deletions tests/components/netatmo/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ async def fake_post_no_data(*args, **kwargs):
with patch(
"homeassistant.components.netatmo.api.AsyncConfigEntryNetatmoAuth"
) as mock_auth, patch(
"homeassistant.components.netatmo.PLATFORMS", ["camera"]
"homeassistant.components.netatmo.data_handler.PLATFORMS", ["camera"]
), patch(
"homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation",
), patch(
Expand All @@ -491,7 +491,7 @@ async def fake_post_no_data(*args, **kwargs):
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()

assert fake_post_hits == 11
assert fake_post_hits == 8


async def test_camera_image_raises_exception(
Expand Down
4 changes: 2 additions & 2 deletions tests/components/netatmo/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ async def test_setup_with_cloud(hass: HomeAssistant, config_entry) -> None:
) as fake_delete_cloudhook, patch(
"homeassistant.components.netatmo.api.AsyncConfigEntryNetatmoAuth"
) as mock_auth, patch(
"homeassistant.components.netatmo.PLATFORMS", []
"homeassistant.components.netatmo.data_handler.PLATFORMS", []
), patch(
"homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation",
), patch(
Expand Down Expand Up @@ -267,7 +267,7 @@ async def test_setup_with_cloudhook(hass: HomeAssistant) -> None:
) as fake_delete_cloudhook, patch(
"homeassistant.components.netatmo.api.AsyncConfigEntryNetatmoAuth"
) as mock_auth, patch(
"homeassistant.components.netatmo.PLATFORMS", []
"homeassistant.components.netatmo.data_handler.PLATFORMS", []
), patch(
"homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation",
), patch(
Expand Down
4 changes: 2 additions & 2 deletions tests/components/netatmo/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async def fake_post_request_no_data(*args, **kwargs):
with patch(
"homeassistant.components.netatmo.api.AsyncConfigEntryNetatmoAuth"
) as mock_auth, patch(
"homeassistant.components.netatmo.PLATFORMS", ["light"]
"homeassistant.components.netatmo.data_handler.PLATFORMS", ["light"]
), patch(
"homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation",
), patch(
Expand All @@ -120,7 +120,7 @@ async def fake_post_request_no_data(*args, **kwargs):
)
await hass.async_block_till_done()

assert fake_post_hits == 4
assert fake_post_hits == 3

assert hass.config_entries.async_entries(DOMAIN)
assert len(hass.states.async_all()) == 0
Expand Down

0 comments on commit 5082740

Please sign in to comment.