mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Log config_flow errors for waze_travel_time (#79352)
This commit is contained in:
parent
886e636565
commit
31ddf6cc31
@ -1,8 +1,12 @@
|
|||||||
"""Helpers for Waze Travel Time integration."""
|
"""Helpers for Waze Travel Time integration."""
|
||||||
|
import logging
|
||||||
|
|
||||||
from WazeRouteCalculator import WazeRouteCalculator, WRCError
|
from WazeRouteCalculator import WazeRouteCalculator, WRCError
|
||||||
|
|
||||||
from homeassistant.helpers.location import find_coordinates
|
from homeassistant.helpers.location import find_coordinates
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def is_valid_config_entry(hass, origin, destination, region):
|
def is_valid_config_entry(hass, origin, destination, region):
|
||||||
"""Return whether the config entry data is valid."""
|
"""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)
|
destination = find_coordinates(hass, destination)
|
||||||
try:
|
try:
|
||||||
WazeRouteCalculator(origin, destination, region).calc_all_routes_info()
|
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 False
|
||||||
return True
|
return True
|
||||||
|
@ -176,7 +176,7 @@ async def test_dupe(hass):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("invalidate_config_entry")
|
@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."""
|
"""Test we get the form."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
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["type"] == data_entry_flow.FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
assert "Error trying to validate entry" in caplog.text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user