diff options
Diffstat (limited to 'tests/test_local_apt.py')
-rw-r--r-- | tests/test_local_apt.py | 24 |
1 files changed, 17 insertions, 7 deletions
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(): |