Skip to content

Commit

Permalink
Add tests for Request(params=...)
Browse files Browse the repository at this point in the history
  • Loading branch information
GreyElaina committed Dec 3, 2024
1 parent a899066 commit bcd1ea9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/models/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,27 @@ def content() -> typing.Iterator[bytes]:
request.read()
pickle_request = pickle.loads(pickle.dumps(request))
assert pickle_request.content == b"test 123"


def test_with_params():
request = httpx.Request("GET", "http://example.com", params={"a": "1", "b": "2"})
assert str(request.url) == "http://example.com?a=1&b=2"


def test_merge_existing_params():
request = httpx.Request(
"GET", "http://example.com?c=3", params={"a": "1", "b": "2"}
)
assert str(request.url) == "http://example.com?c=3&a=1&b=2"


def test_empty_params():
request = httpx.Request("GET", "http://example.com", params={})
assert str(request.url) == "http://example.com"
request = httpx.Request("GET", "http://example.com?a=1", params={})
assert str(request.url) == "http://example.com?a=1"


def test_override_params():
request = httpx.Request("GET", "http://example.com?a=1", params={"a": "2"})
assert str(request.url) == "http://example.com?a=2"

0 comments on commit bcd1ea9

Please sign in to comment.