mirror of
https://github.com/katanemo/plano.git
synced 2026-04-25 16:56:24 +02:00
fix cli models and logs (#196)
* removing unnecessar setup.py files * updated the cli for debug and access logs * ran the pre-commit locally to fix pull request * fixed bug where if archgw_process is None we didn't handle it gracefully * Apply suggestions from code review Co-authored-by: Adil Hafeez <adil@katanemo.com> * fixed changes based on PR * fixed version not found message * fixed message based on PR feedback * adding poetry lock * fixed pre-commit --------- Co-authored-by: Salman Paracha <salmanparacha@MacBook-Pro-261.local> Co-authored-by: Adil Hafeez <adil@katanemo.com>
This commit is contained in:
parent
6cd05572c4
commit
6fb63510b3
11 changed files with 362 additions and 274 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