mirror of
https://github.com/home-assistant/core.git
synced 2026-04-21 00:45:42 +00:00
Improve TodoItem addition in tests
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user