diff --git a/plinth/package.py b/plinth/package.py index 9531b9e53..fe03981e7 100644 --- a/plinth/package.py +++ b/plinth/package.py @@ -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() diff --git a/plinth/tests/test_package.py b/plinth/tests/test_package.py index 7e6cf12d5..66ddafb15 100644 --- a/plinth/tests/test_package.py +++ b/plinth/tests/test_package.py @@ -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."""