diff options
author | Diego Russo <diego.russo@arm.com> | 2022-05-30 13:34:14 +0100 |
---|---|---|
committer | Diego Russo <diego.russo@arm.com> | 2022-05-30 13:34:14 +0100 |
commit | 0efca3cadbad5517a59884576ddb90cfe7ac30f8 (patch) | |
tree | abed6cb6fbf3c439fc8d947f505b6a53d5daeb1e /tests/aiet/test_cli.py | |
parent | 0777092695c143c3a54680b5748287d40c914c35 (diff) | |
download | mlia-0efca3cadbad5517a59884576ddb90cfe7ac30f8.tar.gz |
Add MLIA codebase0.3.0-rc.1
Add MLIA codebase including sources and tests.
Change-Id: Id41707559bd721edd114793618d12ccd188d8dbd
Diffstat (limited to 'tests/aiet/test_cli.py')
-rw-r--r-- | tests/aiet/test_cli.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/aiet/test_cli.py b/tests/aiet/test_cli.py new file mode 100644 index 0000000..e8589fa --- /dev/null +++ b/tests/aiet/test_cli.py @@ -0,0 +1,37 @@ +# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates. +# SPDX-License-Identifier: Apache-2.0 +"""Module for testing CLI top command.""" +from typing import Any +from unittest.mock import ANY +from unittest.mock import MagicMock + +from click.testing import CliRunner + +from aiet.cli import cli + + +def test_cli(cli_runner: CliRunner) -> None: + """Test CLI top level command.""" + result = cli_runner.invoke(cli) + assert result.exit_code == 0 + assert "system" in cli.commands + assert "application" in cli.commands + + +def test_cli_version(cli_runner: CliRunner) -> None: + """Test version option.""" + result = cli_runner.invoke(cli, ["--version"]) + assert result.exit_code == 0 + assert "version" in result.output + + +def test_cli_verbose(cli_runner: CliRunner, monkeypatch: Any) -> None: + """Test verbose option.""" + with monkeypatch.context() as mock_context: + mock = MagicMock() + # params[1] is the verbose option and we need to replace the + # callback with a mock object + mock_context.setattr(cli.params[1], "callback", mock) + cli_runner.invoke(cli, ["-vvvv"]) + # 4 is the number -v called earlier + mock.assert_called_once_with(ANY, ANY, 4) |