mirror of
https://github.com/home-assistant/core.git
synced 2025-09-07 13:51:39 +02:00
Fix schedule entity can't delete icon (#150995)
This commit is contained in:
@@ -242,7 +242,7 @@ class ScheduleStorageCollection(DictStorageCollection):
|
|||||||
async def _update_data(self, item: dict, update_data: dict) -> dict:
|
async def _update_data(self, item: dict, update_data: dict) -> dict:
|
||||||
"""Return a new updated data object."""
|
"""Return a new updated data object."""
|
||||||
self.SCHEMA(update_data)
|
self.SCHEMA(update_data)
|
||||||
return item | update_data
|
return {CONF_ID: item[CONF_ID]} | update_data
|
||||||
|
|
||||||
async def _async_load_data(self) -> SerializedStorageCollection | None:
|
async def _async_load_data(self) -> SerializedStorageCollection | None:
|
||||||
"""Load the data."""
|
"""Load the data."""
|
||||||
|
@@ -617,11 +617,26 @@ async def test_ws_delete(
|
|||||||
|
|
||||||
@pytest.mark.freeze_time("2022-08-10 20:10:00-07:00")
|
@pytest.mark.freeze_time("2022-08-10 20:10:00-07:00")
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("to", "next_event", "saved_to"),
|
("to", "next_event", "saved_to", "icon_dict"),
|
||||||
[
|
[
|
||||||
("23:59:59", "2022-08-10T23:59:59-07:00", "23:59:59"),
|
(
|
||||||
("24:00", "2022-08-11T00:00:00-07:00", "24:00:00"),
|
"23:59:59",
|
||||||
("24:00:00", "2022-08-11T00:00:00-07:00", "24:00:00"),
|
"2022-08-10T23:59:59-07:00",
|
||||||
|
"23:59:59",
|
||||||
|
{CONF_ICON: "mdi:party-pooper"},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"24:00",
|
||||||
|
"2022-08-11T00:00:00-07:00",
|
||||||
|
"24:00:00",
|
||||||
|
{CONF_ICON: "mdi:party-popper"},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"24:00:00",
|
||||||
|
"2022-08-11T00:00:00-07:00",
|
||||||
|
"24:00:00",
|
||||||
|
{},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_update(
|
async def test_update(
|
||||||
@@ -632,6 +647,7 @@ async def test_update(
|
|||||||
to: str,
|
to: str,
|
||||||
next_event: str,
|
next_event: str,
|
||||||
saved_to: str,
|
saved_to: str,
|
||||||
|
icon_dict: dict,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test updating the schedule."""
|
"""Test updating the schedule."""
|
||||||
assert await schedule_setup()
|
assert await schedule_setup()
|
||||||
@@ -654,7 +670,7 @@ async def test_update(
|
|||||||
"type": f"{DOMAIN}/update",
|
"type": f"{DOMAIN}/update",
|
||||||
f"{DOMAIN}_id": "from_storage",
|
f"{DOMAIN}_id": "from_storage",
|
||||||
CONF_NAME: "Party pooper",
|
CONF_NAME: "Party pooper",
|
||||||
CONF_ICON: "mdi:party-pooper",
|
**icon_dict,
|
||||||
CONF_MONDAY: [],
|
CONF_MONDAY: [],
|
||||||
CONF_TUESDAY: [],
|
CONF_TUESDAY: [],
|
||||||
CONF_WEDNESDAY: [{CONF_FROM: "17:00:00", CONF_TO: to}],
|
CONF_WEDNESDAY: [{CONF_FROM: "17:00:00", CONF_TO: to}],
|
||||||
@@ -671,7 +687,7 @@ async def test_update(
|
|||||||
assert state
|
assert state
|
||||||
assert state.state == STATE_ON
|
assert state.state == STATE_ON
|
||||||
assert state.attributes[ATTR_FRIENDLY_NAME] == "Party pooper"
|
assert state.attributes[ATTR_FRIENDLY_NAME] == "Party pooper"
|
||||||
assert state.attributes[ATTR_ICON] == "mdi:party-pooper"
|
assert state.attributes.get(ATTR_ICON) == icon_dict.get(CONF_ICON)
|
||||||
assert state.attributes[ATTR_NEXT_EVENT].isoformat() == next_event
|
assert state.attributes[ATTR_NEXT_EVENT].isoformat() == next_event
|
||||||
|
|
||||||
await client.send_json({"id": 2, "type": f"{DOMAIN}/list"})
|
await client.send_json({"id": 2, "type": f"{DOMAIN}/list"})
|
||||||
|
Reference in New Issue
Block a user