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