diff --git a/plinth/package.py b/plinth/package.py index f2e1a1946..7257c5ca7 100644 --- a/plinth/package.py +++ b/plinth/package.py @@ -27,18 +27,23 @@ class Packages(app.FollowerComponent): of packages required by an app. """ - def __init__(self, component_id: str, packages: list[str]): + def __init__(self, component_id: str, packages: list[str], + skip_recommends=False): """Initialize a new packages component. 'component_id' should be a unique ID across all components of an app and across all components. 'packages' is the list of Debian packages managed by this component. + + 'skip_recommends' is a boolean specifying whether recommended packages + should be installed along with the listed packages. """ super().__init__(component_id) self.component_id = component_id self._packages = packages + self.skip_recommends = skip_recommends @property def packages(self) -> list[str]: diff --git a/plinth/tests/test_package.py b/plinth/tests/test_package.py index 3339172ca..8ae037f77 100644 --- a/plinth/tests/test_package.py +++ b/plinth/tests/test_package.py @@ -5,8 +5,25 @@ Test module for package module. from unittest.mock import call, patch +import pytest + from plinth.errors import ActionError -from plinth.package import packages_installed, remove +from plinth.package import Packages, packages_installed, remove + + +def test_packages_init(): + """Test initialization of packages component.""" + component = Packages('test-component', ['foo', 'bar']) + assert component.component_id == 'test-component' + assert component.packages == ['foo', 'bar'] + assert not component.skip_recommends + + with pytest.raises(ValueError): + Packages(None, []) + + component = Packages('test-component', [], skip_recommends=True) + assert component.packages == [] + assert component.skip_recommends def test_packages_installed():