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:
Sunil Mohan Adapa 2019-12-11 17:55:37 -05:00 committed by James Valleroy
parent 176e7ecae3
commit d9f6928001
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 12 additions and 1 deletions

View File

@ -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

View File

@ -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()