Log config_flow errors for waze_travel_time (#79352)

This commit is contained in:
Kevin Stillhammer 2022-10-01 17:56:47 +02:00 committed by GitHub
parent 886e636565
commit 31ddf6cc31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -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