Remove deprecated `hass.components` from withings webhook tests (#113687)

* Remove deprecated `hass.components` from withings webhook tests

* Use patch.object
This commit is contained in:
Jan-Philipp Benecke 2024-03-17 17:48:58 +01:00 committed by GitHub
parent 681705394d
commit 324c922c0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 20 deletions

View File

@ -16,6 +16,7 @@ import pytest
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import cloud
from homeassistant.components.cloud import CloudNotAvailable
from homeassistant.components.webhook import async_generate_url
from homeassistant.components.withings import CONFIG_SCHEMA, async_setup
@ -298,9 +299,7 @@ async def test_setup_with_cloudhook(
"homeassistant.components.cloud.async_is_logged_in", return_value=True
), patch(
"homeassistant.components.cloud.async_is_connected", return_value=True
), patch(
"homeassistant.components.cloud.async_active_subscription", return_value=True
), patch(
), patch.object(cloud, "async_active_subscription", return_value=True), patch(
"homeassistant.components.cloud.async_create_cloudhook",
return_value="https://hooks.nabu.casa/ABCD",
) as fake_create_cloudhook, patch(
@ -311,7 +310,8 @@ async def test_setup_with_cloudhook(
"homeassistant.components.withings.webhook_generate_url"
):
await setup_integration(hass, cloudhook_config_entry)
assert hass.components.cloud.async_active_subscription() is True
assert cloud.async_active_subscription(hass) is True
assert (
hass.config_entries.async_entries(DOMAIN)[0].data["cloudhook_url"]
@ -342,9 +342,7 @@ async def test_removing_entry_with_cloud_unavailable(
"homeassistant.components.cloud.async_is_logged_in", return_value=True
), patch(
"homeassistant.components.cloud.async_is_connected", return_value=True
), patch(
"homeassistant.components.cloud.async_active_subscription", return_value=True
), patch(
), patch.object(cloud, "async_active_subscription", return_value=True), patch(
"homeassistant.components.cloud.async_create_cloudhook",
return_value="https://hooks.nabu.casa/ABCD",
), patch(
@ -356,7 +354,8 @@ async def test_removing_entry_with_cloud_unavailable(
"homeassistant.components.withings.webhook_generate_url",
):
await setup_integration(hass, cloudhook_config_entry)
assert hass.components.cloud.async_active_subscription() is True
assert cloud.async_active_subscription(hass) is True
await hass.async_block_till_done()
assert hass.config_entries.async_entries(DOMAIN)
@ -380,10 +379,8 @@ async def test_setup_with_cloud(
with patch(
"homeassistant.components.cloud.async_is_logged_in", return_value=True
), patch(
"homeassistant.components.cloud.async_is_connected", return_value=True
), patch(
"homeassistant.components.cloud.async_active_subscription", return_value=True
), patch.object(cloud, "async_is_connected", return_value=True), patch.object(
cloud, "async_active_subscription", return_value=True
), patch(
"homeassistant.components.cloud.async_create_cloudhook",
return_value="https://hooks.nabu.casa/ABCD",
@ -397,8 +394,8 @@ async def test_setup_with_cloud(
await setup_integration(hass, webhook_config_entry)
await prepare_webhook_setup(hass, freezer)
assert hass.components.cloud.async_active_subscription() is True
assert hass.components.cloud.async_is_connected() is True
assert cloud.async_active_subscription(hass) is True
assert cloud.async_is_connected(hass) is True
fake_create_cloudhook.assert_called_once()
fake_delete_cloudhook.assert_called_once()
@ -460,10 +457,8 @@ async def test_cloud_disconnect(
with patch(
"homeassistant.components.cloud.async_is_logged_in", return_value=True
), patch(
"homeassistant.components.cloud.async_is_connected", return_value=True
), patch(
"homeassistant.components.cloud.async_active_subscription", return_value=True
), patch.object(cloud, "async_is_connected", return_value=True), patch.object(
cloud, "async_active_subscription", return_value=True
), patch(
"homeassistant.components.cloud.async_create_cloudhook",
return_value="https://hooks.nabu.casa/ABCD",
@ -476,8 +471,9 @@ async def test_cloud_disconnect(
):
await setup_integration(hass, webhook_config_entry)
await prepare_webhook_setup(hass, freezer)
assert hass.components.cloud.async_active_subscription() is True
assert hass.components.cloud.async_is_connected() is True
assert cloud.async_active_subscription(hass) is True
assert cloud.async_is_connected(hass) is True
await hass.async_block_till_done()