From 6b5c806302b5bd65b26629cd8e02fb94be26c971 Mon Sep 17 00:00:00 2001 From: Yashu Garg Date: Wed, 1 Jun 2022 21:58:04 +0530 Subject: [PATCH 1/2] test:extractor: added zst file test --- test/test_extractor.py | 21 ++++++++++++++++++++- test/utils.py | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/test/test_extractor.py b/test/test_extractor.py index e9001407d8..f73a29573d 100644 --- a/test/test_extractor.py +++ b/test/test_extractor.py @@ -9,7 +9,7 @@ import unittest.mock from io import BytesIO from os import path -from test.utils import CURL_7_20_0_URL, TMUX_DEB, download_file +from test.utils import CURL_7_20_0_URL, TAR_ZST_URL, TMUX_DEB, download_file from typing import List from zipfile import ZipFile, ZipInfo @@ -140,6 +140,25 @@ async def test_extract_file_rpm_no_rpm2cipo(self, extension_list: List[str]): mock_aio_run_command.assert_not_called() +class TestExtractFileZst(TestExtractorBase): + """Tests for the zst file extractor""" + + def setup_method(self): + download_file(TAR_ZST_URL, path.join(self.tempdir, "test.zst")) + + @pytest.fixture + def extension_list(self) -> List[str]: + return self.extractor.file_extractors[self.extractor.extract_file_zst] + + @pytest.mark.asyncio + async def test_extract_file_zst(self, extension_list: List[str]): + """Test the zst file extraction""" + async for extracted_path in self.extract_files( + [f"test{extension}" for extension in extension_list] + ): + assert path.isfile(path.join(extracted_path, "usr", "bin", "tar")) + + class TestExtractFileDeb(TestExtractorBase): """Tests for deb file extractor""" diff --git a/test/utils.py b/test/utils.py index 42938ef402..f5c8aa3b36 100644 --- a/test/utils.py +++ b/test/utils.py @@ -20,6 +20,8 @@ ) TMUX_DEB_NAME = "tmux_1.8-5_amd64.deb" 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 class TempDirTest: From ebb4a5da2e00eed730e6c1321fe9d414b562e416 Mon Sep 17 00:00:00 2001 From: Yashu Garg Date: Thu, 2 Jun 2022 03:43:17 +0530 Subject: [PATCH 2/2] test:extractor: added pkg file test --- test/test_extractor.py | 28 +++++++++++++++++++++++++++- test/utils.py | 4 ++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/test/test_extractor.py b/test/test_extractor.py index f73a29573d..2c8dd74887 100644 --- a/test/test_extractor.py +++ b/test/test_extractor.py @@ -9,7 +9,13 @@ import unittest.mock from io import BytesIO from os import path -from test.utils import CURL_7_20_0_URL, TAR_ZST_URL, TMUX_DEB, download_file +from test.utils import ( + CURL_7_20_0_URL, + GLIB_PKG_URL, + TAR_ZST_URL, + TMUX_DEB, + download_file, +) from typing import List from zipfile import ZipFile, ZipInfo @@ -159,6 +165,26 @@ async def test_extract_file_zst(self, extension_list: List[str]): assert path.isfile(path.join(extracted_path, "usr", "bin", "tar")) +class TestExtractFilePkg(TestExtractorBase): + """Tests for pkg file extractor""" + + def setup_method(self): + assert inpath("tar") or inpath("7z"), "Required tools 'tar' or '7z' not found" + download_file(GLIB_PKG_URL, path.join(self.tempdir, "test.pkg")) + + @pytest.fixture + def extension_list(self) -> List[str]: + return self.extractor.file_extractors[self.extractor.extract_file_pkg] + + @pytest.mark.asyncio + async def test_extract_file_pkg(self, extension_list: List[str]): + """Test the pkg file extraction""" + async for extracted_path in self.extract_files( + [f"test{extension}" for extension in extension_list] + ): + assert path.isfile(path.join(extracted_path, "usr", "local", "bin", "gio")) + + class TestExtractFileDeb(TestExtractorBase): """Tests for deb file extractor""" diff --git a/test/utils.py b/test/utils.py index f5c8aa3b36..f705ca4966 100644 --- a/test/utils.py +++ b/test/utils.py @@ -22,6 +22,10 @@ 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: