diff --git a/homeassistant/components/netatmo/__init__.py b/homeassistant/components/netatmo/__init__.py index 2ada6577df4..8c8c848f4e3 100644 --- a/homeassistant/components/netatmo/__init__.py +++ b/homeassistant/components/netatmo/__init__.py @@ -12,6 +12,7 @@ import voluptuous as vol from homeassistant.components import cloud from homeassistant.components.webhook import ( + async_generate_url as webhook_generate_url, async_register as webhook_register, async_unregister as webhook_unregister, ) @@ -192,9 +193,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: else: webhook_url = entry.data[CONF_CLOUDHOOK_URL] else: - webhook_url = hass.components.webhook.async_generate_url( - entry.data[CONF_WEBHOOK_ID] - ) + webhook_url = webhook_generate_url(hass, entry.data[CONF_WEBHOOK_ID]) if entry.data[ "auth_implementation" diff --git a/tests/components/netatmo/common.py b/tests/components/netatmo/common.py index 55083171a1a..784b428e8d0 100644 --- a/tests/components/netatmo/common.py +++ b/tests/components/netatmo/common.py @@ -106,5 +106,5 @@ def selected_platforms(platforms): """Restrict loaded platforms to list given.""" with patch("homeassistant.components.netatmo.PLATFORMS", platforms), patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", - ), patch("homeassistant.components.webhook.async_generate_url"): + ), patch("homeassistant.components.netatmo.webhook_generate_url"): yield diff --git a/tests/components/netatmo/test_camera.py b/tests/components/netatmo/test_camera.py index 45c8dc48b22..b1cee88ee2f 100644 --- a/tests/components/netatmo/test_camera.py +++ b/tests/components/netatmo/test_camera.py @@ -345,7 +345,7 @@ async def test_camera_reconnect_webhook(hass, config_entry): ), patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", ), patch( - "homeassistant.components.webhook.async_generate_url" + "homeassistant.components.netatmo.webhook_generate_url" ) as mock_webhook: mock_auth.return_value.async_post_request.side_effect = fake_post mock_auth.return_value.async_addwebhook.side_effect = AsyncMock() @@ -437,7 +437,7 @@ async def test_setup_component_no_devices(hass, config_entry): ), patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", ), patch( - "homeassistant.components.webhook.async_generate_url" + "homeassistant.components.netatmo.webhook_generate_url" ): mock_auth.return_value.async_post_request.side_effect = fake_post_no_data mock_auth.return_value.async_addwebhook.side_effect = AsyncMock() @@ -475,7 +475,7 @@ async def test_camera_image_raises_exception(hass, config_entry, requests_mock): ), patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", ), patch( - "homeassistant.components.webhook.async_generate_url" + "homeassistant.components.netatmo.webhook_generate_url" ): mock_auth.return_value.async_post_request.side_effect = fake_post mock_auth.return_value.async_get_image.side_effect = fake_post diff --git a/tests/components/netatmo/test_init.py b/tests/components/netatmo/test_init.py index 418854a61a2..950a45f1e4a 100644 --- a/tests/components/netatmo/test_init.py +++ b/tests/components/netatmo/test_init.py @@ -58,7 +58,7 @@ async def test_setup_component(hass, config_entry): ) as mock_auth, patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", ) as mock_impl, patch( - "homeassistant.components.webhook.async_generate_url" + "homeassistant.components.netatmo.webhook_generate_url" ) as mock_webhook: mock_auth.return_value.async_post_request.side_effect = fake_post_request mock_auth.return_value.async_addwebhook.side_effect = AsyncMock() @@ -96,7 +96,7 @@ async def test_setup_component_with_config(hass, config_entry): with patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", ) as mock_impl, patch( - "homeassistant.components.webhook.async_generate_url" + "homeassistant.components.netatmo.webhook_generate_url" ) as mock_webhook, patch( "homeassistant.components.netatmo.api.AsyncConfigEntryNetatmoAuth", ) as mock_auth, patch( @@ -160,7 +160,7 @@ async def test_setup_without_https(hass, config_entry, caplog): ) as mock_auth, patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", ), patch( - "homeassistant.components.webhook.async_generate_url" + "homeassistant.components.netatmo.webhook_generate_url" ) as mock_async_generate_url: mock_auth.return_value.async_post_request.side_effect = fake_post_request mock_async_generate_url.return_value = "http://example.com" @@ -196,7 +196,7 @@ async def test_setup_with_cloud(hass, config_entry): ), patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", ), patch( - "homeassistant.components.webhook.async_generate_url" + "homeassistant.components.netatmo.webhook_generate_url" ): mock_auth.return_value.async_post_request.side_effect = fake_post_request assert await async_setup_component( @@ -259,7 +259,7 @@ async def test_setup_with_cloudhook(hass): ), patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", ), patch( - "homeassistant.components.webhook.async_generate_url" + "homeassistant.components.netatmo.webhook_generate_url" ): mock_auth.return_value.async_post_request.side_effect = fake_post_request mock_auth.return_value.async_addwebhook.side_effect = AsyncMock() @@ -291,7 +291,7 @@ async def test_setup_component_api_error(hass, config_entry): ) as mock_auth, patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", ) as mock_impl, patch( - "homeassistant.components.webhook.async_generate_url" + "homeassistant.components.netatmo.webhook_generate_url" ): mock_auth.return_value.async_post_request.side_effect = ( pyatmo.exceptions.ApiError() @@ -314,7 +314,7 @@ async def test_setup_component_api_timeout(hass, config_entry): ) as mock_auth, patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", ) as mock_impl, patch( - "homeassistant.components.webhook.async_generate_url" + "homeassistant.components.netatmo.webhook_generate_url" ): mock_auth.return_value.async_post_request.side_effect = ( asyncio.exceptions.TimeoutError() @@ -341,7 +341,7 @@ async def test_setup_component_with_delay(hass, config_entry): ) as mock_dropwebhook, patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", ) as mock_impl, patch( - "homeassistant.components.webhook.async_generate_url" + "homeassistant.components.netatmo.webhook_generate_url" ) as mock_webhook, patch( "pyatmo.AbstractAsyncAuth.async_post_request", side_effect=fake_post_request ) as mock_post_request, patch( @@ -415,7 +415,7 @@ async def test_setup_component_invalid_token_scope(hass): ) as mock_auth, patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", ) as mock_impl, patch( - "homeassistant.components.webhook.async_generate_url" + "homeassistant.components.netatmo.webhook_generate_url" ) as mock_webhook: mock_auth.return_value.async_post_request.side_effect = fake_post_request mock_auth.return_value.async_addwebhook.side_effect = AsyncMock() @@ -456,7 +456,7 @@ async def test_setup_component_invalid_token(hass, config_entry): ) as mock_auth, patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", ) as mock_impl, patch( - "homeassistant.components.webhook.async_generate_url" + "homeassistant.components.netatmo.webhook_generate_url" ) as mock_webhook, patch( "homeassistant.helpers.config_entry_oauth2_flow.OAuth2Session" ) as mock_session: diff --git a/tests/components/netatmo/test_light.py b/tests/components/netatmo/test_light.py index 6abbb646055..d28df01becc 100644 --- a/tests/components/netatmo/test_light.py +++ b/tests/components/netatmo/test_light.py @@ -98,7 +98,7 @@ async def test_setup_component_no_devices(hass, config_entry): ), patch( "homeassistant.helpers.config_entry_oauth2_flow.async_get_config_entry_implementation", ), patch( - "homeassistant.components.webhook.async_generate_url" + "homeassistant.components.netatmo.webhook_generate_url" ): mock_auth.return_value.async_post_request.side_effect = ( fake_post_request_no_data