Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix todoist todo tests #103101

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix todoist todo tests
  • Loading branch information
emontnemery committed Oct 30, 2023
commit 18651a352a739b9162498cfae8fa35f5bcd97e12
46 changes: 11 additions & 35 deletions tests/components/todoist/test_todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ async def test_todo_item_state(


@pytest.mark.parametrize(("tasks"), [[]])
async def test_create_todo_list_item(
async def test_add_todo_list_item(
hass: HomeAssistant,
setup_integration: None,
api: AsyncMock,
) -> None:
"""Test for creating a To-do Item."""
"""Test for adding a To-do Item."""

state = hass.states.get("todo.name")
assert state
Expand All @@ -75,8 +75,8 @@ async def test_create_todo_list_item(

await hass.services.async_call(
TODO_DOMAIN,
"create_item",
{"summary": "Soda"},
"add_item",
{"item": "Soda"},
target={"entity_id": "todo.name"},
blocking=True,
)
Expand All @@ -92,30 +92,6 @@ async def test_create_todo_list_item(
assert state.state == "1"


@pytest.mark.parametrize(("tasks"), [[]])
async def test_create_completed_item_unsupported(
hass: HomeAssistant,
setup_integration: None,
api: AsyncMock,
) -> None:
"""Test for creating a To-do Item that is already completed."""

state = hass.states.get("todo.name")
assert state
assert state.state == "0"

api.add_task = AsyncMock()

with pytest.raises(ValueError, match="Only active tasks"):
await hass.services.async_call(
TODO_DOMAIN,
"create_item",
{"summary": "Soda", "status": "completed"},
target={"entity_id": "todo.name"},
blocking=True,
)


@pytest.mark.parametrize(
("tasks"), [[make_api_task(id="task-id-1", content="Soda", is_completed=False)]]
)
Expand All @@ -141,7 +117,7 @@ async def test_update_todo_item_status(
await hass.services.async_call(
TODO_DOMAIN,
"update_item",
{"uid": "task-id-1", "status": "completed"},
{"item": "task-id-1", "status": "completed"},
target={"entity_id": "todo.name"},
blocking=True,
)
Expand All @@ -164,7 +140,7 @@ async def test_update_todo_item_status(
await hass.services.async_call(
TODO_DOMAIN,
"update_item",
{"uid": "task-id-1", "status": "needs_action"},
{"item": "task-id-1", "status": "needs_action"},
target={"entity_id": "todo.name"},
blocking=True,
)
Expand Down Expand Up @@ -203,7 +179,7 @@ async def test_update_todo_item_summary(
await hass.services.async_call(
TODO_DOMAIN,
"update_item",
{"uid": "task-id-1", "summary": "Milk"},
{"item": "task-id-1", "rename": "Milk"},
target={"entity_id": "todo.name"},
blocking=True,
)
Expand All @@ -223,12 +199,12 @@ async def test_update_todo_item_summary(
]
],
)
async def test_delete_todo_item(
async def test_remove_todo_item(
hass: HomeAssistant,
setup_integration: None,
api: AsyncMock,
) -> None:
"""Test for deleting a To-do Item."""
"""Test for removing a To-do Item."""

state = hass.states.get("todo.name")
assert state
Expand All @@ -240,8 +216,8 @@ async def test_delete_todo_item(

await hass.services.async_call(
TODO_DOMAIN,
"delete_item",
{"uid": ["task-id-1", "task-id-2"]},
"remove_item",
{"item": ["task-id-1", "task-id-2"]},
target={"entity_id": "todo.name"},
blocking=True,
)
Expand Down