mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
package: Add parameter to specify skipping package recommendations
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
057a125531
commit
2157cb33b7
@ -27,18 +27,23 @@ class Packages(app.FollowerComponent):
|
|||||||
of packages required by an app.
|
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.
|
"""Initialize a new packages component.
|
||||||
|
|
||||||
'component_id' should be a unique ID across all components of an app
|
'component_id' should be a unique ID across all components of an app
|
||||||
and across all components.
|
and across all components.
|
||||||
|
|
||||||
'packages' is the list of Debian packages managed by this component.
|
'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)
|
super().__init__(component_id)
|
||||||
|
|
||||||
self.component_id = component_id
|
self.component_id = component_id
|
||||||
self._packages = packages
|
self._packages = packages
|
||||||
|
self.skip_recommends = skip_recommends
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def packages(self) -> list[str]:
|
def packages(self) -> list[str]:
|
||||||
|
|||||||
@ -5,8 +5,25 @@ Test module for package module.
|
|||||||
|
|
||||||
from unittest.mock import call, patch
|
from unittest.mock import call, patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from plinth.errors import ActionError
|
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():
|
def test_packages_installed():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user