-
-
Notifications
You must be signed in to change notification settings - Fork 930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests to test_datastructure
#2505
Add tests to test_datastructure
#2505
Conversation
tests/test_datastructures.py
Outdated
@@ -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="user").password is None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are you testing here?
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/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are you testing here?
Better to post the lines you are testing, otherwise, this will take some time for me.
tests/test_datastructures.py
Outdated
scope_with_host_header = { | ||
"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"), | ||
], | ||
} | ||
url_from_scope_with_host = URL(scope=scope_with_host_header) | ||
assert url_from_scope_with_host.hostname == "example.com" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant doing it here...
starlette/starlette/datastructures.py
Lines 39 to 40 in 74ccb96
for key, value in scope["headers"]: | |
if key == b"host": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 👍
I've updated the test cases to match the current pattern we have there.
* Add tests to test_datastructure * Update tests --------- Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan> Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Summary
Add test cases to
test_datastructures.py
in order to have 100 coverage. Related to this issue and this PR.Checklist