From 1cd1a6436f87869cdd27d4cc458e07707734d0d5 Mon Sep 17 00:00:00 2001 From: Thomas Grimonet Date: Wed, 11 Dec 2024 20:23:21 +0100 Subject: [PATCH] test: Add basic unit tests for cli --- tests/unit/cli/test_cli.py | 24 ++++++++++++++++++++++++ tests/unit/cli/test_debug.py | 13 +++++++++++++ tests/unit/cli/test_get.py | 13 +++++++++++++ tests/unit/cli/test_info.py | 13 +++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 tests/unit/cli/test_cli.py create mode 100644 tests/unit/cli/test_debug.py create mode 100644 tests/unit/cli/test_get.py create mode 100644 tests/unit/cli/test_info.py diff --git a/tests/unit/cli/test_cli.py b/tests/unit/cli/test_cli.py new file mode 100644 index 0000000..05d8c80 --- /dev/null +++ b/tests/unit/cli/test_cli.py @@ -0,0 +1,24 @@ +import pytest +from click.testing import CliRunner +from eos_downloader.cli.cli import ardl + +@pytest.fixture +def runner(): + return CliRunner() + +def test_ardl_help(runner): + result = runner.invoke(ardl, ['--help']) + assert result.exit_code == 0 + assert "Arista Network Download CLI" in result.output + +def test_ardl_version(runner): + result = runner.invoke(ardl, ['--version']) + assert result.exit_code == 0 + assert "version" in result.output + +def test_cli_execution(runner): + result = runner.invoke(ardl, []) + assert result.exit_code == 0 + assert "Usage: ardl [OPTIONS] COMMAND [ARGS]..." in result.output + assert "Arista Network Download CLI" in result.output + diff --git a/tests/unit/cli/test_debug.py b/tests/unit/cli/test_debug.py new file mode 100644 index 0000000..8e977e3 --- /dev/null +++ b/tests/unit/cli/test_debug.py @@ -0,0 +1,13 @@ + +import pytest +from click.testing import CliRunner +from eos_downloader.cli.cli import ardl + +@pytest.fixture +def runner(): + return CliRunner() + +def test_debug_help(runner): + result = runner.invoke(ardl, ['debug', '--help']) + assert result.exit_code == 0 + assert "Debug commands to work with ardl" in result.output \ No newline at end of file diff --git a/tests/unit/cli/test_get.py b/tests/unit/cli/test_get.py new file mode 100644 index 0000000..554497f --- /dev/null +++ b/tests/unit/cli/test_get.py @@ -0,0 +1,13 @@ + +import pytest +from click.testing import CliRunner +from eos_downloader.cli.cli import ardl + +@pytest.fixture +def runner(): + return CliRunner() + +def test_get_help(runner): + result = runner.invoke(ardl, ['get', '--help']) + assert result.exit_code == 0 + assert "Download Arista from Arista website" in result.output \ No newline at end of file diff --git a/tests/unit/cli/test_info.py b/tests/unit/cli/test_info.py new file mode 100644 index 0000000..e6c48f3 --- /dev/null +++ b/tests/unit/cli/test_info.py @@ -0,0 +1,13 @@ + +import pytest +from click.testing import CliRunner +from eos_downloader.cli.cli import ardl + +@pytest.fixture +def runner(): + return CliRunner() + +def test_info_help(runner): + result = runner.invoke(ardl, ['info', '--help']) + assert result.exit_code == 0 + assert "List information from Arista website" in result.output \ No newline at end of file