Skip to content

Commit 3074f52

Browse files
JohnVillalovosnejch
authored andcommitted
test: fix failing tests that use 204 (No Content) plus content
urllib3>=2 now checks for expected content length. Also codes 204 and 304 are set to expect a content length of 0 [1] So in the unit tests stop setting content to return in these situations. [1] https://github.com/urllib3/urllib3/blob/88a707290b655394aade060a8b7eaee83152dc8b/src/urllib3/response.py#L691-L693
1 parent 8d2d297 commit 3074f52

18 files changed

+21
-70
lines changed

tests/unit/objects/conftest.py

-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ def created_content():
2121
return {"message": "201 Created"}
2222

2323

24-
@pytest.fixture
25-
def no_content():
26-
return {"message": "204 No Content"}
27-
28-
2924
@pytest.fixture
3025
def resp_export(accepted_content, binary_content):
3126
"""Common fixture for group and project exports."""

tests/unit/objects/test_badges.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,11 @@ def resp_update_badge():
9797

9898

9999
@pytest.fixture()
100-
def resp_delete_badge(no_content):
100+
def resp_delete_badge():
101101
with responses.RequestsMock() as rsps:
102102
rsps.add(
103103
method=responses.DELETE,
104104
url=re.compile(r"http://localhost/api/v4/(projects|groups)/1/badges/1"),
105-
json=no_content,
106-
content_type="application/json",
107105
status=204,
108106
)
109107
yield rsps

tests/unit/objects/test_group_access_tokens.py

-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ def resp_revoke_group_access_token():
7575
rsps.add(
7676
method=responses.DELETE,
7777
url="http://localhost/api/v4/groups/1/access_tokens/42",
78-
json=content,
79-
content_type="application/json",
8078
status=204,
8179
)
8280
rsps.add(

tests/unit/objects/test_groups.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def resp_update_push_rules_group():
215215

216216

217217
@pytest.fixture
218-
def resp_delete_push_rules_group(no_content):
218+
def resp_delete_push_rules_group():
219219
with responses.RequestsMock() as rsps:
220220
rsps.add(
221221
method=responses.GET,
@@ -227,15 +227,13 @@ def resp_delete_push_rules_group(no_content):
227227
rsps.add(
228228
method=responses.DELETE,
229229
url="http://localhost/api/v4/groups/1/push_rule",
230-
json=no_content,
231-
content_type="application/json",
232230
status=204,
233231
)
234232
yield rsps
235233

236234

237235
@pytest.fixture
238-
def resp_list_ldap_group_links(no_content):
236+
def resp_list_ldap_group_links():
239237
with responses.RequestsMock() as rsps:
240238
rsps.add(
241239
method=responses.GET,
@@ -292,7 +290,7 @@ def resp_create_saml_group_link():
292290

293291

294292
@pytest.fixture
295-
def resp_delete_saml_group_link(no_content):
293+
def resp_delete_saml_group_link():
296294
with responses.RequestsMock() as rsps:
297295
rsps.add(
298296
method=responses.POST,
@@ -309,8 +307,6 @@ def resp_delete_saml_group_link(no_content):
309307
rsps.add(
310308
method=responses.DELETE,
311309
url="http://localhost/api/v4/groups/1/saml_group_links/saml-group-1",
312-
json=no_content,
313-
content_type="application/json",
314310
status=204,
315311
)
316312
yield rsps

tests/unit/objects/test_job_artifacts.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ def resp_artifacts_by_ref_name(binary_content):
2525

2626

2727
@pytest.fixture
28-
def resp_project_artifacts_delete(no_content):
28+
def resp_project_artifacts_delete():
2929
with responses.RequestsMock() as rsps:
3030
rsps.add(
3131
method=responses.DELETE,
3232
url="http://localhost/api/v4/projects/1/artifacts",
33-
json=no_content,
34-
content_type="application/json",
3533
status=204,
3634
)
3735
yield rsps

tests/unit/objects/test_members.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
@pytest.fixture
26-
def resp_create_group_member(no_content):
26+
def resp_create_group_member():
2727
with responses.RequestsMock() as rsps:
2828
rsps.add(
2929
method=responses.POST,
@@ -49,13 +49,11 @@ def resp_list_billable_group_members():
4949

5050

5151
@pytest.fixture
52-
def resp_delete_billable_group_member(no_content):
52+
def resp_delete_billable_group_member():
5353
with responses.RequestsMock() as rsps:
5454
rsps.add(
5555
method=responses.DELETE,
5656
url="http://localhost/api/v4/groups/1/billable_members/1",
57-
json=no_content,
58-
content_type="application/json",
5957
status=204,
6058
)
6159
yield rsps

tests/unit/objects/test_packages.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -137,33 +137,29 @@ def resp_get_package():
137137

138138

139139
@pytest.fixture
140-
def resp_delete_package(no_content):
140+
def resp_delete_package():
141141
with responses.RequestsMock() as rsps:
142142
rsps.add(
143143
method=responses.DELETE,
144144
url="http://localhost/api/v4/projects/1/packages/1",
145-
json=no_content,
146-
content_type="application/json",
147145
status=204,
148146
)
149147
yield rsps
150148

151149

152150
@pytest.fixture
153-
def resp_delete_package_file(no_content):
151+
def resp_delete_package_file():
154152
with responses.RequestsMock() as rsps:
155153
rsps.add(
156154
method=responses.DELETE,
157155
url="http://localhost/api/v4/projects/1/packages/1/package_files/1",
158-
json=no_content,
159-
content_type="application/json",
160156
status=204,
161157
)
162158
yield rsps
163159

164160

165161
@pytest.fixture
166-
def resp_delete_package_file_list(no_content):
162+
def resp_delete_package_file_list():
167163
with responses.RequestsMock() as rsps:
168164
rsps.add(
169165
method=responses.GET,
@@ -178,8 +174,6 @@ def resp_delete_package_file_list(no_content):
178174
rsps.add(
179175
method=responses.DELETE,
180176
url=f"http://localhost/api/v4/projects/1/packages/1/package_files/{pkg_file_id}",
181-
json=no_content,
182-
content_type="application/json",
183177
status=204,
184178
)
185179
yield rsps

tests/unit/objects/test_personal_access_tokens.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,11 @@ def resp_get_personal_access_token_self():
8181

8282

8383
@pytest.fixture
84-
def resp_delete_personal_access_token(no_content):
84+
def resp_delete_personal_access_token():
8585
with responses.RequestsMock() as rsps:
8686
rsps.add(
8787
method=responses.DELETE,
8888
url=single_token_url,
89-
json=no_content,
90-
content_type="application/json",
9189
status=204,
9290
)
9391
yield rsps

tests/unit/objects/test_project_access_tokens.py

-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ def resp_revoke_project_access_token():
7575
rsps.add(
7676
method=responses.DELETE,
7777
url="http://localhost/api/v4/projects/1/access_tokens/42",
78-
json=content,
79-
content_type="application/json",
8078
status=204,
8179
)
8280
rsps.add(

tests/unit/objects/test_project_merge_request_approvals.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,11 @@ def resp_mr_approval_rules():
147147

148148

149149
@pytest.fixture
150-
def resp_delete_mr_approval_rule(no_content):
150+
def resp_delete_mr_approval_rule():
151151
with responses.RequestsMock() as rsps:
152152
rsps.add(
153153
method=responses.DELETE,
154154
url="http://localhost/api/v4/projects/1/merge_requests/1/approval_rules/1",
155-
json=no_content,
156-
content_type="application/json",
157155
status=204,
158156
)
159157
yield rsps

tests/unit/objects/test_projects.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,11 @@ def resp_share_project():
361361

362362

363363
@pytest.fixture
364-
def resp_unshare_project(no_content):
364+
def resp_unshare_project():
365365
with responses.RequestsMock() as rsps:
366366
rsps.add(
367367
method=responses.DELETE,
368368
url="http://localhost/api/v4/projects/1/share/1",
369-
json=no_content,
370-
content_type="application/json",
371369
status=204,
372370
)
373371
yield rsps
@@ -387,13 +385,11 @@ def resp_create_fork_relation():
387385

388386

389387
@pytest.fixture
390-
def resp_delete_fork_relation(no_content):
388+
def resp_delete_fork_relation():
391389
with responses.RequestsMock() as rsps:
392390
rsps.add(
393391
method=responses.DELETE,
394392
url="http://localhost/api/v4/projects/2/fork",
395-
json=no_content,
396-
content_type="application/json",
397393
status=204,
398394
)
399395
yield rsps
@@ -485,7 +481,7 @@ def resp_update_push_rules_project():
485481

486482

487483
@pytest.fixture
488-
def resp_delete_push_rules_project(no_content):
484+
def resp_delete_push_rules_project():
489485
with responses.RequestsMock() as rsps:
490486
rsps.add(
491487
method=responses.GET,
@@ -497,8 +493,6 @@ def resp_delete_push_rules_project(no_content):
497493
rsps.add(
498494
method=responses.DELETE,
499495
url="http://localhost/api/v4/projects/1/push_rule",
500-
json=no_content,
501-
content_type="application/json",
502496
status=204,
503497
)
504498
yield rsps

tests/unit/objects/test_registry_repositories.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,11 @@ def resp_get_registry_repository():
5959

6060

6161
@pytest.fixture
62-
def resp_delete_registry_repository(no_content):
62+
def resp_delete_registry_repository():
6363
with responses.RequestsMock() as rsps:
6464
rsps.add(
6565
method=responses.DELETE,
6666
url="http://localhost/api/v4/projects/1/registry/repositories/1",
67-
json=no_content,
68-
content_type="application/json",
6967
status=204,
7068
)
7169
yield rsps

tests/unit/objects/test_releases.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,11 @@ def resp_update_link():
101101

102102

103103
@pytest.fixture
104-
def resp_delete_link(no_content):
104+
def resp_delete_link():
105105
with responses.RequestsMock() as rsps:
106106
rsps.add(
107107
method=responses.DELETE,
108108
url=link_id_url,
109-
json=link_content,
110-
content_type="application/json",
111109
status=204,
112110
)
113111
yield rsps

tests/unit/objects/test_secure_files.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,11 @@ def resp_download_secure_file(binary_content):
6565

6666

6767
@pytest.fixture
68-
def resp_remove_secure_file(no_content):
68+
def resp_remove_secure_file():
6969
with responses.RequestsMock() as rsps:
7070
rsps.add(
7171
method=responses.DELETE,
7272
url="http://localhost/api/v4/projects/1/secure_files/1",
73-
json=no_content,
74-
content_type="application/json",
7573
status=204,
7674
)
7775
yield rsps

tests/unit/objects/test_todos.py

-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ def resp_mark_all_as_done():
6666
rsps.add(
6767
method=responses.POST,
6868
url="http://localhost/api/v4/todos/mark_as_done",
69-
json={},
70-
content_type="application/json",
7169
status=204,
7270
)
7371
yield rsps

tests/unit/objects/test_topics.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,11 @@ def resp_update_topic():
7878

7979

8080
@pytest.fixture
81-
def resp_delete_topic(no_content):
81+
def resp_delete_topic():
8282
with responses.RequestsMock() as rsps:
8383
rsps.add(
8484
method=responses.DELETE,
8585
url=topic_url,
86-
json=no_content,
87-
content_type="application/json",
8886
status=204,
8987
)
9088
yield rsps

tests/unit/objects/test_users.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,11 @@ def resp_get_user_status():
152152

153153

154154
@pytest.fixture
155-
def resp_delete_user_identity(no_content):
155+
def resp_delete_user_identity():
156156
with responses.RequestsMock() as rsps:
157157
rsps.add(
158158
method=responses.DELETE,
159159
url="http://localhost/api/v4/users/1/identities/test_provider",
160-
json=no_content,
161-
content_type="application/json",
162160
status=204,
163161
)
164162
yield rsps

tests/unit/objects/test_variables.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,11 @@ def resp_update_variable():
8787

8888

8989
@pytest.fixture
90-
def resp_delete_variable(no_content):
90+
def resp_delete_variable():
9191
with responses.RequestsMock() as rsps:
9292
rsps.add(
9393
method=responses.DELETE,
9494
url=variables_key_url,
95-
json=no_content,
96-
content_type="application/json",
9795
status=204,
9896
)
9997
yield rsps

0 commit comments

Comments
 (0)