aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_build.py12
-rw-r--r--tests/test_local_apt.py24
2 files changed, 17 insertions, 19 deletions
diff --git a/tests/test_build.py b/tests/test_build.py
index 3d564e3..968ac8d 100644
--- a/tests/test_build.py
+++ b/tests/test_build.py
@@ -176,15 +176,6 @@ expected_source_description = {
expected = [*expected_resources, expected_mapping, expected_source_description]
-@pytest.fixture
-def tmpdir() -> Iterable[str]:
- """
- Provide test case with a temporary directory that will be automatically
- deleted after the test.
- """
- with TemporaryDirectory() as tmpdir:
- yield Path(tmpdir)
-
def run_reuse(command, **kwargs):
"""
Instead of running a 'reuse' command, check if 'mock_reuse_missing' file
@@ -677,10 +668,7 @@ def test_build_error(tmpdir, sample_source, sample_source_make_errors):
error_type, error_regex = sample_source_make_errors
dstdir = Path(tmpdir) / 'dstdir'
- tmpdir = Path(tmpdir) / 'example'
-
dstdir.mkdir(exist_ok=True)
- tmpdir.mkdir(exist_ok=True)
with pytest.raises(error_type, match=error_regex):
build.Build(sample_source, Path('index.json'))\
diff --git a/tests/test_local_apt.py b/tests/test_local_apt.py
index edd47fa..f94ee37 100644
--- a/tests/test_local_apt.py
+++ b/tests/test_local_apt.py
@@ -341,7 +341,7 @@ def test_local_apt_download(mock_cache_dir):
destination.mkdir()
local_apt.download_apt_packages(sources_list, local_apt.default_keys,
- ['libjs-mathjax'], destination)
+ ['libjs-mathjax'], destination, False)
libjs_mathjax_path = destination / 'libjs-mathjax_0%3a2.7.9+dfsg-1_all.deb'
fonts_mathjax_path = destination / 'fonts-mathjax_0%3a2.7.9+dfsg-1_all.deb'
@@ -418,7 +418,7 @@ $\
with pytest.raises(local_apt.AptError, match=error_regex):
local_apt.download_apt_packages(sources_list, local_apt.default_keys,
- ['libjs-mathjax'], destination)
+ ['libjs-mathjax'], destination, False)
assert [*destination.iterdir()] == []
@@ -469,7 +469,7 @@ $\
with pytest.raises(local_apt.AptError, match=error_regex):
local_apt.download_apt_packages(sources_list, local_apt.default_keys,
- ['libjs-mathjax'], destination)
+ ['libjs-mathjax'], destination, False)
assert [*destination.iterdir()] == []
@@ -499,7 +499,7 @@ $\
with pytest.raises(local_apt.AptError, match=error_regex):
local_apt.download_apt_packages(sources_list, local_apt.default_keys,
- ['libjs-mathjax'], destination)
+ ['libjs-mathjax'], destination, False)
assert [*destination.iterdir()] == []
@@ -572,7 +572,8 @@ def mock_download_packages(monkeypatch):
'base_depends': True,
'identity': 'nabia',
'props': {'distribution': 'nabia', 'dependencies': False},
- 'all_keys': local_apt.default_keys
+ 'all_keys': local_apt.default_keys,
+ 'prepared_directory': False
},
{
'with_deps': True,
@@ -586,19 +587,22 @@ def mock_download_packages(monkeypatch):
'depend_on_base_packages': False
},
'all_keys': [*local_apt.default_keys, 'AB' * 20],
+ 'prepared_directory': True
}
])
@pytest.mark.usefixtures('mock_download_packages', 'mock_subprocess_run')
-def test_piggybacked_system_download(params):
+def test_piggybacked_system_download(params, tmpdir):
"""
Verify that the piggybacked_system() function properly downloads and unpacks
APT packages.
"""
+ foreign_packages_dir = tmpdir if params['prepared_directory'] else None
+
with local_apt.piggybacked_system({
'system': 'apt',
**params['props'],
'packages': ['some-bin-package', 'another-package=1.1-2']
- }, None) as piggybacked:
+ }, foreign_packages_dir) as piggybacked:
expected_depends = [{'identifier': 'apt-common-licenses'}] \
if params['base_depends'] else []
assert piggybacked.package_must_depend == expected_depends
@@ -626,6 +630,9 @@ def test_piggybacked_system_download(params):
else:
assert path.read_text() == f'dummy {path.name}'
+ if foreign_packages_dir is not None:
+ assert path.parent == foreign_packages_dir / 'apt'
+
license_files = {*piggybacked.package_license_files}
assert license_files == {
@@ -654,6 +661,9 @@ def test_piggybacked_system_download(params):
assert not root.exists()
+ if foreign_packages_dir:
+ assert [*tmpdir.iterdir()] == [tmpdir / 'apt']
+
@pytest.mark.subprocess_run(local_apt, run_dpkg_deb)
@pytest.mark.usefixtures('mock_subprocess_run')
def test_piggybacked_system_no_download():