diff options
author | Dmitrii Agibov <dmitrii.agibov@arm.com> | 2023-01-27 09:12:50 +0000 |
---|---|---|
committer | Benjamin Klimczak <benjamin.klimczak@arm.com> | 2023-02-08 15:25:11 +0000 |
commit | 3e3dcb9bd5abb88adcd85b4f89e8a81e7f6fa293 (patch) | |
tree | 020eee6abef093113de5b49c135c915c37173843 /tests/test_backend_manager.py | |
parent | 836efd40317a397761ec8b66e3f4398faac43ad0 (diff) | |
download | mlia-3e3dcb9bd5abb88adcd85b4f89e8a81e7f6fa293.tar.gz |
MLIA-595 Remove old backend configuration mechanism
- Remove old backend configuration code
- Install backends into directory ~/.mlia
- Rename targets/backends in registry to make it consistent
across codebase.
Change-Id: I9c8b012fe863280f1c692940c0dcad3ef638aaae
Diffstat (limited to 'tests/test_backend_manager.py')
-rw-r--r-- | tests/test_backend_manager.py | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/tests/test_backend_manager.py b/tests/test_backend_manager.py index 19cb357..879353e 100644 --- a/tests/test_backend_manager.py +++ b/tests/test_backend_manager.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates. +# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates. # SPDX-License-Identifier: Apache-2.0 """Tests for installation manager.""" from __future__ import annotations @@ -16,6 +16,8 @@ from mlia.backend.install import Installation from mlia.backend.install import InstallationType from mlia.backend.install import InstallFromPath from mlia.backend.manager import DefaultInstallationManager +from mlia.core.errors import ConfigurationError +from mlia.core.errors import InternalError def get_default_installation_manager_mock( @@ -255,6 +257,25 @@ def test_installation_manager_install_from( install_mock.uninstall.assert_not_called() +def test_installation_manager_unsupported_install_type( + monkeypatch: pytest.MonkeyPatch, + tmp_path: Path, +) -> None: + """Test that installation could not be installed via unsupported type.""" + download_install_mock = _could_be_downloaded_and_installed_mock() + install_from_mock = _could_be_installed_from_mock() + install_mocks = [download_install_mock, install_from_mock] + + manager = get_installation_manager(False, install_mocks, monkeypatch) + manager.install_from(tmp_path, "could_be_downloaded_and_installed") + + manager.download_and_install("could_be_installed_from") + + for mock in install_mocks: + mock.install.assert_not_called() + mock.uninstall.assert_not_called() + + @pytest.mark.parametrize("noninteractive", [True, False]) @pytest.mark.parametrize( "install_mock, backend_name, expected_call", @@ -280,3 +301,39 @@ def test_installation_manager_uninstall( manager.uninstall(backend_name) assert install_mock.uninstall.mock_calls == expected_call + + +def test_installation_internal_error(monkeypatch: pytest.MonkeyPatch) -> None: + """Test that manager should be able to detect wrong state.""" + install_mock = _ready_for_uninstall_mock() + manager = get_installation_manager(False, [install_mock, install_mock], monkeypatch) + + with pytest.raises( + InternalError, + match="More than one installed backend with name already_installed found", + ): + manager.uninstall("already_installed") + + +def test_uninstall_unknown_backend(monkeypatch: pytest.MonkeyPatch) -> None: + """Test that uninstall should fail for uknown backend.""" + install_mock = _ready_for_uninstall_mock() + manager = get_installation_manager(False, [install_mock, install_mock], monkeypatch) + + with pytest.raises( + ConfigurationError, match="Backend 'some_backend' is not installed" + ): + manager.uninstall("some_backend") + + +def test_show_env_details(monkeypatch: pytest.MonkeyPatch) -> None: + """Test method show_env_details.""" + ready_to_install_mock = _ready_for_installation_mock() + could_be_installed_mock = _could_be_installed_from_mock() + + manager = get_installation_manager( + False, + [ready_to_install_mock, could_be_installed_mock], + monkeypatch, + ) + manager.show_env_details() |