From 31ddf6cc31aaaf08a09cd6afa9eb830450d1817d Mon Sep 17 00:00:00 2001 From: Kevin Stillhammer Date: Sat, 1 Oct 2022 17:56:47 +0200 Subject: [PATCH] Log config_flow errors for waze_travel_time (#79352) --- homeassistant/components/waze_travel_time/helpers.py | 7 ++++++- tests/components/waze_travel_time/test_config_flow.py | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/waze_travel_time/helpers.py b/homeassistant/components/waze_travel_time/helpers.py index 67d8b5674b2..8468bb8ea9a 100644 --- a/homeassistant/components/waze_travel_time/helpers.py +++ b/homeassistant/components/waze_travel_time/helpers.py @@ -1,8 +1,12 @@ """Helpers for Waze Travel Time integration.""" +import logging + from WazeRouteCalculator import WazeRouteCalculator, WRCError from homeassistant.helpers.location import find_coordinates +_LOGGER = logging.getLogger(__name__) + def is_valid_config_entry(hass, origin, destination, region): """Return whether the config entry data is valid.""" @@ -10,6 +14,7 @@ def is_valid_config_entry(hass, origin, destination, region): destination = find_coordinates(hass, destination) try: WazeRouteCalculator(origin, destination, region).calc_all_routes_info() - except WRCError: + except WRCError as error: + _LOGGER.error("Error trying to validate entry: %s", error) return False return True diff --git a/tests/components/waze_travel_time/test_config_flow.py b/tests/components/waze_travel_time/test_config_flow.py index c4b8144b74d..bc343792218 100644 --- a/tests/components/waze_travel_time/test_config_flow.py +++ b/tests/components/waze_travel_time/test_config_flow.py @@ -176,7 +176,7 @@ async def test_dupe(hass): @pytest.mark.usefixtures("invalidate_config_entry") -async def test_invalid_config_entry(hass): +async def test_invalid_config_entry(hass, caplog): """Test we get the form.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} @@ -190,3 +190,5 @@ async def test_invalid_config_entry(hass): assert result2["type"] == data_entry_flow.FlowResultType.FORM assert result2["errors"] == {"base": "cannot_connect"} + + assert "Error trying to validate entry" in caplog.text