Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Christophe Morin <[email protected]>
  • Loading branch information
JeanChristopheMorinPerso committed Feb 4, 2024
1 parent d96693f commit 278914c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
7 changes: 7 additions & 0 deletions docs/source/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@ Hooks
"package" in place.

:param package: An instanciate PackageMaker.

.. py:function:: cleanup(dist: importlib.metadata.Distribution, path: str) -> None
Cleanup a package post-installation.

:param dist: Python distribution.
:param path: Root path of the rez variant.
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ addopts =
--cov-report=term-missing
--cov-report=xml
--cov-report=html
--durations=0
#--durations=0

norecursedirs = rez_repo

Expand Down
3 changes: 2 additions & 1 deletion src/rez_pip/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def getManager() -> pluggy.PluginManager:
# Register the builtin plugins
for module in pkgutil.iter_modules(__path__):
manager.register(
importlib.import_module(f"rez_pip.plugins.{module.name}"), name=module.name
importlib.import_module(f"rez_pip.plugins.{module.name}"),
name=f"rez_pip.{module.name}",
)

manager.load_setuptools_entrypoints("rez-pip")
Expand Down
5 changes: 5 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def test_parseArgs_empty():
assert vars(args) == {
"constraint": None,
"keep_tmp_dirs": False,
"list_plugins": False,
"log_level": "info",
"packages": [],
"pip": rez_pip.pip.getBundledPip(),
Expand All @@ -44,6 +45,7 @@ def test_parseArgs_packages(packages):
assert vars(args) == {
"constraint": None,
"keep_tmp_dirs": False,
"list_plugins": False,
"log_level": "info",
"packages": packages,
"pip": rez_pip.pip.getBundledPip(),
Expand All @@ -63,6 +65,7 @@ def test_parseArgs_no_package_with_requirements(files):
assert vars(args) == {
"constraint": None,
"keep_tmp_dirs": False,
"list_plugins": False,
"log_level": "info",
"packages": [],
"pip": rez_pip.pip.getBundledPip(),
Expand All @@ -81,6 +84,7 @@ def test_parseArgs_constraints():
assert vars(args) == {
"constraint": ["asd", "adasdasd"],
"keep_tmp_dirs": False,
"list_plugins": False,
"log_level": "info",
"packages": [],
"pip": rez_pip.pip.getBundledPip(),
Expand All @@ -101,6 +105,7 @@ def test_parseArgs_pipArgs():
assert vars(args) == {
"constraint": None,
"keep_tmp_dirs": False,
"list_plugins": False,
"log_level": "info",
"packages": [],
"pip": rez_pip.pip.getBundledPip(),
Expand Down
23 changes: 18 additions & 5 deletions tests/test_rez.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
else:
import importlib_metadata

import rez_pip.pip
import rez_pip.rez
import rez_pip.utils

Expand Down Expand Up @@ -62,16 +63,28 @@ def make_file(path: str) -> importlib_metadata.PackagePath:
metadata={"is_pure_python": False},
)

packageGroup = rez_pip.pip.PackageGroup(
[
rez_pip.pip.PackageInfo(
metadata=rez_pip.pip.Metadata(name="package-a", version="1.0.0.post0"),
download_info=rez_pip.pip.DownloadInfo(
url=f"http://localhost/asd",
archive_info=rez_pip.pip.ArchiveInfo("hash", {}),
),
is_direct=True,
requested=True,
)
]
)
packageGroup.dists = [dist]

with unittest.mock.patch.object(
rez_pip.utils, "getRezRequirements", return_value=expectedRequirements
):
rez_pip.rez.createPackage(
dist,
False,
packageGroup,
rez.version.Version("3.7.0"),
[],
source,
"http://localhost/asd",
prefix=repo,
)

Expand All @@ -84,7 +97,7 @@ def make_file(path: str) -> importlib_metadata.PackagePath:
"name": dist.name,
"version": dist.version,
"is_pure_python": False,
"wheel_url": "http://localhost/asd",
"wheel_urls": ["http://localhost/asd"],
"rez_pip_version": importlib_metadata.version("rez-pip"),
"metadata": {},
}
Expand Down

0 comments on commit 278914c

Please sign in to comment.