Ejemplo n.º 1
0
def test_dependencies_failed(mocker: MockerFixture) -> None:
    """
    must raise exception if there are errors during srcinfo load
    """
    mocker.patch("pathlib.Path.read_text", return_value="")
    mocker.patch("ahriman.models.package.parse_srcinfo",
                 return_value=({
                     "packages": {}
                 }, ["an error"]))

    with pytest.raises(InvalidPackageInfo):
        Package.dependencies(Path("path"))
Ejemplo n.º 2
0
def test_dependencies_with_version(mocker: MockerFixture,
                                   resource_path_root: Path) -> None:
    """
    must load correct list of dependencies with version
    """
    srcinfo = (resource_path_root / "models" /
               "package_yay_srcinfo").read_text()
    mocker.patch("pathlib.Path.read_text", return_value=srcinfo)

    assert Package.dependencies(Path("path")) == {"git", "go", "pacman"}
Ejemplo n.º 3
0
 def load(cls: Type[Leaf], package: Package) -> Leaf:
     """
     load leaf from package with dependencies
     :param package: package properties
     :return: loaded class
     """
     clone_dir = Path(tempfile.mkdtemp())
     try:
         Task.fetch(clone_dir, package.git_url)
         dependencies = Package.dependencies(clone_dir)
     finally:
         shutil.rmtree(clone_dir, ignore_errors=True)
     return cls(package, dependencies)
Ejemplo n.º 4
0
 def process_dependencies(path: Path) -> None:
     if without_dependencies:
         return
     dependencies = Package.dependencies(path)
     self.add(dependencies.difference(known_packages), without_dependencies)