Skip to content

Commit

Permalink
cms_form: fake_request fix handling of multiple values
Browse files Browse the repository at this point in the history
  • Loading branch information
simahawk committed Mar 5, 2025
1 parent a8bed06 commit 9d644a8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cms_form/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ def fake_request(
content_type=None,
session=None,
):
data = urllib.parse.urlencode(form_data or {})
form_data = form_data or {}
data = []
# urlencode does not preserve duplicated keys (eg: foo:list)
for k, v in form_data.items():
if k.endswith(":list"):
for vv in form_data.getlist(k):
data.append(urllib.parse.urlencode({k: vv}))

Check warning on line 35 in cms_form/tests/utils.py

View check run for this annotation

Codecov / codecov/patch

cms_form/tests/utils.py#L35

Added line #L35 was not covered by tests
else:
data.append(urllib.parse.urlencode({k: v}))
data = "&".join(data)
content_type = content_type or "application/x-www-form-urlencoded"
# werkzeug request
w_req = Request.from_values(
Expand Down

0 comments on commit 9d644a8

Please sign in to comment.