mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-03 10:50:20 +00:00
app: Add API to uninstall an app
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
22fef4d521
commit
aa94d9f622
@ -133,6 +133,11 @@ class App:
|
||||
for component in self.components.values():
|
||||
component.setup(old_version=old_version)
|
||||
|
||||
def uninstall(self):
|
||||
"""De-configure and uninstall the app."""
|
||||
for component in self.components.values():
|
||||
component.uninstall()
|
||||
|
||||
def get_setup_state(self) -> SetupState:
|
||||
"""Return whether the app is not setup or needs upgrade."""
|
||||
current_version = self.get_setup_version()
|
||||
@ -280,6 +285,9 @@ class Component:
|
||||
def setup(self, old_version):
|
||||
"""Run operations to install and configure the component."""
|
||||
|
||||
def uninstall(self):
|
||||
"""De-configure and uninstall the component."""
|
||||
|
||||
def enable(self):
|
||||
"""Run operations to enable the component."""
|
||||
|
||||
|
||||
@ -126,7 +126,7 @@ def test_get_components_of_type(app_with_components):
|
||||
|
||||
|
||||
def test_app_setup(app_with_components):
|
||||
"""Test that running setup on an app run setup on components."""
|
||||
"""Test that running setup on an app runs setup on components."""
|
||||
for component in app_with_components.components.values():
|
||||
component.setup = Mock()
|
||||
|
||||
@ -135,6 +135,16 @@ def test_app_setup(app_with_components):
|
||||
component.setup.assert_has_calls([call(old_version=2)])
|
||||
|
||||
|
||||
def test_app_uninstall(app_with_components):
|
||||
"""Test that running uninstall on an app runs uninstall on components."""
|
||||
for component in app_with_components.components.values():
|
||||
component.uninstall = Mock()
|
||||
|
||||
app_with_components.uninstall()
|
||||
for component in app_with_components.components.values():
|
||||
component.uninstall.assert_has_calls([call()])
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_setup_state():
|
||||
"""Test retrieving the current setup state of the app."""
|
||||
@ -284,6 +294,12 @@ def test_component_setup():
|
||||
assert component.setup(old_version=1) is None
|
||||
|
||||
|
||||
def test_component_uninstall():
|
||||
"""Test running uninstall on component."""
|
||||
component = Component('test-component')
|
||||
assert component.uninstall() is None
|
||||
|
||||
|
||||
def test_component_enable():
|
||||
"""Test running enable on component."""
|
||||
component = Component('test-component')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user