Set todo item status in intent (#105743)
parent
e055306482
commit
6c5ca58405
|
@ -6,7 +6,7 @@ from homeassistant.helpers import intent
|
|||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
|
||||
from . import DOMAIN, TodoItem, TodoListEntity
|
||||
from . import DOMAIN, TodoItem, TodoItemStatus, TodoListEntity
|
||||
|
||||
INTENT_LIST_ADD_ITEM = "HassListAddItem"
|
||||
|
||||
|
@ -47,7 +47,9 @@ class ListAddItemIntent(intent.IntentHandler):
|
|||
assert target_list is not None
|
||||
|
||||
# Add to list
|
||||
await target_list.async_create_todo_item(TodoItem(item))
|
||||
await target_list.async_create_todo_item(
|
||||
TodoItem(summary=item, status=TodoItemStatus.NEEDS_ACTION)
|
||||
)
|
||||
|
||||
response = intent_obj.create_response()
|
||||
response.response_type = intent.IntentResponseType.ACTION_DONE
|
||||
|
|
|
@ -1038,6 +1038,7 @@ async def test_add_item_intent(
|
|||
assert len(entity1.items) == 1
|
||||
assert len(entity2.items) == 0
|
||||
assert entity1.items[0].summary == "beer"
|
||||
assert entity1.items[0].status == TodoItemStatus.NEEDS_ACTION
|
||||
entity1.items.clear()
|
||||
|
||||
# Add to second list
|
||||
|
@ -1052,6 +1053,7 @@ async def test_add_item_intent(
|
|||
assert len(entity1.items) == 0
|
||||
assert len(entity2.items) == 1
|
||||
assert entity2.items[0].summary == "cheese"
|
||||
assert entity2.items[0].status == TodoItemStatus.NEEDS_ACTION
|
||||
|
||||
# List name is case insensitive
|
||||
response = await intent.async_handle(
|
||||
|
@ -1065,6 +1067,7 @@ async def test_add_item_intent(
|
|||
assert len(entity1.items) == 0
|
||||
assert len(entity2.items) == 2
|
||||
assert entity2.items[1].summary == "wine"
|
||||
assert entity2.items[1].status == TodoItemStatus.NEEDS_ACTION
|
||||
|
||||
# Missing list
|
||||
with pytest.raises(intent.IntentHandleError):
|
||||
|
|
Loading…
Reference in New Issue