Skip to content

Commit 6e87aae

Browse files
committed
Rename mock_route args with explicit request/response prefixes
Use response_json/response_status and request_json/request_params/request_headers to keep route matching and mocked response fields consistently explicit.
1 parent f22764f commit 6e87aae

10 files changed

Lines changed: 183 additions & 177 deletions

tests/test_api_comments.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ async def test_get_comment(
3535
respx_mock,
3636
method="GET",
3737
url=endpoint,
38-
json=default_comment_response,
39-
status=200,
40-
headers=api_headers(),
38+
response_json=default_comment_response,
39+
response_status=200,
40+
request_headers=api_headers(),
4141
)
4242

4343
comment = todoist_api.get_comment(comment_id)
@@ -68,10 +68,13 @@ async def test_get_comments(
6868
respx_mock,
6969
method="GET",
7070
url=endpoint,
71-
json=page,
72-
status=200,
73-
params={"task_id": task_id} | ({"cursor": cursor} if cursor else {}),
74-
headers=api_headers(),
71+
response_json=page,
72+
response_status=200,
73+
request_params={
74+
"task_id": task_id,
75+
}
76+
| ({"cursor": cursor} if cursor else {}),
77+
request_headers=api_headers(),
7578
)
7679
cursor = page["next_cursor"]
7780

@@ -113,9 +116,9 @@ async def test_add_comment(
113116
respx_mock,
114117
method="POST",
115118
url=f"{DEFAULT_API_URL}/comments",
116-
json=default_comment_response,
117-
status=200,
118-
headers=api_headers(),
119+
response_json=default_comment_response,
120+
response_status=200,
121+
request_headers=api_headers(),
119122
request_json={
120123
"content": content,
121124
"project_id": project_id,
@@ -158,9 +161,9 @@ async def test_update_comment(
158161
respx_mock,
159162
method="POST",
160163
url=f"{DEFAULT_API_URL}/comments/{default_comment.id}",
161-
json=updated_comment_dict,
162-
status=200,
163-
headers=api_headers(),
164+
response_json=updated_comment_dict,
165+
response_status=200,
166+
request_headers=api_headers(),
164167
request_json=args,
165168
)
166169

@@ -190,8 +193,8 @@ async def test_delete_comment(
190193
respx_mock,
191194
method="DELETE",
192195
url=endpoint,
193-
status=204,
194-
headers=api_headers(),
196+
response_status=204,
197+
request_headers=api_headers(),
195198
)
196199

197200
response = todoist_api.delete_comment(comment_id)

tests/test_api_completed_tasks.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ async def test_get_completed_tasks_by_due_date(
5151
respx_mock,
5252
method="GET",
5353
url=endpoint,
54-
json=page,
55-
status=200,
56-
params=params | ({"cursor": cursor} if cursor else {}),
57-
headers=api_headers(),
54+
response_json=page,
55+
response_status=200,
56+
request_params=params | ({"cursor": cursor} if cursor else {}),
57+
request_headers=api_headers(),
5858
)
5959
cursor = page["next_cursor"]
6060

@@ -113,10 +113,10 @@ async def test_get_completed_tasks_by_completion_date(
113113
respx_mock,
114114
method="GET",
115115
url=endpoint,
116-
json=page,
117-
status=200,
118-
params=params | ({"cursor": cursor} if cursor else {}),
119-
headers=api_headers(),
116+
response_json=page,
117+
response_status=200,
118+
request_params=params | ({"cursor": cursor} if cursor else {}),
119+
request_headers=api_headers(),
120120
)
121121
cursor = page["next_cursor"]
122122

tests/test_api_labels.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ async def test_get_label(
3030
respx_mock,
3131
method="GET",
3232
url=endpoint,
33-
json=default_label_response,
34-
status=200,
35-
headers=api_headers(),
33+
response_json=default_label_response,
34+
response_status=200,
35+
request_headers=api_headers(),
3636
)
3737

3838
label = todoist_api.get_label(label_id)
@@ -62,10 +62,10 @@ async def test_get_labels(
6262
respx_mock,
6363
method="GET",
6464
url=endpoint,
65-
json=page,
66-
status=200,
67-
params={"cursor": cursor} if cursor else {},
68-
headers=api_headers(),
65+
response_json=page,
66+
response_status=200,
67+
request_params={"cursor": cursor} if cursor else {},
68+
request_headers=api_headers(),
6969
)
7070
cursor = page["next_cursor"]
7171

@@ -103,10 +103,10 @@ async def test_search_labels(
103103
respx_mock,
104104
method="GET",
105105
url=endpoint,
106-
json=page,
107-
status=200,
108-
params={"query": query} | ({"cursor": cursor} if cursor else {}),
109-
headers=api_headers(),
106+
response_json=page,
107+
response_status=200,
108+
request_params={"query": query} | ({"cursor": cursor} if cursor else {}),
109+
request_headers=api_headers(),
110110
)
111111
cursor = page["next_cursor"]
112112

@@ -141,9 +141,9 @@ async def test_add_label_minimal(
141141
respx_mock,
142142
method="POST",
143143
url=f"{DEFAULT_API_URL}/labels",
144-
json=default_label_response,
145-
status=200,
146-
headers=api_headers(),
144+
response_json=default_label_response,
145+
response_status=200,
146+
request_headers=api_headers(),
147147
request_json={"name": label_name},
148148
)
149149

@@ -177,9 +177,9 @@ async def test_add_label_full(
177177
respx_mock,
178178
method="POST",
179179
url=f"{DEFAULT_API_URL}/labels",
180-
json=default_label_response,
181-
status=200,
182-
headers=api_headers(),
180+
response_json=default_label_response,
181+
response_status=200,
182+
request_headers=api_headers(),
183183
request_json={"name": label_name} | args,
184184
)
185185

@@ -210,9 +210,9 @@ async def test_update_label(
210210
respx_mock,
211211
method="POST",
212212
url=f"{DEFAULT_API_URL}/labels/{default_label.id}",
213-
json=updated_label_dict,
214-
status=200,
215-
headers=api_headers(),
213+
response_json=updated_label_dict,
214+
response_status=200,
215+
request_headers=api_headers(),
216216
request_json=args,
217217
)
218218

@@ -240,8 +240,8 @@ async def test_delete_label(
240240
respx_mock,
241241
method="DELETE",
242242
url=endpoint,
243-
status=204,
244-
headers=api_headers(),
243+
response_status=204,
244+
request_headers=api_headers(),
245245
)
246246

247247
response = todoist_api.delete_label(label_id)

tests/test_api_projects.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ async def test_get_project(
3030
respx_mock,
3131
method="GET",
3232
url=endpoint,
33-
json=default_project_response,
34-
status=200,
35-
headers=api_headers(),
33+
response_json=default_project_response,
34+
response_status=200,
35+
request_headers=api_headers(),
3636
)
3737

3838
project = todoist_api.get_project(project_id)
@@ -62,10 +62,10 @@ async def test_get_projects(
6262
respx_mock,
6363
method="GET",
6464
url=endpoint,
65-
json=page,
66-
status=200,
67-
params={"cursor": cursor} if cursor else {},
68-
headers=api_headers(),
65+
response_json=page,
66+
response_status=200,
67+
request_params={"cursor": cursor} if cursor else {},
68+
request_headers=api_headers(),
6969
)
7070
cursor = page["next_cursor"]
7171

@@ -103,10 +103,10 @@ async def test_search_projects(
103103
respx_mock,
104104
method="GET",
105105
url=endpoint,
106-
json=page,
107-
status=200,
108-
params={"query": query} | ({"cursor": cursor} if cursor else {}),
109-
headers=api_headers(),
106+
response_json=page,
107+
response_status=200,
108+
request_params={"query": query} | ({"cursor": cursor} if cursor else {}),
109+
request_headers=api_headers(),
110110
)
111111
cursor = page["next_cursor"]
112112

@@ -141,9 +141,9 @@ async def test_add_project_minimal(
141141
respx_mock,
142142
method="POST",
143143
url=f"{DEFAULT_API_URL}/projects",
144-
json=default_project_response,
145-
status=200,
146-
headers=api_headers(),
144+
response_json=default_project_response,
145+
response_status=200,
146+
request_headers=api_headers(),
147147
request_json={"name": project_name},
148148
)
149149

@@ -179,9 +179,9 @@ async def test_add_project_full(
179179
respx_mock,
180180
method="POST",
181181
url=f"{DEFAULT_API_URL}/projects",
182-
json=default_project_response,
183-
status=200,
184-
headers=api_headers(),
182+
response_json=default_project_response,
183+
response_status=200,
184+
request_headers=api_headers(),
185185
request_json={"name": project_name} | args,
186186
)
187187

@@ -214,9 +214,9 @@ async def test_update_project(
214214
respx_mock,
215215
method="POST",
216216
url=f"{DEFAULT_API_URL}/projects/{default_project.id}",
217-
json=updated_project_dict,
218-
status=200,
219-
headers=api_headers(),
217+
response_json=updated_project_dict,
218+
response_status=200,
219+
request_headers=api_headers(),
220220
request_json=args,
221221
)
222222

@@ -250,9 +250,9 @@ async def test_archive_project(
250250
respx_mock,
251251
method="POST",
252252
url=endpoint,
253-
json=archived_project_dict,
254-
status=200,
255-
headers=api_headers(),
253+
response_json=archived_project_dict,
254+
response_status=200,
255+
request_headers=api_headers(),
256256
)
257257

258258
project = todoist_api.archive_project(project_id)
@@ -283,9 +283,9 @@ async def test_unarchive_project(
283283
respx_mock,
284284
method="POST",
285285
url=endpoint,
286-
json=unarchived_project_dict,
287-
status=200,
288-
headers=api_headers(),
286+
response_json=unarchived_project_dict,
287+
response_status=200,
288+
request_headers=api_headers(),
289289
)
290290

291291
project = todoist_api.unarchive_project(project_id)
@@ -312,8 +312,8 @@ async def test_delete_project(
312312
respx_mock,
313313
method="DELETE",
314314
url=endpoint,
315-
status=204,
316-
headers=api_headers(),
315+
response_status=204,
316+
request_headers=api_headers(),
317317
)
318318

319319
response = todoist_api.delete_project(project_id)
@@ -344,10 +344,10 @@ async def test_get_collaborators(
344344
respx_mock,
345345
method="GET",
346346
url=endpoint,
347-
json=page,
348-
status=200,
349-
params={"cursor": cursor} if cursor else {},
350-
headers=api_headers(),
347+
response_json=page,
348+
response_status=200,
349+
request_params={"cursor": cursor} if cursor else {},
350+
request_headers=api_headers(),
351351
)
352352
cursor = page["next_cursor"]
353353

0 commit comments

Comments
 (0)