mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Set todo item status in intent (#105743)
This commit is contained in:
parent
8bfb6b5745
commit
f1f3301edc
@ -6,7 +6,7 @@ from homeassistant.helpers import intent
|
|||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
|
|
||||||
from . import DOMAIN, TodoItem, TodoListEntity
|
from . import DOMAIN, TodoItem, TodoItemStatus, TodoListEntity
|
||||||
|
|
||||||
INTENT_LIST_ADD_ITEM = "HassListAddItem"
|
INTENT_LIST_ADD_ITEM = "HassListAddItem"
|
||||||
|
|
||||||
@ -47,7 +47,9 @@ class ListAddItemIntent(intent.IntentHandler):
|
|||||||
assert target_list is not None
|
assert target_list is not None
|
||||||
|
|
||||||
# Add to list
|
# 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 = intent_obj.create_response()
|
||||||
response.response_type = intent.IntentResponseType.ACTION_DONE
|
response.response_type = intent.IntentResponseType.ACTION_DONE
|
||||||
|
@ -1038,6 +1038,7 @@ async def test_add_item_intent(
|
|||||||
assert len(entity1.items) == 1
|
assert len(entity1.items) == 1
|
||||||
assert len(entity2.items) == 0
|
assert len(entity2.items) == 0
|
||||||
assert entity1.items[0].summary == "beer"
|
assert entity1.items[0].summary == "beer"
|
||||||
|
assert entity1.items[0].status == TodoItemStatus.NEEDS_ACTION
|
||||||
entity1.items.clear()
|
entity1.items.clear()
|
||||||
|
|
||||||
# Add to second list
|
# Add to second list
|
||||||
@ -1052,6 +1053,7 @@ async def test_add_item_intent(
|
|||||||
assert len(entity1.items) == 0
|
assert len(entity1.items) == 0
|
||||||
assert len(entity2.items) == 1
|
assert len(entity2.items) == 1
|
||||||
assert entity2.items[0].summary == "cheese"
|
assert entity2.items[0].summary == "cheese"
|
||||||
|
assert entity2.items[0].status == TodoItemStatus.NEEDS_ACTION
|
||||||
|
|
||||||
# List name is case insensitive
|
# List name is case insensitive
|
||||||
response = await intent.async_handle(
|
response = await intent.async_handle(
|
||||||
@ -1065,6 +1067,7 @@ async def test_add_item_intent(
|
|||||||
assert len(entity1.items) == 0
|
assert len(entity1.items) == 0
|
||||||
assert len(entity2.items) == 2
|
assert len(entity2.items) == 2
|
||||||
assert entity2.items[1].summary == "wine"
|
assert entity2.items[1].summary == "wine"
|
||||||
|
assert entity2.items[1].status == TodoItemStatus.NEEDS_ACTION
|
||||||
|
|
||||||
# Missing list
|
# Missing list
|
||||||
with pytest.raises(intent.IntentHandleError):
|
with pytest.raises(intent.IntentHandleError):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user