def test_lsarchive__returns_list_of_archive_members_with_explicit_extension_format( tmp_path: Path, arc_ext: str, source: Dir, expected: t.Set[Path]): archive_file = tmp_path / "archive" src_dir = create_archive_source(tmp_path, source) create_archive(archive_file, src_dir.items[0].path, ext=arc_ext) listing = sh.lsarchive(archive_file, ext=arc_ext) assert set(listing) == expected
def test_lsarchive__returns_list_of_archive_members(tmp_path: Path, arc_ext: str, source: Dir, expected: t.Set[Path]): archive_file = tmp_path / f"archive{arc_ext}" src_dir = create_archive_source(tmp_path, source) create_archive(archive_file, src_dir.items[0].path) listing = sh.lsarchive(archive_file) assert set(listing) == expected
def test_archive__uses_custom_root_path_inside_archive( tmp_path: Path, rep_ext: str, source: t.Union[File, Dir], root: Path, expected_listing: t.Set[Path], ): src_dir = create_archive_source(tmp_path, source) root = src_dir.path / root archive_file = tmp_path / f"archive{rep_ext}" sh.archive(archive_file, *(item.path for item in src_dir.items), root=root) assert archive_file.is_file() listing = set(sh.lsarchive(archive_file)) assert listing == expected_listing
def test_archive__archives_filtered_ls_sources( tmp_path: Path, arc_ext: str, sources: t.List[Dir], ls_func: t.Callable[[Path], sh.Ls], expected_listing: t.Set[Path], ): archive_file = tmp_path / f"archive{arc_ext}" _test_archive(tmp_path, archive_file, *sources, iteratee=ls_func, skip_extraction=True) listing = set(sh.lsarchive(archive_file)) assert listing == expected_listing
def test_archive__archives_relative_paths( tmp_path: Path, rep_ext: str, source: t.Union[File, Dir], root: t.Optional[Path], expected_listing: t.Set[Path], ): src_dir = create_archive_source(tmp_path, source) archive_file = tmp_path / f"archive{rep_ext}" with sh.cd(src_dir.path): items = [item.path.relative_to(src_dir.path) for item in src_dir.items] sh.archive(archive_file, *items, root=root) assert archive_file.is_file() listing = set(sh.lsarchive(archive_file)) assert listing == expected_listing
def test_archive__repaths_paths_inside_archive( tmp_path: Path, rep_ext: str, sources: t.List[t.Union[File, Dir]], paths: t.List[t.Union[str, Path, sh.Ls]], root: t.Optional[Path], repath: t.Optional[t.Union[str, dict]], expected_listing: t.Set[Path], ): src_dir = create_archive_source(tmp_path, *sources) archive_file = tmp_path / f"archive{rep_ext}" with sh.cd(src_dir.path): sh.archive(archive_file, *paths, root=root, repath=repath) assert archive_file.is_file() listing = set(sh.lsarchive(archive_file)) assert listing == expected_listing