Skip to content

Commit 3ea7ee5

Browse files
committed
fix(google-tasks): couple showHidden with show_completed
The Tasks API marks completed items as hidden, so hardcoding showHidden=false filtered completed tasks back out even when callers passed show_completed=true, making the parameter a no-op. Send showHidden=true whenever show_completed is true (and false otherwise) so opted-in completed tasks are returned. Fixes #147
1 parent 783b994 commit 3ea7ee5

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/apron_tools/providers/google/tasks/tools.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ async def google_tasks_list_tasks(
112112
"maxResults": _clamp_max_results(params.max_results),
113113
# Strings "true"/"false" because the Tasks API expects query-string
114114
# booleans rather than python's capitalised "True"/"False".
115+
# The Tasks API marks completed items as hidden, so showHidden must be
116+
# coupled to showCompleted; otherwise completed tasks are filtered back
117+
# out even when the caller opts in.
115118
"showCompleted": "true" if params.show_completed else "false",
116-
"showHidden": "false",
119+
"showHidden": "true" if params.show_completed else "false",
117120
"showDeleted": "false",
118121
}
119122
if params.due_min:

tests/providers/google/tasks/test_tools.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,21 @@ async def test_hides_completed_by_default(self, httpx_mock: HTTPXMock) -> None:
100100
await google_tasks_list_tasks(ListTasksParams(), token=_TOKEN)
101101

102102
request = httpx_mock.get_request()
103-
assert "showCompleted=false" in str(request.url)
103+
url = str(request.url)
104+
assert "showCompleted=false" in url
105+
assert "showHidden=false" in url
104106

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

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

110112
request = httpx_mock.get_request()
111-
assert "showCompleted=true" in str(request.url)
113+
url = str(request.url)
114+
assert "showCompleted=true" in url
115+
# Completed tasks are marked hidden by the Tasks API, so surfacing them
116+
# requires showHidden coupled to showCompleted.
117+
assert "showHidden=true" in url
112118

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

0 commit comments

Comments
 (0)