Skip to content

fix(TestExtractFilePkg): avoid downloading files in tests #1784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added test/assets/test.pkg
Binary file not shown.
13 changes: 4 additions & 9 deletions test/test_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@
from asyncio import coroutine
from io import BytesIO
from pathlib import Path
from test.utils import (
CURL_7_20_0_URL,
GLIB_PKG_URL,
TAR_ZST_URL,
TMUX_DEB,
download_file,
)
from test.utils import CURL_7_20_0_URL, TAR_ZST_URL, TMUX_DEB, download_file
from typing import Dict, List
from zipfile import ZipFile, ZipInfo

Expand All @@ -36,6 +30,7 @@
DOVECOT_FILE_PATH = (
TEST_DIR_PATH / "condensed-downloads" / "dovecot-2.3.14-1.fc34.i686.rpm"
)
PKG_FILE_PATH = TEST_DIR_PATH / "assets" / "test.pkg"
CAB_TEST_FILE_PATH = TEST_DIR_PATH / "assets" / "cab-test-python3.8.cab"


Expand Down Expand Up @@ -177,7 +172,7 @@ class TestExtractFilePkg(TestExtractorBase):

def setup_method(self):
assert inpath("tar") or inpath("7z"), "Required tools 'tar' or '7z' not found"
download_file(GLIB_PKG_URL, self.tempdir / "test.pkg")
shutil.copyfile(PKG_FILE_PATH, self.tempdir / "test.pkg")

@pytest.fixture
def extension_list(self) -> List[str]:
Expand Down Expand Up @@ -211,7 +206,7 @@ async def test_extract_file_pkg(
async for extracted_path in self.extract_files(
[f"test{extension}" for extension in extension_list]
):
assert (Path(extracted_path) / "usr" / "local" / "bin" / "gio").is_file()
assert (Path(extracted_path) / "dir" / "dir2" / "file").is_file()


class TestExtractFileRpmWithZstd(TestExtractorBase):
Expand Down
4 changes: 0 additions & 4 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
TMUX_DEB = "https://mirrors.cat.pdx.edu/ubuntu/pool/main/t/tmux/" + TMUX_DEB_NAME
TAR_ZST_NAME = "tar-1.34-1-x86_64.pkg.tar.zst"
TAR_ZST_URL = "https://ftp5.gwdg.de/pub/linux/archlinux/core/os/x86_64/" + TAR_ZST_NAME
GLIB_PKG_NAME = "glib-2.70.4_3,2.pkg"
GLIB_PKG_URL = (
"https://pkg.freebsd.org/FreeBSD:12:aarch64/quarterly/All/" + GLIB_PKG_NAME
)


class TempDirTest:
Expand Down