def fetch_archives(self, download_path: Path) -> List[Tuple[str, str, Path]]: """Fetches archives, list of (<package-name>, <package-version>, <dl-path>).""" downloaded = list() for package in self.cache.get_changes(): try: dl_path = package.candidate.fetch_binary(str(download_path)) except apt.package.FetchError as e: raise errors.PackageFetchError(str(e)) downloaded.append((package.name, package.candidate.version, Path(dl_path))) return downloaded
def test_get_package_fetch_error(self): self.fake_apt_cache.return_value.__enter__.return_value.fetch_archives.side_effect = errors.PackageFetchError( "foo") raised = self.assertRaises( errors.PackageFetchError, repo.Ubuntu.fetch_stage_packages, package_names=["fake-package"], stage_packages_path=Path(self.path), base="core", ) self.assertThat(str(raised), Equals("Package fetch error: foo"))