Files
aitbc/cli/tests/test_cli_basic.py
aitbc 40ddf89b9c
Some checks failed
API Endpoint Tests / test-api-endpoints (push) Waiting to run
CLI Tests / test-cli (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
Integration Tests / test-service-integration (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
Documentation Validation / validate-docs (push) Has been cancelled
docs: update CLI command syntax across workflow documentation
- Updated marketplace commands: `marketplace --action` → `market` subcommands
- Updated wallet commands: direct flags → `wallet` subcommands
- Updated AI commands: `ai-submit`, `ai-status` → `ai submit`, `ai status`
- Updated blockchain commands: `chain` → `blockchain info`
- Standardized command structure across all workflow files
- Affected files: MULTI_NODE_MASTER_INDEX.md, TEST_MASTER_INDEX.md, multi-node-blockchain-marketplace
2026-04-08 12:10:21 +02:00

99 lines
2.8 KiB
Python

#!/usr/bin/env python3
"""Basic CLI tests for the unified AITBC command hierarchy."""
import importlib.util
import json
import subprocess
from pathlib import Path
CLI_DIR = Path(__file__).resolve().parent.parent
PROJECT_ROOT = CLI_DIR.parent
CLI_FILE = CLI_DIR / "aitbc_cli.py"
UNIFIED_FILE = CLI_DIR / "unified_cli.py"
CLI_BIN = PROJECT_ROOT / "aitbc-cli"
def run_cli(*args):
return subprocess.run(
[str(CLI_BIN), *args],
capture_output=True,
text=True,
timeout=15,
cwd=str(PROJECT_ROOT),
)
class TestCLIImports:
"""Test direct file-based CLI module imports."""
def test_cli_main_import(self):
spec = importlib.util.spec_from_file_location("aitbc_cli_file", CLI_FILE)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
assert callable(module.main)
def test_unified_cli_import(self):
spec = importlib.util.spec_from_file_location("unified_cli_file", UNIFIED_FILE)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
assert callable(module.run_cli)
class TestCLIBasicFunctionality:
"""Test the visible command tree and core commands."""
def test_cli_help_output(self):
result = run_cli("--help")
assert result.returncode == 0
assert "AITBC CLI" in result.stdout
assert "wallet" in result.stdout
assert "blockchain" in result.stdout
assert "ai" in result.stdout
assert "market" in result.stdout
def test_cli_version_output(self):
result = run_cli("--version")
assert result.returncode == 0
assert "2.1.0" in result.stdout
def test_nested_wallet_list_command(self):
result = run_cli("wallet", "list")
assert result.returncode == 0
def test_legacy_wallet_list_alias(self):
result = run_cli("list")
assert result.returncode == 0
def test_json_output_flag(self):
result = run_cli("--output", "json", "wallet", "list")
assert result.returncode == 0
json.loads(result.stdout or "[]")
class TestCLIErrorHandling:
"""Test CLI error handling."""
def test_cli_invalid_command(self):
result = run_cli("invalid-command")
assert result.returncode != 0
def test_wallet_balance_requires_target(self):
result = run_cli("wallet", "balance")
assert result.returncode != 0
assert "Error: Wallet name is required" in result.stdout
class TestCLIConfiguration:
"""Test CLI file presence and launcher availability."""
def test_cli_files_exist(self):
assert CLI_FILE.exists()
assert UNIFIED_FILE.exists()
assert CLI_BIN.exists()
def test_cli_file_contains_main(self):
content = CLI_FILE.read_text()
assert len(content) > 1000
assert "def main" in content