Fix update of uncategorized OurGroceries items (#105255)
* Fix update of uncategorized OurGroceries items * Address code review comments
This commit is contained in:
parent
8a4b761c78
commit
c4d77877d2
2 changed files with 11 additions and 3 deletions
|
@ -89,7 +89,7 @@ class OurGroceriesTodoListEntity(
|
|||
if item.summary:
|
||||
api_items = self.coordinator.data[self._list_id]["list"]["items"]
|
||||
category = next(
|
||||
api_item["categoryId"]
|
||||
api_item.get("categoryId")
|
||||
for api_item in api_items
|
||||
if api_item["id"] == item.uid
|
||||
)
|
||||
|
|
|
@ -142,12 +142,20 @@ async def test_update_todo_item_status(
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("items"), [[{"id": "12345", "name": "Soda", "categoryId": "test_category"}]]
|
||||
("items", "category"),
|
||||
[
|
||||
(
|
||||
[{"id": "12345", "name": "Soda", "categoryId": "test_category"}],
|
||||
"test_category",
|
||||
),
|
||||
([{"id": "12345", "name": "Uncategorized"}], None),
|
||||
],
|
||||
)
|
||||
async def test_update_todo_item_summary(
|
||||
hass: HomeAssistant,
|
||||
setup_integration: None,
|
||||
ourgroceries: AsyncMock,
|
||||
category: str | None,
|
||||
) -> None:
|
||||
"""Test for updating an item summary."""
|
||||
|
||||
|
@ -171,7 +179,7 @@ async def test_update_todo_item_summary(
|
|||
)
|
||||
assert ourgroceries.change_item_on_list
|
||||
args = ourgroceries.change_item_on_list.call_args
|
||||
assert args.args == ("test_list", "12345", "test_category", "Milk")
|
||||
assert args.args == ("test_list", "12345", category, "Milk")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
Loading…
Add table
Reference in a new issue