mirror of
https://github.com/katanemo/plano.git
synced 2026-06-23 15:38:07 +02:00
wip
Signed-off-by: José Ulises Niño Rivera <junr03@users.noreply.github.com>
This commit is contained in:
parent
6cd05572c4
commit
e61e78242c
23 changed files with 2708 additions and 440 deletions
42
arch/tools/test/test_cli.py
Normal file
42
arch/tools/test/test_cli.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import pytest
|
||||
from click.testing import CliRunner
|
||||
from tools.cli.main import main # Import your CLI's entry point
|
||||
import importlib.metadata
|
||||
|
||||
|
||||
def get_version():
|
||||
"""Helper function to fetch the version."""
|
||||
try:
|
||||
version = importlib.metadata.version("archgw")
|
||||
return version
|
||||
except importlib.metadata.PackageNotFoundError:
|
||||
return None
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def runner():
|
||||
"""Fixture to create a Click test runner."""
|
||||
return CliRunner()
|
||||
|
||||
|
||||
def test_version_option(runner):
|
||||
"""Test the --version option."""
|
||||
result = runner.invoke(main, ["--version"])
|
||||
assert result.exit_code == 0
|
||||
expected_version = get_version()
|
||||
assert f"archgw cli version: {expected_version}" in result.output
|
||||
|
||||
|
||||
def test_default_behavior(runner):
|
||||
"""Test the default behavior when no command is provided."""
|
||||
result = runner.invoke(main)
|
||||
assert result.exit_code == 0
|
||||
assert "Arch (The Intelligent Prompt Gateway) CLI" in result.output
|
||||
assert "Usage:" in result.output # Ensure help text is shown
|
||||
|
||||
|
||||
def test_invalid_command(runner):
|
||||
"""Test that an invalid command returns an appropriate error message."""
|
||||
result = runner.invoke(main, ["invalid_command"])
|
||||
assert result.exit_code != 0 # Non-zero exit code for invalid command
|
||||
assert "Error: No such command 'invalid_command'" in result.output
|
||||
Loading…
Add table
Add a link
Reference in a new issue