Correction to account for vcs only (no index urls)

This commit is contained in:
Matt Davis 2023-06-26 20:25:28 -04:00
parent ae3f7f4906
commit e862bc9c4e
No known key found for this signature in database
GPG Key ID: 5B56EE1B446A032A
2 changed files with 17 additions and 7 deletions

View File

@ -136,6 +136,6 @@ class SearchScope:
index_urls = self.index_urls
if project_name in self.index_lookup:
index_urls = [self.index_lookup[project_name]]
else:
elif self.index_urls:
index_urls = [self.index_urls[0]]
return [mkurl_pypi_url(url) for url in index_urls]

View File

@ -25,8 +25,8 @@ class TestSearchScope:
assert "links-user:****@page.domain.com" in result
assert "links-pass" not in result
def test_get_index_urls_locations(self) -> None:
"""Check that the canonical name is on all indexes"""
def test_get_index_urls_location_default(self) -> None:
"""Check that the default index url is used when no index is specified."""
search_scope = SearchScope(
find_links=[],
index_urls=["file://index1/", "file://index2"],
@ -35,7 +35,17 @@ class TestSearchScope:
req = install_req_from_line("Complex_Name")
assert req.name is not None
actual = search_scope.get_index_urls_locations(req.name)
assert actual == [
"file://index1/complex-name/",
"file://index2/complex-name/",
]
assert actual == ["file://index1/complex-name/"]
def test_get_index_urls_location_specified(self) -> None:
"""Check that the specified index url is used."""
search_scope = SearchScope(
find_links=[],
index_urls=["file://index1/", "file://index2"],
no_index=False,
index_lookup={"complex-name": "file://index2"},
)
req = install_req_from_line("Complex_Name")
assert req.name is not None
actual = search_scope.get_index_urls_locations(req.name)
assert actual == ["file://index2/complex-name/"]