Skip to content

Commit 6130d90

Browse files
author
mathioud
committed
Test added for relative_links + minor fixes
Signed-off-by: mathioud <georgios.mathioudakis@here.com>
1 parent 3d535f7 commit 6130d90

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

tests/data/fetch_links_test.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!DOCTYPE html>
2+
<html><head><title>Simple Index</title><meta name="api-version" value="2" /></head><body>
3+
<a href="../sources.whl#sha256=a4e66406acabbb0a6606c89c5e61bacd2847f5393818b90490021a3929b47807" rel="internal">sources.whl</a><br />
4+
</body></html>

tests/test_resolution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def test_get_resolved_dependencies_with_tilde_requirement_using_json_api():
121121
assert plist == [
122122
"pkg:pypi/click@8.1.3",
123123
"pkg:pypi/flask@2.1.3",
124-
"pkg:pypi/importlib-metadata@6.6.0",
124+
"pkg:pypi/importlib-metadata@6.7.0",
125125
"pkg:pypi/itsdangerous@2.1.2",
126126
"pkg:pypi/jinja2@3.1.2",
127127
"pkg:pypi/markupsafe@2.1.3",

tests/test_utils.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ def test_fetch_links(mock_get):
5858
with open(result_file, "w") as file:
5959
json.dump(links, file, indent=4)
6060
check_json_results(result_file, expected_file, clean=False)
61+
#Testing relative links
62+
realtive_links_file= test_env.get_test_loc("fetch_links_test.html")
63+
with open(realtive_links_file) as realtive_file:
64+
mock_get.return_value = realtive_file.read()
65+
relative_links = PypiSimpleRepository().fetch_links(normalized_name="")
66+
relative_links_result_file = test_env.get_temp_file("json")
67+
relative_links_expected_file = test_env.get_test_loc("relative-links-expected.json", must_exist=False)
68+
with open(relative_links_result_file, "w") as file:
69+
json.dump(links, file, indent=4)
70+
check_json_results(relative_links_result_file, relative_links_expected_file, clean=False)
6171

6272

6373
def test_parse_reqs():
@@ -99,3 +109,11 @@ def test_parse_reqs_with_setup_requires_and_python_requires():
99109
def test_valid_python_version():
100110
assert valid_python_version("3.8", ">3.1")
101111
assert not valid_python_version("3.8.1", ">3.9")
112+
113+
114+
# def test_parsing_relative_urls():
115+
# self.index_url= test_fetch_links ("tests/data/fetch_links_test.html")
116+
# normalized_name=""
117+
# simple=PypiSimpleRepository()
118+
# assert simple.fetch_links(normalized_name)==""
119+

0 commit comments

Comments
 (0)