diff --git a/plinth/app.py b/plinth/app.py index f23ed4f85..cb5eff328 100644 --- a/plinth/app.py +++ b/plinth/app.py @@ -49,6 +49,11 @@ class App: """Return an app with given ID.""" return cls._all_apps[app_id] + @classmethod + def list(cls): + """Return a list of all apps.""" + return cls._all_apps.values() + def add(self, component): """Add a component to an app.""" self.components[component.component_id] = component diff --git a/plinth/tests/test_app.py b/plinth/tests/test_app.py index 9f8c73a37..d727a15b3 100644 --- a/plinth/tests/test_app.py +++ b/plinth/tests/test_app.py @@ -62,12 +62,18 @@ def test_app_instantiation(): assert len(app._all_apps) == 1 -def test_get(): +def test_app_get(): """Test that an app can be correctly retrieved.""" app = AppTest() assert App.get(app.app_id) == app +def test_app_list(): + """Test listing all apps.""" + app = AppTest() + assert list(App.list()) == [app] + + def test_app_add(): """Test adding a components to an App.""" app = AppTest()