Skip to content

Commit eaf2643

Browse files
gjohansson-STfrenck
authored andcommitted
Fix can exclude optional holidays in workday (home-assistant#153082)
1 parent d8f6f17 commit eaf2643

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

homeassistant/components/workday/config_flow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def validate_custom_dates(user_input: dict[str, Any]) -> None:
155155
subdiv=province,
156156
years=year,
157157
language=language,
158+
categories=[PUBLIC, *user_input.get(CONF_CATEGORY, [])],
158159
)
159160

160161
else:

tests/components/workday/test_config_flow.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
CONF_CATEGORY,
1515
CONF_EXCLUDES,
1616
CONF_OFFSET,
17+
CONF_PROVINCE,
1718
CONF_REMOVE_HOLIDAYS,
1819
CONF_WORKDAYS,
1920
DEFAULT_EXCLUDES,
@@ -702,6 +703,53 @@ async def test_form_with_categories(hass: HomeAssistant) -> None:
702703
}
703704

704705

706+
async def test_form_with_categories_can_remove_day(hass: HomeAssistant) -> None:
707+
"""Test optional categories, days can be removed."""
708+
709+
result = await hass.config_entries.flow.async_init(
710+
DOMAIN, context={"source": config_entries.SOURCE_USER}
711+
)
712+
assert result["type"] is FlowResultType.FORM
713+
714+
result2 = await hass.config_entries.flow.async_configure(
715+
result["flow_id"],
716+
{
717+
CONF_NAME: "Workday Sensor",
718+
CONF_COUNTRY: "CH",
719+
},
720+
)
721+
await hass.async_block_till_done()
722+
result3 = await hass.config_entries.flow.async_configure(
723+
result2["flow_id"],
724+
{
725+
CONF_PROVINCE: "FR",
726+
CONF_EXCLUDES: DEFAULT_EXCLUDES,
727+
CONF_OFFSET: DEFAULT_OFFSET,
728+
CONF_WORKDAYS: DEFAULT_WORKDAYS,
729+
CONF_ADD_HOLIDAYS: [],
730+
CONF_REMOVE_HOLIDAYS: ["Berchtoldstag"],
731+
CONF_LANGUAGE: "de",
732+
CONF_CATEGORY: [OPTIONAL],
733+
},
734+
)
735+
await hass.async_block_till_done()
736+
737+
assert result3["type"] is FlowResultType.CREATE_ENTRY
738+
assert result3["title"] == "Workday Sensor"
739+
assert result3["options"] == {
740+
"name": "Workday Sensor",
741+
"country": "CH",
742+
"excludes": ["sat", "sun", "holiday"],
743+
"days_offset": 0,
744+
"workdays": ["mon", "tue", "wed", "thu", "fri"],
745+
"add_holidays": [],
746+
"province": "FR",
747+
"remove_holidays": ["Berchtoldstag"],
748+
"language": "de",
749+
"category": ["optional"],
750+
}
751+
752+
705753
async def test_options_form_removes_subdiv(hass: HomeAssistant) -> None:
706754
"""Test we get the form in options when removing a configured subdivision."""
707755

0 commit comments

Comments
 (0)