mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-03 10:50:20 +00:00
app: Introduce API to return a list of all apps
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
176e7ecae3
commit
d9f6928001
@ -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
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user