mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Fix test coverage in workday (#133616)
This commit is contained in:
parent
6b666b3a0f
commit
11efec49db
@ -94,7 +94,11 @@ def _get_obj_holidays(
|
||||
language=language,
|
||||
categories=set_categories,
|
||||
)
|
||||
if (supported_languages := obj_holidays.supported_languages) and language == "en":
|
||||
if (
|
||||
(supported_languages := obj_holidays.supported_languages)
|
||||
and language
|
||||
and language.startswith("en")
|
||||
):
|
||||
for lang in supported_languages:
|
||||
if lang.startswith("en"):
|
||||
obj_holidays = country_holidays(
|
||||
|
@ -136,7 +136,7 @@ def validate_custom_dates(user_input: dict[str, Any]) -> None:
|
||||
|
||||
year: int = dt_util.now().year
|
||||
if country := user_input.get(CONF_COUNTRY):
|
||||
language = user_input.get(CONF_LANGUAGE)
|
||||
language: str | None = user_input.get(CONF_LANGUAGE)
|
||||
province = user_input.get(CONF_PROVINCE)
|
||||
obj_holidays = country_holidays(
|
||||
country=country,
|
||||
@ -145,8 +145,10 @@ def validate_custom_dates(user_input: dict[str, Any]) -> None:
|
||||
language=language,
|
||||
)
|
||||
if (
|
||||
supported_languages := obj_holidays.supported_languages
|
||||
) and language == "en":
|
||||
(supported_languages := obj_holidays.supported_languages)
|
||||
and language
|
||||
and language.startswith("en")
|
||||
):
|
||||
for lang in supported_languages:
|
||||
if lang.startswith("en"):
|
||||
obj_holidays = country_holidays(
|
||||
|
@ -653,3 +653,48 @@ async def test_form_with_categories(hass: HomeAssistant) -> None:
|
||||
"language": "de",
|
||||
"category": ["half_day"],
|
||||
}
|
||||
|
||||
|
||||
async def test_options_form_removes_subdiv(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form in options when removing a configured subdivision."""
|
||||
|
||||
entry = await init_integration(
|
||||
hass,
|
||||
{
|
||||
"name": "Workday Sensor",
|
||||
"country": "DE",
|
||||
"excludes": ["sat", "sun", "holiday"],
|
||||
"days_offset": 0,
|
||||
"workdays": ["mon", "tue", "wed", "thu", "fri"],
|
||||
"add_holidays": [],
|
||||
"remove_holidays": [],
|
||||
"language": "de",
|
||||
"province": "BW",
|
||||
},
|
||||
)
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
result2 = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
"excludes": ["sat", "sun", "holiday"],
|
||||
"days_offset": 0,
|
||||
"workdays": ["mon", "tue", "wed", "thu", "fri"],
|
||||
"add_holidays": [],
|
||||
"remove_holidays": [],
|
||||
"language": "de",
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"] == {
|
||||
"name": "Workday Sensor",
|
||||
"country": "DE",
|
||||
"excludes": ["sat", "sun", "holiday"],
|
||||
"days_offset": 0,
|
||||
"workdays": ["mon", "tue", "wed", "thu", "fri"],
|
||||
"add_holidays": [],
|
||||
"remove_holidays": [],
|
||||
"language": "de",
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user