FreedomBox/plinth/tests/test_setup.py
James Valleroy 35c2326261
setup: Add method to run app repair
- Repair is run within an operation.

- Diagnostics are run for the app first.

- Call app.repair, then re-run setup if needed.

- Add helper functions for apps or components to store error messages in thread
  local storage. These error messages are shown at the end.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
[sunil: Undo minor reformatting, due to automatic tool]
[sunil: Fix passing incorrect Exception argument to operation.on_update]
[sunil: Add full stop at the end of the success message to match install message]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-05-02 21:46:11 -07:00

20 lines
558 B
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Test module for setup module.
"""
from plinth.setup import store_error_message, retrieve_error_messages
def test_store_retrieve_error_message():
"""Test storing and retrieving error messages."""
store_error_message('error 1')
assert retrieve_error_messages() == ['error 1']
store_error_message('error 1')
store_error_message('error 2')
assert retrieve_error_messages() == ['error 1', 'error 2']
# errors are cleared after retrieving
assert retrieve_error_messages() == []