diff --git a/archinstall/lib/profile/profiles_handler.py b/archinstall/lib/profile/profiles_handler.py index d09364fb33..e3031d4718 100644 --- a/archinstall/lib/profile/profiles_handler.py +++ b/archinstall/lib/profile/profiles_handler.py @@ -265,6 +265,7 @@ def _import_profile_from_url(self, url: str) -> None: profiles = self._process_profile_file(filepath) self.remove_custom_profiles(profiles) + self.add_custom_profiles(profiles) def _load_profile_class(self, module: ModuleType) -> list[Profile]: """ diff --git a/tests/test_profile_url_import.py b/tests/test_profile_url_import.py new file mode 100644 index 0000000000..3e56bdaa2e --- /dev/null +++ b/tests/test_profile_url_import.py @@ -0,0 +1,29 @@ +from pytest import MonkeyPatch + +from archinstall.lib.profile.profiles_handler import ProfileHandler, ProfileSerialization + + +def test_parse_profile_config_imports_profile_from_url(monkeypatch: MonkeyPatch) -> None: + custom_profile_code = b""" +from archinstall.default_profiles.profile import Profile, ProfileType + +class CustomUrlProfile(Profile): + def __init__(self) -> None: + super().__init__('CustomUrlProfile', ProfileType.CustomType) +""" + + monkeypatch.setattr( + 'archinstall.lib.profile.profiles_handler.fetch_data_from_url', + lambda _url: custom_profile_code, + ) + + handler = ProfileHandler() + profile_config: ProfileSerialization = { + 'path': 'https://example.com/custom_profile.py', + 'main': 'CustomUrlProfile', + } + + profile = handler.parse_profile_config(profile_config) + + assert profile is not None + assert profile.name == 'CustomUrlProfile'