package: Implement uninstall in Package component

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2022-08-18 22:08:01 -07:00 committed by James Valleroy
parent aa94d9f622
commit a1c6c7b6a7
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 19 additions and 0 deletions

View File

@ -176,6 +176,10 @@ class Packages(app.FollowerComponent):
install(self.get_actual_packages(),
skip_recommends=self.skip_recommends)
def uninstall(self):
"""Uninstall and purge the packages."""
uninstall(self.get_actual_packages())
def diagnose(self):
"""Run diagnostics and return results."""
results = super().diagnose()

View File

@ -114,6 +114,21 @@ def test_packages_setup(install):
install.assert_has_calls([call(['python3'], skip_recommends=False)])
@patch('plinth.package.uninstall')
def test_packages_uninstall(uninstall):
"""Test uninstalling packages component."""
class TestApp(App):
"""Test app"""
app_id = 'test-app'
component = Packages('test-component', ['python3', 'bash'])
app = TestApp()
app.add(component)
app.uninstall()
uninstall.assert_has_calls([call(['python3', 'bash'])])
@patch('apt.Cache')
def test_diagnose(cache):
"""Test checking for latest version of the package."""