Files
aitbc/cli/tests/test_cli_comprehensive.py
aitbc 852f2e5a8a
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Documentation Validation / validate-docs (push) Has been cancelled
Documentation Validation / validate-policies-strict (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Node Failover Simulation / failover-test (push) Has been cancelled
Integration Tests / test-service-integration (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
CLI Tests / test-cli (push) Has been cancelled
Blockchain Synchronization Verification / sync-verification (push) Successful in 11s
Contract Performance Benchmarks / benchmark-gas-usage (push) Successful in 1m36s
Contract Performance Benchmarks / benchmark-execution-time (push) Successful in 1m24s
Contract Performance Benchmarks / benchmark-throughput (push) Successful in 1m25s
Cross-Chain Functionality Tests / test-cross-chain-sync (push) Successful in 2s
Cross-Chain Functionality Tests / test-cross-chain-transactions (push) Successful in 5s
Cross-Chain Functionality Tests / test-cross-chain-bridge (push) Has been skipped
Cross-Chain Functionality Tests / test-multi-chain-consensus (push) Successful in 3s
Cross-Chain Functionality Tests / aggregate-results (push) Has been skipped
Multi-Chain Island Architecture Tests / test-multi-chain-island (push) Successful in 2s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 3s
P2P Network Verification / p2p-verification (push) Successful in 2s
Smart Contract Tests / test-solidity (map[name:aitbc-contracts path:contracts]) (push) Failing after 1m28s
Smart Contract Tests / test-solidity (map[name:aitbc-token path:packages/solidity/aitbc-token]) (push) Successful in 21s
Smart Contract Tests / test-foundry (push) Failing after 20s
Smart Contract Tests / lint-solidity (push) Successful in 30s
Smart Contract Tests / deploy-contracts (push) Successful in 1m40s
Systemd Sync / sync-systemd (push) Successful in 26s
Contract Performance Benchmarks / compare-benchmarks (push) Successful in 4s
Rename openclaw to hermes across documentation and workflows
- Update workflow paths from docs/openclaw to docs/hermes
- Rename skill prefixes from openclaw-* to hermes-*
- Update agent skill references in refactoring and analysis docs
- Rename OPENCLAW_AITBC_MASTERY_PLAN.md to reflect hermes branding
- Update CLI examples and command references throughout documentation
2026-05-07 11:42:06 +02:00

208 lines
6.5 KiB
Python

#!/usr/bin/env python3
"""Comprehensive tests for the unified AITBC CLI hierarchy."""
import subprocess
import time
from pathlib import Path
PROJECT_ROOT = Path("/opt/aitbc")
CLI_BIN = PROJECT_ROOT / "aitbc-cli"
def run_cli(*args):
return subprocess.run(
[str(CLI_BIN), *args],
capture_output=True,
text=True,
cwd=str(PROJECT_ROOT),
timeout=20,
)
class TestSimulateCommand:
"""Test the nested simulate command family."""
def test_simulate_help(self):
result = run_cli("simulate", "--help")
assert result.returncode == 0
assert "blockchain" in result.stdout
assert "wallets" in result.stdout
assert "price" in result.stdout
assert "network" in result.stdout
assert "ai-jobs" in result.stdout
def test_simulate_blockchain_basic(self):
result = run_cli("simulate", "blockchain", "--blocks", "2", "--transactions", "3", "--delay", "0")
assert result.returncode == 0
assert "Block 1:" in result.stdout
assert "Total Blocks: 2" in result.stdout
class TestBlockchainCommand:
"""Test nested blockchain commands and legacy chain alias."""
def test_blockchain_help(self):
result = run_cli("blockchain", "info", "--help")
assert result.returncode == 0
assert "--rpc-url" in result.stdout
def test_chain_alias_help(self):
result = run_cli("chain", "--help")
assert result.returncode == 0
assert "blockchain info" in result.stdout
assert "--rpc-url" in result.stdout
class TestNetworkCommand:
"""Test network subcommands and backward-compatible argument forms."""
def test_network_ping_positional_node(self):
result = run_cli("network", "ping", "localhost")
assert result.returncode == 0
assert "Ping: Node localhost" in result.stdout
def test_network_ping_flag_alias(self):
result = run_cli("network", "ping", "--node", "localhost")
assert result.returncode == 0
assert "Ping: Node localhost" in result.stdout
def test_network_propagate_flag_alias(self):
result = run_cli("network", "propagate", "--data", "smoke-test")
assert result.returncode == 0
assert "Data propagation: Complete" in result.stdout
assert "smoke-test" in result.stdout
class TestMarketplaceCommand:
"""Test marketplace grouping and legacy rewrite."""
def test_market_help(self):
result = run_cli("market", "--help")
assert result.returncode == 0
assert "list" in result.stdout
assert "create" in result.stdout
assert "search" in result.stdout
assert "my-listings" in result.stdout
def test_marketplace_legacy_alias(self):
result = run_cli("marketplace", "--action", "list")
assert result.returncode == 0
assert "Marketplace list:" in result.stdout
class TestAIOperationsCommand:
"""Test the unified ai command family and legacy ai-ops rewrite."""
def test_ai_help(self):
result = run_cli("ai", "--help")
assert result.returncode == 0
assert "submit" in result.stdout
assert "status" in result.stdout
assert "results" in result.stdout
def test_ai_ops_legacy_status(self):
result = run_cli("ai-ops", "--action", "status")
assert result.returncode == 0
assert "AI status:" in result.stdout
class TestResourceCommand:
"""Test resource subcommands."""
def test_resource_help(self):
result = run_cli("resource", "--help")
assert result.returncode == 0
assert "status" in result.stdout
assert "allocate" in result.stdout
def test_resource_status(self):
result = run_cli("resource", "status")
assert result.returncode == 0
assert "Resource status:" in result.stdout
class TestIntegrationScenarios:
"""Test representative end-to-end command patterns."""
def test_cli_version(self):
result = run_cli("--version")
assert result.returncode == 0
assert "2.1.0" in result.stdout
def test_cli_help_comprehensive(self):
result = run_cli("--help")
assert result.returncode == 0
for command in ["wallet", "blockchain", "network", "market", "ai", "mining", "agent", "hermes", "workflow", "resource", "simulate"]:
assert command in result.stdout
def test_wallet_alias_and_nested_forms(self):
nested = run_cli("wallet", "list")
alias = run_cli("list")
assert nested.returncode == 0
assert alias.returncode == 0
def test_network_default_and_nested_forms(self):
default = run_cli("network")
nested = run_cli("network", "status")
assert default.returncode == 0
assert nested.returncode == 0
assert "Network status:" in default.stdout
assert "Network status:" in nested.stdout
def test_ai_submit_legacy_alias(self):
result = run_cli("ai-submit", "--wallet", "test", "--type", "test", "--prompt", "hello", "--payment", "1")
assert result.returncode == 0
assert "AI submit:" in result.stdout
class TestErrorHandling:
"""Test error handling scenarios."""
def test_invalid_command(self):
result = run_cli("invalid-command")
assert result.returncode != 0
def test_missing_required_args(self):
result = run_cli("wallet", "send")
assert result.returncode != 0
def test_invalid_option_values(self):
result = run_cli("--output", "invalid")
assert result.returncode != 0
class TestPerformance:
"""Test performance characteristics."""
def test_help_response_time(self):
start_time = time.time()
result = run_cli("--help")
end_time = time.time()
assert result.returncode == 0
assert (end_time - start_time) < 5.0
def test_command_startup_time(self):
start_time = time.time()
result = run_cli("wallet", "list")
end_time = time.time()
assert result.returncode == 0
assert (end_time - start_time) < 10.0
class TestConfiguration:
"""Test global flags across the new command tree."""
def test_different_output_formats(self):
for fmt in ["table", "json", "yaml"]:
result = run_cli("--output", fmt, "wallet", "list")
assert result.returncode == 0
def test_verbose_mode(self):
result = run_cli("--verbose", "wallet", "list")
assert result.returncode == 0
def test_debug_mode(self):
result = run_cli("--debug", "wallet", "list")
assert result.returncode == 0