mirror of
https://github.com/home-assistant/core.git
synced 2026-02-15 07:36:16 +00:00
Fix can exclude optional holidays in workday (#153082)
This commit is contained in:
@@ -155,6 +155,7 @@ def validate_custom_dates(user_input: dict[str, Any]) -> None:
|
||||
subdiv=province,
|
||||
years=year,
|
||||
language=language,
|
||||
categories=[PUBLIC, *user_input.get(CONF_CATEGORY, [])],
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
@@ -14,6 +14,7 @@ from homeassistant.components.workday.const import (
|
||||
CONF_CATEGORY,
|
||||
CONF_EXCLUDES,
|
||||
CONF_OFFSET,
|
||||
CONF_PROVINCE,
|
||||
CONF_REMOVE_HOLIDAYS,
|
||||
CONF_WORKDAYS,
|
||||
DEFAULT_EXCLUDES,
|
||||
@@ -702,6 +703,53 @@ async def test_form_with_categories(hass: HomeAssistant) -> None:
|
||||
}
|
||||
|
||||
|
||||
async def test_form_with_categories_can_remove_day(hass: HomeAssistant) -> None:
|
||||
"""Test optional categories, days can be removed."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{
|
||||
CONF_NAME: "Workday Sensor",
|
||||
CONF_COUNTRY: "CH",
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result2["flow_id"],
|
||||
{
|
||||
CONF_PROVINCE: "FR",
|
||||
CONF_EXCLUDES: DEFAULT_EXCLUDES,
|
||||
CONF_OFFSET: DEFAULT_OFFSET,
|
||||
CONF_WORKDAYS: DEFAULT_WORKDAYS,
|
||||
CONF_ADD_HOLIDAYS: [],
|
||||
CONF_REMOVE_HOLIDAYS: ["Berchtoldstag"],
|
||||
CONF_LANGUAGE: "de",
|
||||
CONF_CATEGORY: [OPTIONAL],
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == "Workday Sensor"
|
||||
assert result3["options"] == {
|
||||
"name": "Workday Sensor",
|
||||
"country": "CH",
|
||||
"excludes": ["sat", "sun", "holiday"],
|
||||
"days_offset": 0,
|
||||
"workdays": ["mon", "tue", "wed", "thu", "fri"],
|
||||
"add_holidays": [],
|
||||
"province": "FR",
|
||||
"remove_holidays": ["Berchtoldstag"],
|
||||
"language": "de",
|
||||
"category": ["optional"],
|
||||
}
|
||||
|
||||
|
||||
async def test_options_form_removes_subdiv(hass: HomeAssistant) -> None:
|
||||
"""Test we get the form in options when removing a configured subdivision."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user