From 0efca3cadbad5517a59884576ddb90cfe7ac30f8 Mon Sep 17 00:00:00 2001 From: Diego Russo Date: Mon, 30 May 2022 13:34:14 +0100 Subject: Add MLIA codebase Add MLIA codebase including sources and tests. Change-Id: Id41707559bd721edd114793618d12ccd188d8dbd --- tests/mlia/test_cli_config.py | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/mlia/test_cli_config.py (limited to 'tests/mlia/test_cli_config.py') diff --git a/tests/mlia/test_cli_config.py b/tests/mlia/test_cli_config.py new file mode 100644 index 0000000..6d19eec --- /dev/null +++ b/tests/mlia/test_cli_config.py @@ -0,0 +1,49 @@ +# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates. +# SPDX-License-Identifier: Apache-2.0 +"""Tests for cli.config module.""" +from typing import List +from unittest.mock import MagicMock + +import pytest + +from mlia.cli.config import get_default_backends +from mlia.cli.config import is_corstone_backend + + +@pytest.mark.parametrize( + "available_backends, expected_default_backends", + [ + [["Vela"], ["Vela"]], + [["Corstone-300"], ["Corstone-300"]], + [["Corstone-310"], ["Corstone-310"]], + [["Corstone-300", "Corstone-310"], ["Corstone-310"]], + [["Vela", "Corstone-300", "Corstone-310"], ["Vela", "Corstone-310"]], + [ + ["Vela", "Corstone-300", "Corstone-310", "New backend"], + ["Vela", "Corstone-310", "New backend"], + ], + [ + ["Vela", "Corstone-300", "New backend"], + ["Vela", "Corstone-300", "New backend"], + ], + ], +) +def test_get_default_backends( + monkeypatch: pytest.MonkeyPatch, + available_backends: List[str], + expected_default_backends: List[str], +) -> None: + """Test function get_default backends.""" + monkeypatch.setattr( + "mlia.cli.config.get_available_backends", + MagicMock(return_value=available_backends), + ) + + assert get_default_backends() == expected_default_backends + + +def test_is_corstone_backend() -> None: + """Test function is_corstone_backend.""" + assert is_corstone_backend("Corstone-300") is True + assert is_corstone_backend("Corstone-310") is True + assert is_corstone_backend("New backend") is False -- cgit v1.2.1