Rename todo due_date_time parameter to due_datetime (#104698)

* Rename todo due_date_time parameter to due_datetime

* Apply suggestions from code review

---------

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
pull/104723/head
Martin Hjelmare 2023-11-29 13:11:15 +01:00 committed by GitHub
parent 861bb48ab6
commit 5f44dadb66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 22 deletions

View File

@ -35,7 +35,7 @@ from .const import (
ATTR_DESCRIPTION,
ATTR_DUE,
ATTR_DUE_DATE,
ATTR_DUE_DATE_TIME,
ATTR_DUE_DATETIME,
DOMAIN,
TodoItemStatus,
TodoListEntityFeature,
@ -73,7 +73,7 @@ TODO_ITEM_FIELDS = [
required_feature=TodoListEntityFeature.SET_DUE_DATE_ON_ITEM,
),
TodoItemFieldDescription(
service_field=ATTR_DUE_DATE_TIME,
service_field=ATTR_DUE_DATETIME,
validation=vol.All(cv.datetime, dt_util.as_local),
todo_item_field=ATTR_DUE,
required_feature=TodoListEntityFeature.SET_DUE_DATETIME_ON_ITEM,
@ -89,9 +89,7 @@ TODO_ITEM_FIELDS = [
TODO_ITEM_FIELD_SCHEMA = {
vol.Optional(desc.service_field): desc.validation for desc in TODO_ITEM_FIELDS
}
TODO_ITEM_FIELD_VALIDATIONS = [
cv.has_at_most_one_key(ATTR_DUE_DATE, ATTR_DUE_DATE_TIME)
]
TODO_ITEM_FIELD_VALIDATIONS = [cv.has_at_most_one_key(ATTR_DUE_DATE, ATTR_DUE_DATETIME)]
def _validate_supported_features(

View File

@ -6,7 +6,7 @@ DOMAIN = "todo"
ATTR_DUE = "due"
ATTR_DUE_DATE = "due_date"
ATTR_DUE_DATE_TIME = "due_date_time"
ATTR_DUE_DATETIME = "due_datetime"
ATTR_DESCRIPTION = "description"

View File

@ -29,7 +29,7 @@ add_item:
example: "2023-11-17"
selector:
date:
due_date_time:
due_datetime:
example: "2023-11-17 13:30:00"
selector:
datetime:
@ -65,7 +65,7 @@ update_item:
example: "2023-11-17"
selector:
date:
due_date_time:
due_datetime:
example: "2023-11-17 13:30:00"
selector:
datetime:

View File

@ -28,8 +28,8 @@
"name": "Due date",
"description": "The date the to-do item is expected to be completed."
},
"due_date_time": {
"name": "Due date time",
"due_datetime": {
"name": "Due date and time",
"description": "The date and time the to-do item is expected to be completed."
},
"description": {
@ -58,8 +58,8 @@
"name": "Due date",
"description": "The date the to-do item is expected to be completed."
},
"due_date_time": {
"name": "Due date time",
"due_datetime": {
"name": "Due date and time",
"description": "The date and time the to-do item is expected to be completed."
},
"description": {

View File

@ -71,7 +71,7 @@ def set_time_zone(hass: HomeAssistant) -> None:
({}, {}),
({"due_date": "2023-11-17"}, {"due": "2023-11-17"}),
(
{"due_date_time": "2023-11-17T11:30:00+00:00"},
{"due_datetime": "2023-11-17T11:30:00+00:00"},
{"due": "2023-11-17T05:30:00-06:00"},
),
({"description": "Additional detail"}, {"description": "Additional detail"}),
@ -118,7 +118,7 @@ async def test_add_item(
({}, {}),
({"due_date": "2023-11-17"}, {"due": "2023-11-17"}),
(
{"due_date_time": "2023-11-17T11:30:00+00:00"},
{"due_datetime": "2023-11-17T11:30:00+00:00"},
{"due": "2023-11-17T05:30:00-06:00"},
),
({"description": "Additional detail"}, {"description": "Additional detail"}),
@ -213,7 +213,7 @@ async def test_bulk_remove(
({"status": "completed"}, {"status": "completed"}, "0"),
({"due_date": "2023-11-17"}, {"due": "2023-11-17"}, "1"),
(
{"due_date_time": "2023-11-17T11:30:00+00:00"},
{"due_datetime": "2023-11-17T11:30:00+00:00"},
{"due": "2023-11-17T05:30:00-06:00"},
"1",
),

View File

@ -354,10 +354,10 @@ async def test_add_item_service_raises(
(
{
"item": "Submit forms",
"due_date_time": f"2023-11-17T17:00:00{TEST_OFFSET}",
"due_datetime": f"2023-11-17T17:00:00{TEST_OFFSET}",
},
ValueError,
"does not support setting field 'due_date_time'",
"does not support setting field 'due_datetime'",
),
],
)
@ -396,7 +396,7 @@ async def test_add_item_service_invalid_input(
),
(
TodoListEntityFeature.SET_DUE_DATETIME_ON_ITEM,
{"item": "New item", "due_date_time": f"2023-11-13T17:00:00{TEST_OFFSET}"},
{"item": "New item", "due_datetime": f"2023-11-13T17:00:00{TEST_OFFSET}"},
TodoItem(
summary="New item",
status=TodoItemStatus.NEEDS_ACTION,
@ -405,7 +405,7 @@ async def test_add_item_service_invalid_input(
),
(
TodoListEntityFeature.SET_DUE_DATETIME_ON_ITEM,
{"item": "New item", "due_date_time": "2023-11-13T17:00:00+00:00"},
{"item": "New item", "due_datetime": "2023-11-13T17:00:00+00:00"},
TodoItem(
summary="New item",
status=TodoItemStatus.NEEDS_ACTION,
@ -414,7 +414,7 @@ async def test_add_item_service_invalid_input(
),
(
TodoListEntityFeature.SET_DUE_DATETIME_ON_ITEM,
{"item": "New item", "due_date_time": "2023-11-13"},
{"item": "New item", "due_datetime": "2023-11-13"},
TodoItem(
summary="New item",
status=TodoItemStatus.NEEDS_ACTION,
@ -663,7 +663,7 @@ async def test_update_item_service_invalid_input(
@pytest.mark.parametrize(
("update_data"),
[
({"due_date_time": f"2023-11-13T17:00:00{TEST_OFFSET}"}),
({"due_datetime": f"2023-11-13T17:00:00{TEST_OFFSET}"}),
({"due_date": "2023-11-13"}),
({"description": "Submit revised draft"}),
],
@ -697,7 +697,7 @@ async def test_update_todo_item_field_unsupported(
),
(
TodoListEntityFeature.SET_DUE_DATETIME_ON_ITEM,
{"due_date_time": f"2023-11-13T17:00:00{TEST_OFFSET}"},
{"due_datetime": f"2023-11-13T17:00:00{TEST_OFFSET}"},
TodoItem(
uid="1",
due=datetime.datetime(2023, 11, 13, 17, 0, 0, tzinfo=TEST_TIMEZONE),