Skip to content
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

Merged
merged 5 commits into from
Mar 24, 2024

Conversation

TechNiick
Copy link
Contributor

Summary

Add test cases to test_datastructures.py in order to have 100 coverage. Related to this issue and this PR.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@@ -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
Copy link
Member

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?

Comment on lines +76 to +79
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/"
Copy link
Member

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.

Comment on lines 148 to 160
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"

Copy link
Member

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...

for key, value in scope["headers"]:
if key == b"host":

Copy link
Member

@Kludex Kludex left a 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.

@Kludex Kludex enabled auto-merge (squash) March 24, 2024 17:18
@Kludex Kludex merged commit 2e504fd into encode:master Mar 24, 2024
5 checks passed
nixroxursox pushed a commit to nixroxursox/starlette that referenced this pull request Jul 20, 2024
* Add tests to test_datastructure

* Update tests

---------

Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants