91 lines
No EOL
2.3 KiB
Python
91 lines
No EOL
2.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script to demonstrate cost tracking functionality
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
def run_cost_tracking_test():
|
|
"""Run a test with cost tracking enabled"""
|
|
print("Testing cost tracking with hybrid mode...")
|
|
print("=" * 60)
|
|
|
|
# Test command with cost tracking enabled
|
|
cmd = [
|
|
sys.executable, "cli.py",
|
|
"--test",
|
|
"--hybrid",
|
|
"--enable-cost-tracking",
|
|
"--cost-report"
|
|
]
|
|
|
|
print(f"Running command: {' '.join(cmd)}")
|
|
print("-" * 60)
|
|
|
|
try:
|
|
result = subprocess.run(cmd, capture_output=True, text=True, cwd=Path(__file__).parent)
|
|
|
|
print("STDOUT:")
|
|
print(result.stdout)
|
|
|
|
if result.stderr:
|
|
print("\nSTDERR:")
|
|
print(result.stderr)
|
|
|
|
print(f"\nReturn code: {result.returncode}")
|
|
|
|
# Check if cost report was generated
|
|
cost_reports = list(Path("results").glob("cost_report_*.json"))
|
|
if cost_reports:
|
|
print(f"\n✅ Cost report generated: {cost_reports[-1]}")
|
|
else:
|
|
print("\n❌ No cost report found")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Error running test: {e}")
|
|
|
|
def run_without_cost_tracking():
|
|
"""Run a test without cost tracking for comparison"""
|
|
print("\nTesting without cost tracking...")
|
|
print("=" * 60)
|
|
|
|
# Test command without cost tracking
|
|
cmd = [
|
|
sys.executable, "cli.py",
|
|
"--test",
|
|
"--hybrid"
|
|
]
|
|
|
|
print(f"Running command: {' '.join(cmd)}")
|
|
print("-" * 60)
|
|
|
|
try:
|
|
result = subprocess.run(cmd, capture_output=True, text=True, cwd=Path(__file__).parent)
|
|
|
|
print("STDOUT:")
|
|
print(result.stdout)
|
|
|
|
if result.stderr:
|
|
print("\nSTDERR:")
|
|
print(result.stderr)
|
|
|
|
print(f"\nReturn code: {result.returncode}")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Error running test: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
print("Cost Tracking Integration Test")
|
|
print("=" * 60)
|
|
|
|
# Test 1: With cost tracking
|
|
run_cost_tracking_test()
|
|
|
|
# Test 2: Without cost tracking
|
|
run_without_cost_tracking()
|
|
|
|
print("\n" + "=" * 60)
|
|
print("Integration test completed!")
|
|
print("=" * 60) |