diff options
author | Benjamin Klimczak <benjamin.klimczak@arm.com> | 2022-07-11 12:33:42 +0100 |
---|---|---|
committer | Benjamin Klimczak <benjamin.klimczak@arm.com> | 2022-07-26 14:08:21 +0100 |
commit | 5d81f37de09efe10f90512e50252be9c36925fcf (patch) | |
tree | b4d7cdfd051da0a6e882bdfcf280fd7ca7b39e57 /tests/mlia/test_cli_logging.py | |
parent | 7899b908c1fe6d86b92a80f3827ddd0ac05b674b (diff) | |
download | mlia-5d81f37de09efe10f90512e50252be9c36925fcf.tar.gz |
MLIA-551 Rework remains of AIET architecture
Re-factoring the code base to further merge the old AIET code into MLIA.
- Remove last traces of the backend type 'tool'
- Controlled systems removed, including SSH protocol, controller,
RunningCommand, locks etc.
- Build command / build dir and deploy functionality removed from
Applications and Systems
- Moving working_dir()
- Replace module 'output_parser' with new module 'output_consumer' and
merge Base64 parsing into it
- Change the output consumption to optionally remove (i.e. actually
consume) lines
- Use Base64 parsing in GenericInferenceOutputParser, replacing the
regex-based parsing and remove the now unused regex parsing
- Remove AIET reporting
- Pre-install applications by moving them to src/mlia/resources/backends
- Rename aiet-config.json to backend-config.json
- Move tests from tests/mlia/ to tests/
- Adapt unit tests to code changes
- Dependencies removed: paramiko, filelock, psutil
- Fix bug in corstone.py: The wrong resource directory was used which
broke the functionality to download backends.
- Use f-string formatting.
- Use logging instead of print.
Change-Id: I768bc3bb6b2eda57d219ad01be4a8e0a74167d76
Diffstat (limited to 'tests/mlia/test_cli_logging.py')
-rw-r--r-- | tests/mlia/test_cli_logging.py | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/tests/mlia/test_cli_logging.py b/tests/mlia/test_cli_logging.py deleted file mode 100644 index 3f59cb6..0000000 --- a/tests/mlia/test_cli_logging.py +++ /dev/null @@ -1,104 +0,0 @@ -# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates. -# SPDX-License-Identifier: Apache-2.0 -"""Tests for the module cli.logging.""" -import logging -from pathlib import Path -from typing import Optional - -import pytest - -from mlia.cli.logging import setup_logging -from tests.mlia.utils.logging import clear_loggers - - -def teardown_function() -> None: - """Perform action after test completion. - - This function is launched automatically by pytest after each test - in this module. - """ - clear_loggers() - - -@pytest.mark.parametrize( - "logs_dir, verbose, expected_output, expected_log_file_content", - [ - ( - None, - None, - "cli info\n", - None, - ), - ( - None, - True, - """mlia.backend.manager - backends debug -cli info -mlia.cli - cli debug -""", - None, - ), - ( - "logs", - True, - """mlia.backend.manager - backends debug -cli info -mlia.cli - cli debug -""", - """mlia.backend.manager - DEBUG - backends debug -mlia.cli - DEBUG - cli debug -""", - ), - ], -) -def test_setup_logging( - tmp_path: Path, - capfd: pytest.CaptureFixture, - logs_dir: str, - verbose: bool, - expected_output: str, - expected_log_file_content: str, -) -> None: - """Test function setup_logging.""" - logs_dir_path = tmp_path / logs_dir if logs_dir else None - - setup_logging(logs_dir_path, verbose) - - backend_logger = logging.getLogger("mlia.backend.manager") - backend_logger.debug("backends debug") - - cli_logger = logging.getLogger("mlia.cli") - cli_logger.info("cli info") - cli_logger.debug("cli debug") - - stdout, _ = capfd.readouterr() - assert stdout == expected_output - - check_log_assertions(logs_dir_path, expected_log_file_content) - - -def check_log_assertions( - logs_dir_path: Optional[Path], expected_log_file_content: str -) -> None: - """Test assertions for log file.""" - if logs_dir_path is not None: - assert logs_dir_path.is_dir() - - items = list(logs_dir_path.iterdir()) - assert len(items) == 1 - - log_file_path = items[0] - assert log_file_path.is_file() - - log_file_name = log_file_path.name - assert log_file_name == "mlia.log" - - with open(log_file_path, encoding="utf-8") as log_file: - log_content = log_file.read() - - expected_lines = expected_log_file_content.split("\n") - produced_lines = log_content.split("\n") - - assert len(expected_lines) == len(produced_lines) - for expected, produced in zip(expected_lines, produced_lines): - assert expected in produced |