Skip to content

Commit

Permalink
Add a test for the 'orderby' task_list param
Browse files Browse the repository at this point in the history
This is a simple parametrized test which ensures that `orderby` takes
and serializes strings and lists of strings correctly.
  • Loading branch information
sirosen committed Jul 19, 2024
1 parent 1f6bffe commit aeef3bc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/functional/services/transfer/test_task_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,26 @@ def test_task_list(client, client_kwargs, qs):
# parsed_qs will have each value as a list (because query-params are a multidict)
# so transform the test data to match before comparison
assert parsed_qs == {k: [v] for k, v in qs.items()}


@pytest.mark.parametrize(
"orderby_value, expected_orderby_param",
[
("foo", "foo"),
(["foo"], "foo"),
("foo,bar", "foo,bar"),
("foo ASC,bar", "foo ASC,bar"),
(["foo ASC", "bar"], "foo ASC,bar"),
(["foo ASC", "bar DESC"], "foo ASC,bar DESC"),
],
)
def test_task_list_orderby_parameter(client, orderby_value, expected_orderby_param):
load_response(client.task_list)
client.task_list(orderby=orderby_value)

req = get_last_request()
parsed_qs = urllib.parse.parse_qs(urllib.parse.urlparse(req.url).query)
assert "orderby" in parsed_qs
assert len(parsed_qs["orderby"]) == 1
orderby_param = parsed_qs["orderby"][0]
assert orderby_param == expected_orderby_param

0 comments on commit aeef3bc

Please sign in to comment.