Files
aitbc/tests/archived/test_runner.py
aitbc b71ada9822 feat: reorganize test directory for 100% completion status
 Test Directory Reorganization:
- Created production/ directory for current test suites
- Created archived/ directory for legacy test files
- Created integration/ directory for integration tests
- Updated README.md to reflect 100% completion status
- Added run_production_tests.py for easy test execution

📊 Test Structure Updates:
- production/: 6 core test suites (100% complete)
- archived/: 6 legacy test files (pre-100% completion)
- integration/: 2 integration test files
- Updated documentation and directory structure

🎯 Test Status Reflection:
- JWT Authentication:  Individual tests passing
- Production Monitoring:  Core functionality working
- Type Safety:  Individual tests passing
- Advanced Features:  Individual tests passing
- Complete Integration: ⚠️ Some API compatibility issues

📁 Files Moved:
- 6 production test files → production/
- 6 legacy test files → archived/
- 2 integration test files → integration/

🚀 Test Directory: Organized for 100% project completion
2026-04-02 16:06:46 +02:00

169 lines
6.2 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Simple Test Runner for AITBC
This script provides convenient commands for running tests with the new
pyproject.toml configuration. It's a thin wrapper around pytest that
provides common test patterns and helpful output.
Usage:
python tests/test_runner.py # Run all fast tests
python tests/test_runner.py --all # Run all tests including slow
python tests/test_runner.py --unit # Run unit tests only
python tests/test_runner.py --integration # Run integration tests only
python tests/test_runner.py --cli # Run CLI tests only
python tests/test_runner.py --coverage # Run with coverage
python tests/test_runner.py --performance # Run performance tests
"""
import sys
import subprocess
import argparse
from pathlib import Path
def run_pytest(args, description):
"""Run pytest with given arguments."""
print(f"🧪 {description}")
print("=" * 50)
cmd = ["python", "-m", "pytest"] + args
try:
result = subprocess.run(cmd, cwd=Path(__file__).parent.parent)
return result.returncode
except KeyboardInterrupt:
print("\n❌ Tests interrupted")
return 1
except Exception as e:
print(f"❌ Error running tests: {e}")
return 1
def main():
"""Main test runner."""
parser = argparse.ArgumentParser(
description="AITBC Test Runner - Simple wrapper around pytest",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
python tests/test_runner.py # Run all fast tests
python tests/test_runner.py --all # Run all tests including slow
python tests/test_runner.py --unit # Run unit tests only
python tests/test_runner.py --integration # Run integration tests only
python tests/test_runner.py --cli # Run CLI tests only
python tests/test_runner.py --coverage # Run with coverage
python tests/test_runner.py --performance # Run performance tests
"""
)
# Test selection options
test_group = parser.add_mutually_exclusive_group()
test_group.add_argument("--all", action="store_true", help="Run all tests including slow ones")
test_group.add_argument("--unit", action="store_true", help="Run unit tests only")
test_group.add_argument("--integration", action="store_true", help="Run integration tests only")
test_group.add_argument("--cli", action="store_true", help="Run CLI tests only")
test_group.add_argument("--api", action="store_true", help="Run API tests only")
test_group.add_argument("--blockchain", action="store_true", help="Run blockchain tests only")
test_group.add_argument("--slow", action="store_true", help="Run slow tests only")
test_group.add_argument("--performance", action="store_true", help="Run performance tests only")
test_group.add_argument("--security", action="store_true", help="Run security tests only")
# Additional options
parser.add_argument("--coverage", action="store_true", help="Run with coverage reporting")
parser.add_argument("--verbose", "-v", action="store_true", help="Verbose output")
parser.add_argument("--debug", action="store_true", help="Debug mode (show collection)")
parser.add_argument("--list", "-l", action="store_true", help="List available tests")
parser.add_argument("--markers", action="store_true", help="Show available markers")
# Allow passing through pytest arguments
parser.add_argument("pytest_args", nargs="*", help="Additional pytest arguments")
args = parser.parse_args()
# Build pytest command
pytest_args = []
# Add coverage if requested
if args.coverage:
pytest_args.extend(["--cov=aitbc_cli", "--cov-report=term-missing"])
if args.verbose:
pytest_args.append("--cov-report=html")
# Add verbosity
if args.verbose:
pytest_args.append("-v")
# Add test selection markers
if args.all:
pytest_args.append("-m") # No marker - run all tests
elif args.unit:
pytest_args.extend(["-m", "unit and not slow"])
elif args.integration:
pytest_args.extend(["-m", "integration and not slow"])
elif args.cli:
pytest_args.extend(["-m", "cli and not slow"])
elif args.api:
pytest_args.extend(["-m", "api and not slow"])
elif args.blockchain:
pytest_args.extend(["-m", "blockchain and not slow"])
elif args.slow:
pytest_args.extend(["-m", "slow"])
elif args.performance:
pytest_args.extend(["-m", "performance"])
elif args.security:
pytest_args.extend(["-m", "security"])
else:
# Default: run fast tests only
pytest_args.extend(["-m", "unit or integration or cli or api or blockchain"])
pytest_args.extend(["-m", "not slow"])
# Add debug options
if args.debug:
pytest_args.append("--debug")
# Add list/markers options
if args.list:
pytest_args.append("--collect-only")
elif args.markers:
pytest_args.append("--markers")
# Add additional pytest arguments
if args.pytest_args:
pytest_args.extend(args.pytest_args)
# Special handling for markers/list (don't run tests)
if args.list or args.markers:
return run_pytest(pytest_args, "Listing pytest information")
# Run tests
if args.all:
description = "Running all tests (including slow)"
elif args.unit:
description = "Running unit tests"
elif args.integration:
description = "Running integration tests"
elif args.cli:
description = "Running CLI tests"
elif args.api:
description = "Running API tests"
elif args.blockchain:
description = "Running blockchain tests"
elif args.slow:
description = "Running slow tests"
elif args.performance:
description = "Running performance tests"
elif args.security:
description = "Running security tests"
else:
description = "Running fast tests (unit, integration, CLI, API, blockchain)"
if args.coverage:
description += " with coverage"
return run_pytest(pytest_args, description)
if __name__ == "__main__":
sys.exit(main())