Skip to content

Commit

Permalink
Add tests to test_datastructure (encode#2505)
Browse files Browse the repository at this point in the history
* Add tests to test_datastructure

* Update tests

---------

Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
  • Loading branch information
3 people authored and Rocky Allen committed Jul 20, 2024
1 parent 9689a97 commit 44e640a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test_datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def test_url() -> None:
url = URL("http://u:p@host:80")
assert url.replace(port=88) == URL("http://u:p@host:88")

url = URL("http://host:80")
assert url.replace(username="u") == URL("http://u@host:80")


def test_url_query_params() -> None:
u = URL("https://example.org/path/?page=3")
Expand All @@ -70,6 +73,10 @@ def test_url_query_params() -> None:
assert str(u) == "https://example.org/path/?order=name"
u = u.remove_query_params("order")
assert str(u) == "https://example.org/path/"
u = u.include_query_params(page=4, search="testing")
assert str(u) == "https://example.org/path/?page=4&search=testing"
u = u.remove_query_params(["page", "search"])
assert str(u) == "https://example.org/path/"


def test_hidden_password() -> None:
Expand Down Expand Up @@ -138,6 +145,21 @@ def test_url_from_scope() -> None:
assert u == "https://example.org/path/to/somewhere?abc=123"
assert repr(u) == "URL('https://example.org/path/to/somewhere?abc=123')"

u = URL(
scope={
"scheme": "http",
"path": "/some/path",
"query_string": b"query=string",
"headers": [
(b"content-type", b"text/html"),
(b"host", b"example.com:8000"),
(b"accept", b"text/html"),
],
}
)
assert u == "http://example.com:8000/some/path?query=string"
assert repr(u) == "URL('http://example.com:8000/some/path?query=string')"


def test_headers() -> None:
h = Headers(raw=[(b"a", b"123"), (b"a", b"456"), (b"b", b"789")])
Expand Down

0 comments on commit 44e640a

Please sign in to comment.