|
14 | 14 | CONF_CATEGORY, |
15 | 15 | CONF_EXCLUDES, |
16 | 16 | CONF_OFFSET, |
| 17 | + CONF_PROVINCE, |
17 | 18 | CONF_REMOVE_HOLIDAYS, |
18 | 19 | CONF_WORKDAYS, |
19 | 20 | DEFAULT_EXCLUDES, |
@@ -702,6 +703,53 @@ async def test_form_with_categories(hass: HomeAssistant) -> None: |
702 | 703 | } |
703 | 704 |
|
704 | 705 |
|
| 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 | + |
705 | 753 | async def test_options_form_removes_subdiv(hass: HomeAssistant) -> None: |
706 | 754 | """Test we get the form in options when removing a configured subdivision.""" |
707 | 755 |
|
|
0 commit comments