Skip to content

Commit

Permalink
Exclude Todoist sub-tasks for the todo platform (#104914)
Browse files Browse the repository at this point in the history
  • Loading branch information
boralyl authored Dec 4, 2023
1 parent 35e2f59 commit 677c50a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions homeassistant/components/todoist/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def _handle_coordinator_update(self) -> None:
for task in self.coordinator.data:
if task.project_id != self._project_id:
continue
if task.parent_id is not None:
# Filter out sub-tasks until they are supported by the UI.
continue
if task.is_completed:
status = TodoItemStatus.COMPLETED
else:
Expand Down
3 changes: 2 additions & 1 deletion tests/components/todoist/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def make_api_task(
due: Due | None = None,
project_id: str | None = None,
description: str | None = None,
parent_id: str | None = None,
) -> Task:
"""Mock a todoist Task instance."""
return Task(
Expand All @@ -61,7 +62,7 @@ def make_api_task(
id=id or "1",
labels=["Label1"],
order=1,
parent_id=None,
parent_id=parent_id,
priority=1,
project_id=project_id or PROJECT_ID,
section_id=None,
Expand Down
8 changes: 8 additions & 0 deletions tests/components/todoist/test_todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def set_time_zone(hass: HomeAssistant) -> None:
],
"0",
),
(
[
make_api_task(
id="12345", content="sub-task", is_completed=False, parent_id="1"
)
],
"0",
),
],
)
async def test_todo_item_state(
Expand Down

0 comments on commit 677c50a

Please sign in to comment.