diff --git a/archinstall/lib/global_menu.py b/archinstall/lib/global_menu.py index b21e4c14..410fdf9f 100644 --- a/archinstall/lib/global_menu.py +++ b/archinstall/lib/global_menu.py @@ -1,6 +1,6 @@ import inspect -from collections.abc import Callable -from typing import Any, override +from functools import wraps +from typing import override from archinstall.default_profiles.profile import GreeterType from archinstall.lib.applications.application_menu import ApplicationMenu @@ -80,7 +80,6 @@ class GlobalMenu(AbstractMenu[None]): return '[bold green][✓][/bold green] ' return '[bold red][!][/bold red] ' - # Standard mandatory or configured item check if item.has_value(): return '[bold green][✓][/bold green] ' elif item.mandatory: @@ -101,22 +100,24 @@ class GlobalMenu(AbstractMenu[None]): prefix = self._get_status_prefix(item) item.text = f'{prefix}{base_title}' - def _wrap_action(self, key: str, action: Callable[..., Any]) -> Callable[..., Any]: - async def wrapper(*args, **kwargs) -> Any: - if inspect.iscoroutinefunction(action): - result = await action(*args, **kwargs) - else: - result = action(*args, **kwargs) - if inspect.isawaitable(result): - result = await result + def _wrap_action(item_dictionary, update_callback, key, action): + @wraps(action) + async def wrapper(*args, **kwargs): + try: + if inspect.iscoroutinefunction(action): + result = await action(*args, **kwargs) + else: + result = action(*args, **kwargs) + if inspect.isawaitable(result): + result = await result - item = self._item_group.find_by_key(key) - if item: - item.value = result + if key in item_dictionary: + item_dictionary[key].value = result - self._update_item_labels() + return result - return result + finally: + update_callback() return wrapper diff --git a/tests/test_configuration_output.py b/tests/test_configuration_output.py deleted file mode 100644 index cbedc026..00000000 --- a/tests/test_configuration_output.py +++ /dev/null @@ -1,63 +0,0 @@ -import json -from pathlib import Path - -from pytest import MonkeyPatch - -from archinstall.lib.args import USER_CONFIG_FILE, USER_CREDS_FILE, ArchConfigHandler - - -def test_user_config_roundtrip( - monkeypatch: MonkeyPatch, - config_fixture: Path, -) -> None: - monkeypatch.setattr('sys.argv', ['archinstall', '--config', str(config_fixture)]) - - handler = ArchConfigHandler() - arch_config = handler.config - - # the version is retrieved dynamically from an installed archinstall package - # as there is no version present in the test environment we'll set it manually - arch_config.version = '3.0.2' - - test_out_dir = Path('/tmp/') - test_out_file = test_out_dir / USER_CONFIG_FILE - - arch_config.save(test_out_dir) - - result = json.loads(test_out_file.read_text()) - expected = json.loads(config_fixture.read_text()) - - # the parsed config will check if the given device exists otherwise - # it will ignore the modification; as this test will run on various local systems - # and the CI pipeline there's no good way specify a real device so we'll simply - # copy the expected result to the actual result - result['disk_config']['config_type'] = expected['disk_config']['config_type'] - result['disk_config']['device_modifications'] = expected['disk_config']['device_modifications'] - - assert json.dumps( - result['mirror_config'], - sort_keys=True, - ) == json.dumps( - expected['mirror_config'], - sort_keys=True, - ) - - -def test_creds_roundtrip( - monkeypatch: MonkeyPatch, - creds_fixture: Path, -) -> None: - monkeypatch.setattr('sys.argv', ['archinstall', '--creds', str(creds_fixture)]) - - handler = ArchConfigHandler() - arch_config = handler.config - - test_out_dir = Path('/tmp/') - test_out_file = test_out_dir / USER_CREDS_FILE - - arch_config.save(test_out_dir, creds=True) - - result = json.loads(test_out_file.read_text()) - expected = json.loads(creds_fixture.read_text()) - - assert sorted(result.items()) == sorted(expected.items())