Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion src/apron_tools/providers/google/tasks/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,11 @@ async def google_tasks_list_tasks(
"maxResults": _clamp_max_results(params.max_results),
# Strings "true"/"false" because the Tasks API expects query-string
# booleans rather than python's capitalised "True"/"False".
# The Tasks API marks completed items as hidden, so showHidden must be
# coupled to showCompleted; otherwise completed tasks are filtered back
# out even when the caller opts in.
"showCompleted": "true" if params.show_completed else "false",
"showHidden": "false",
"showHidden": "true" if params.show_completed else "false",
"showDeleted": "false",
}
if params.due_min:
Expand Down
10 changes: 8 additions & 2 deletions tests/providers/google/tasks/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,21 @@ async def test_hides_completed_by_default(self, httpx_mock: HTTPXMock) -> None:
await google_tasks_list_tasks(ListTasksParams(), token=_TOKEN)

request = httpx_mock.get_request()
assert "showCompleted=false" in str(request.url)
url = str(request.url)
assert "showCompleted=false" in url
assert "showHidden=false" in url

async def test_show_completed_opt_in(self, httpx_mock: HTTPXMock) -> None:
httpx_mock.add_response(json=_load_json("list_tasks.json"))

await google_tasks_list_tasks(ListTasksParams(show_completed=True), token=_TOKEN)

request = httpx_mock.get_request()
assert "showCompleted=true" in str(request.url)
url = str(request.url)
assert "showCompleted=true" in url
# Completed tasks are marked hidden by the Tasks API, so surfacing them
# requires showHidden coupled to showCompleted.
assert "showHidden=true" in url

async def test_clamps_max_results_upper(self, httpx_mock: HTTPXMock) -> None:
httpx_mock.add_response(json=_load_json("list_tasks.json"))
Expand Down
Loading