mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 17:31:15 -04:00
Use bulk edit API to delete OurGroceries items (#182402)
This commit is contained in:
@@ -6,5 +6,5 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/ourgroceries",
|
||||
"integration_type": "service",
|
||||
"iot_class": "cloud_polling",
|
||||
"requirements": ["ourgroceries==1.5.4"]
|
||||
"requirements": ["ourgroceries==1.6.0"]
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
"""A todo platform for OurGroceries."""
|
||||
|
||||
import asyncio
|
||||
from typing import Any, override
|
||||
|
||||
from ourgroceries import make_delete_item_edit_record
|
||||
|
||||
from homeassistant.components.todo import (
|
||||
TodoItem,
|
||||
TodoItemStatus,
|
||||
@@ -109,11 +110,8 @@ class OurGroceriesTodoListEntity(
|
||||
@override
|
||||
async def async_delete_todo_items(self, uids: list[str]) -> None:
|
||||
"""Delete a To-do item."""
|
||||
await asyncio.gather(
|
||||
*[
|
||||
self.coordinator.og.remove_item_from_list(self._list_id, uid)
|
||||
for uid in uids
|
||||
]
|
||||
await self.coordinator.og.edit_items(
|
||||
self._list_id, [make_delete_item_edit_record(uid) for uid in uids]
|
||||
)
|
||||
await self.coordinator.async_refresh()
|
||||
|
||||
|
||||
Generated
+1
-1
@@ -1875,7 +1875,7 @@ orvibo==1.1.2
|
||||
ouman-eh-800-api==1.0.0
|
||||
|
||||
# homeassistant.components.ourgroceries
|
||||
ourgroceries==1.5.4
|
||||
ourgroceries==1.6.0
|
||||
|
||||
# homeassistant.components.ovo_energy
|
||||
ovoenergy==3.0.2
|
||||
|
||||
@@ -217,7 +217,7 @@ async def test_remove_todo_item(
|
||||
assert state
|
||||
assert state.state == "2"
|
||||
|
||||
ourgroceries.remove_item_from_list = AsyncMock()
|
||||
ourgroceries.edit_items = AsyncMock()
|
||||
# Fake API response when state is refreshed after remove
|
||||
_mock_version_id(ourgroceries, 2)
|
||||
ourgroceries.get_list_items.return_value = items_to_shopping_list([])
|
||||
@@ -229,10 +229,13 @@ async def test_remove_todo_item(
|
||||
target={ATTR_ENTITY_ID: "todo.test_list"},
|
||||
blocking=True,
|
||||
)
|
||||
assert ourgroceries.remove_item_from_list.call_count == 2
|
||||
args = ourgroceries.remove_item_from_list.call_args_list
|
||||
assert args[0].args == ("test_list", "12345")
|
||||
assert args[1].args == ("test_list", "54321")
|
||||
ourgroceries.edit_items.assert_called_once_with(
|
||||
"test_list",
|
||||
[
|
||||
{"editType": "delete", "itemId": "12345"},
|
||||
{"editType": "delete", "itemId": "54321"},
|
||||
],
|
||||
)
|
||||
|
||||
await async_update_entity(hass, "todo.test_list")
|
||||
state = hass.states.get("todo.test_list")
|
||||
|
||||
Reference in New Issue
Block a user