-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New Features, Examples Refactoring and Bug Fix - Unit Tests #881
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
Conversation
| assert "link_urls" in result_state | ||
| assert "img_urls" in result_state | ||
|
|
||
| assert "https://example.com" in result_state["link_urls"] |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High test
https://example.com
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 11 months ago
To fix the problem, we need to ensure that the URL is properly parsed and validated before performing the check. This can be done by using the urlparse function from the urllib.parse module to extract the hostname and then performing the check on the parsed hostname.
- Parse the URL using
urlparseto extract the hostname. - Check if the hostname matches the expected value.
- Update the test case to use this new validation method.
-
Copy modified lines R112-R118
| @@ -111,5 +111,9 @@ | ||
|
|
||
| assert "https://example.com" in result_state["link_urls"] | ||
| assert "https://sourcesite.com/relative/path.html" in result_state["link_urls"] | ||
| assert "https://sourcesite.com/image.jpg" in result_state["img_urls"] | ||
| from urllib.parse import urlparse | ||
| def get_hostname(url): | ||
| return urlparse(url).hostname | ||
|
|
||
| assert any(get_hostname(url) == "example.com" for url in result_state["link_urls"]) | ||
| assert any(get_hostname(url) == "sourcesite.com" and url.endswith("/relative/path.html") for url in result_state["link_urls"]) | ||
| assert any(get_hostname(url) == "sourcesite.com" and url.endswith("/image.jpg") for url in result_state["img_urls"]) | ||
| assert len(result_state["chunks"]) > 0 |
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.

Test Coverage Improvements 🎯
This PR adds new tests to improve coverage across multiple files.
Summary
Detailed Changes
tests/test_split_text_into_chunks.pytests/test_tokenizer.pytests/test_tokenizer_openai.pytests/test_parse_node.pytests/test_generate_answer_node.pytests/test_chromium.py