mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 14:57:09 +00:00
Clean off unnecessary logger in Workday (#98741)
This commit is contained in:
parent
180dd3d11a
commit
1a4fb90897
@ -7,7 +7,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryError
|
from homeassistant.exceptions import ConfigEntryError
|
||||||
|
|
||||||
from .const import CONF_COUNTRY, CONF_PROVINCE, LOGGER, PLATFORMS
|
from .const import CONF_COUNTRY, CONF_PROVINCE, PLATFORMS
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
@ -16,12 +16,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
country: str = entry.options[CONF_COUNTRY]
|
country: str = entry.options[CONF_COUNTRY]
|
||||||
province: str | None = entry.options.get(CONF_PROVINCE)
|
province: str | None = entry.options.get(CONF_PROVINCE)
|
||||||
if country and country not in list_supported_countries():
|
if country and country not in list_supported_countries():
|
||||||
LOGGER.error("There is no country %s", country)
|
raise ConfigEntryError(f"Selected country {country} is not valid")
|
||||||
raise ConfigEntryError("Selected country is not valid")
|
|
||||||
|
|
||||||
if province and province not in list_supported_countries()[country]:
|
if province and province not in list_supported_countries()[country]:
|
||||||
LOGGER.error("There is no subdivision %s in country %s", province, country)
|
raise ConfigEntryError(
|
||||||
raise ConfigEntryError("Selected province is not valid")
|
f"Selected province {province} for country {country} is not valid"
|
||||||
|
)
|
||||||
|
|
||||||
entry.async_on_unload(entry.add_update_listener(async_update_listener))
|
entry.async_on_unload(entry.add_update_listener(async_update_listener))
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ async def test_setup_faulty_country(
|
|||||||
state = hass.states.get("binary_sensor.workday_sensor")
|
state = hass.states.get("binary_sensor.workday_sensor")
|
||||||
assert state is None
|
assert state is None
|
||||||
|
|
||||||
assert "There is no country" in caplog.text
|
assert "Selected country ZZ is not valid" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_faulty_province(
|
async def test_setup_faulty_province(
|
||||||
@ -215,7 +215,7 @@ async def test_setup_faulty_province(
|
|||||||
state = hass.states.get("binary_sensor.workday_sensor")
|
state = hass.states.get("binary_sensor.workday_sensor")
|
||||||
assert state is None
|
assert state is None
|
||||||
|
|
||||||
assert "There is no subdivision" in caplog.text
|
assert "Selected province ZZ for country DE is not valid" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_incorrect_add_remove(
|
async def test_setup_incorrect_add_remove(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user