app: component: Add app_id and app properties

- So that with a component at hand, it's app can be easily retrieved.

- Don't create circular dependencies.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa authored and Veiko Aasa committed 2021-01-04 13:47:36 +02:00
1 parent d45cc00981
commit 734e4fea9a
2 files changed
+33 -1

No files matched your search

+14
View File
@@ -71,6 +71,7 @@ def test_app_add():
return_value = app.add(component)
assert len(app.components) == 1
assert app.components['test-component'] == component
assert component.app_id == app.app_id
assert return_value == app
@@ -79,6 +80,7 @@ def test_app_remove(app_with_components):
app = app_with_components
component = app.components['test-leader-1']
assert app.remove('test-leader-1') == component
assert component.app_id is None
assert 'test-leader-1' not in app.components
@@ -206,6 +208,18 @@ def test_component_initialization():
assert not component.is_leader
def test_component_app_property():
"""Test component's app property."""
component = Component('test-component')
assert component.app_id is None
with pytest.raises(KeyError):
assert not component.app
app = AppTest()
app.add(component)
assert component.app == app
def test_component_diagnose():
"""Test running diagnostics on component."""
component = Component('test-component')