Improve TodoItem addition in tests

This commit is contained in:
abmantis
2026-03-18 22:14:23 +00:00
parent be66e3c7e9
commit 2ebfcfa070
2 changed files with 4 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
"""Tests for the To-do integration."""
import dataclasses
import uuid
from homeassistant.components.todo import DOMAIN, TodoItem, TodoListEntity
@@ -31,13 +32,7 @@ class MockTodoListEntity(TodoListEntity):
async def async_create_todo_item(self, item: TodoItem) -> None:
"""Add an item to the To-do list."""
self._attr_todo_items.append(
TodoItem(
summary=item.summary,
uid=item.uid or uuid.uuid4().hex,
status=item.status,
due=item.due,
description=item.description,
)
dataclasses.replace(item, uid=item.uid or uuid.uuid4().hex)
)
async def async_delete_todo_items(self, uids: list[str]) -> None:

View File

@@ -1,4 +1,4 @@
"""Tests for the todo item_added trigger."""
"""Tests for the todo triggers."""
from typing import Any
@@ -136,7 +136,7 @@ def _assert_service_calls(
async def _setup_automation(hass: HomeAssistant, target: dict[str, Any]) -> None:
"""Set up an automation with the todo.item_added trigger."""
"""Set up an automation with the todo trigger."""
assert await async_setup_component(
hass,
automation.DOMAIN,