mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
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:
parent
681705394d
commit
324c922c0d
@ -16,6 +16,7 @@ import pytest
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components import cloud
|
||||||
from homeassistant.components.cloud import CloudNotAvailable
|
from homeassistant.components.cloud import CloudNotAvailable
|
||||||
from homeassistant.components.webhook import async_generate_url
|
from homeassistant.components.webhook import async_generate_url
|
||||||
from homeassistant.components.withings import CONFIG_SCHEMA, async_setup
|
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
|
"homeassistant.components.cloud.async_is_logged_in", return_value=True
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.cloud.async_is_connected", return_value=True
|
"homeassistant.components.cloud.async_is_connected", return_value=True
|
||||||
), patch(
|
), patch.object(cloud, "async_active_subscription", return_value=True), patch(
|
||||||
"homeassistant.components.cloud.async_active_subscription", return_value=True
|
|
||||||
), patch(
|
|
||||||
"homeassistant.components.cloud.async_create_cloudhook",
|
"homeassistant.components.cloud.async_create_cloudhook",
|
||||||
return_value="https://hooks.nabu.casa/ABCD",
|
return_value="https://hooks.nabu.casa/ABCD",
|
||||||
) as fake_create_cloudhook, patch(
|
) as fake_create_cloudhook, patch(
|
||||||
@ -311,7 +310,8 @@ async def test_setup_with_cloudhook(
|
|||||||
"homeassistant.components.withings.webhook_generate_url"
|
"homeassistant.components.withings.webhook_generate_url"
|
||||||
):
|
):
|
||||||
await setup_integration(hass, cloudhook_config_entry)
|
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 (
|
assert (
|
||||||
hass.config_entries.async_entries(DOMAIN)[0].data["cloudhook_url"]
|
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
|
"homeassistant.components.cloud.async_is_logged_in", return_value=True
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.cloud.async_is_connected", return_value=True
|
"homeassistant.components.cloud.async_is_connected", return_value=True
|
||||||
), patch(
|
), patch.object(cloud, "async_active_subscription", return_value=True), patch(
|
||||||
"homeassistant.components.cloud.async_active_subscription", return_value=True
|
|
||||||
), patch(
|
|
||||||
"homeassistant.components.cloud.async_create_cloudhook",
|
"homeassistant.components.cloud.async_create_cloudhook",
|
||||||
return_value="https://hooks.nabu.casa/ABCD",
|
return_value="https://hooks.nabu.casa/ABCD",
|
||||||
), patch(
|
), patch(
|
||||||
@ -356,7 +354,8 @@ async def test_removing_entry_with_cloud_unavailable(
|
|||||||
"homeassistant.components.withings.webhook_generate_url",
|
"homeassistant.components.withings.webhook_generate_url",
|
||||||
):
|
):
|
||||||
await setup_integration(hass, cloudhook_config_entry)
|
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()
|
await hass.async_block_till_done()
|
||||||
assert hass.config_entries.async_entries(DOMAIN)
|
assert hass.config_entries.async_entries(DOMAIN)
|
||||||
@ -380,10 +379,8 @@ async def test_setup_with_cloud(
|
|||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.cloud.async_is_logged_in", return_value=True
|
"homeassistant.components.cloud.async_is_logged_in", return_value=True
|
||||||
), patch(
|
), patch.object(cloud, "async_is_connected", return_value=True), patch.object(
|
||||||
"homeassistant.components.cloud.async_is_connected", return_value=True
|
cloud, "async_active_subscription", return_value=True
|
||||||
), patch(
|
|
||||||
"homeassistant.components.cloud.async_active_subscription", return_value=True
|
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.cloud.async_create_cloudhook",
|
"homeassistant.components.cloud.async_create_cloudhook",
|
||||||
return_value="https://hooks.nabu.casa/ABCD",
|
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 setup_integration(hass, webhook_config_entry)
|
||||||
await prepare_webhook_setup(hass, freezer)
|
await prepare_webhook_setup(hass, freezer)
|
||||||
|
|
||||||
assert hass.components.cloud.async_active_subscription() is True
|
assert cloud.async_active_subscription(hass) is True
|
||||||
assert hass.components.cloud.async_is_connected() is True
|
assert cloud.async_is_connected(hass) is True
|
||||||
fake_create_cloudhook.assert_called_once()
|
fake_create_cloudhook.assert_called_once()
|
||||||
fake_delete_cloudhook.assert_called_once()
|
fake_delete_cloudhook.assert_called_once()
|
||||||
|
|
||||||
@ -460,10 +457,8 @@ async def test_cloud_disconnect(
|
|||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.cloud.async_is_logged_in", return_value=True
|
"homeassistant.components.cloud.async_is_logged_in", return_value=True
|
||||||
), patch(
|
), patch.object(cloud, "async_is_connected", return_value=True), patch.object(
|
||||||
"homeassistant.components.cloud.async_is_connected", return_value=True
|
cloud, "async_active_subscription", return_value=True
|
||||||
), patch(
|
|
||||||
"homeassistant.components.cloud.async_active_subscription", return_value=True
|
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.cloud.async_create_cloudhook",
|
"homeassistant.components.cloud.async_create_cloudhook",
|
||||||
return_value="https://hooks.nabu.casa/ABCD",
|
return_value="https://hooks.nabu.casa/ABCD",
|
||||||
@ -476,8 +471,9 @@ async def test_cloud_disconnect(
|
|||||||
):
|
):
|
||||||
await setup_integration(hass, webhook_config_entry)
|
await setup_integration(hass, webhook_config_entry)
|
||||||
await prepare_webhook_setup(hass, freezer)
|
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()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user