Skip to content

Commit

Permalink
test: check that invalid package names are filtered out (#7980)
Browse files Browse the repository at this point in the history
  • Loading branch information
ralbertazzi authored Jun 5, 2023
1 parent e1344ef commit a9ac06f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/repositories/fixtures/legacy/pytest-with-extra-packages.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>

<head>
<title>Links for pytest</title>
</head>

<body>
<h1>Links for pytest</h1>
<a href="https://files.pythonhosted.org/packages/ed/96/271c93f75212c06e2a7ec3e2fa8a9c90acee0a4838dc05bf379ea09aae31/pytest-3.5.0-py2.py3-none-any.whl#sha256=6266f87ab64692112e5477eba395cfedda53b1933ccd29478e671e73b420c19c"
data-requires-python="&gt;=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*">pytest-3.5.0-py2.py3-none-any.whl</a><br />
<a href="https://files.pythonhosted.org/packages/2d/56/6019153cdd743300c5688ab3b07702355283e53c83fbf922242c053ffb7b/pytest-3.5.0.tar.gz#sha256=fae491d1874f199537fd5872b5e1f0e74a009b979df9d53d1553fd03da1703e1"
data-requires-python="&gt;=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*">pytest-3.5.0.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/2d/99/b2c4e9d5a30f6471e410a146232b4118e697fa3ffc06d6a65efde84debd0/futures-3.2.0-py2-none-any.whl#sha256=ec0a6cb848cc212002b9828c3e34c675e0c9ff6741dc445cab6fdd4e1085d1f1"
data-requires-python="&gt;=2.6, &lt;3">futures-3.2.0-py2-none-any.whl</a><br />
<a href="https://files.pythonhosted.org/packages/2d/99/b2c4e9d5a30f6471e410a146232b4118e697fa3ffc06d6a65efde84debd0/futures-3.2.0-py2-none-any.whl#sha256=ec0a6cb848cc212002b9828c3e34c675e0c9ff6741dc445cab6fdd4e1085d1f1"
data-requires-python="&gt;=2.6, &lt;3">pytest-3.10.0-py2.py3-none-any.whl</a><br />
<a href="https://files.pythonhosted.org/packages/2d/99/b2c4e9d5a30f6471e410a146232b4118e697fa3ffc06d6a65efde84debd0/futures-3.2.0-py2-none-any.whl#sha256=ec0a6cb848cc212002b9828c3e34c675e0c9ff6741dc445cab6fdd4e1085d1f1"
data-requires-python="&gt;=2.6, &lt;3">pytest-3.5.0-py2.py3-none-any.whl</a><br />
</body>

</html>
<!--SERIAL 7198641-->
24 changes: 24 additions & 0 deletions tests/repositories/test_legacy_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,30 @@ def test_page_invalid_version_link() -> None:
assert packages[0].version.to_string() == "0.1.0"


def test_page_filters_out_invalid_package_names() -> None:
class SpecialMockRepository(MockRepository):
def _get_page(self, name: NormalizedName) -> SimpleRepositoryPage:
return super()._get_page(canonicalize_name(f"{name}-with-extra-packages"))

repo = SpecialMockRepository()
packages = repo.find_packages(Factory.create_dependency("pytest", "*"))
assert len(packages) == 1
assert packages[0].name == "pytest"
assert packages[0].version == Version.parse("3.5.0")

package = repo.package("pytest", Version.parse("3.5.0"))
assert package.files == [
{
"file": "pytest-3.5.0-py2.py3-none-any.whl",
"hash": "sha256:6266f87ab64692112e5477eba395cfedda53b1933ccd29478e671e73b420c19c", # noqa: E501
},
{
"file": "pytest-3.5.0.tar.gz",
"hash": "sha256:fae491d1874f199537fd5872b5e1f0e74a009b979df9d53d1553fd03da1703e1", # noqa: E501
},
]


def test_sdist_format_support() -> None:
repo = MockRepository()
page = repo.get_page("relative")
Expand Down

0 comments on commit a9ac06f

Please sign in to comment.