mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-01 17:17:24 -04:00
Major improvements: - Fixed all 42 broken tests (database connection leaks) - Added db_connection() context manager for proper cleanup - Created comprehensive test suites for undertested modules New test coverage: - tools/general_tools.py: 26 tests (97% coverage) - tools/price_tools.py: 11 tests (validates NASDAQ symbols, date handling) - api/price_data_manager.py: 12 tests (85% coverage) - api/routes/results_v2.py: 3 tests (98% coverage) - agent/reasoning_summarizer.py: 2 tests (87% coverage) - api/routes/period_metrics.py: 2 edge case tests (100% coverage) - agent/mock_provider: 1 test (100% coverage) Database fixes: - Added db_connection() context manager to prevent leaks - Updated 16+ test files to use context managers - Fixed drop_all_tables() to match new schema - Added CHECK constraint for action_type - Added ON DELETE CASCADE to trading_days foreign key Test improvements: - Updated SQL INSERT statements with all required fields - Fixed date parameter handling in API integration tests - Added edge case tests for validation functions - Fixed import errors across test suite Results: - Total coverage: 84.81% (was 61%) - Tests passing: 406 (was 364 with 42 failures) - Total lines covered: 6364 of 7504 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
AI-Trader Scripts
This directory contains standardized scripts for testing, validation, and operations.
Testing Scripts
Interactive Testing
test.sh - Interactive test menu
bash scripts/test.sh
User-friendly menu for all testing operations. Best for local development.
Development Testing
quick_test.sh - Fast unit test feedback
bash scripts/quick_test.sh
- Runs unit tests only
- No coverage
- Fails fast
- ~10-30 seconds
run_tests.sh - Full test suite
bash scripts/run_tests.sh [OPTIONS]
- All test types (unit, integration, e2e)
- Coverage reporting
- Parallel execution support
- Highly configurable
coverage_report.sh - Coverage analysis
bash scripts/coverage_report.sh [OPTIONS]
- Generate HTML/JSON/terminal reports
- Check coverage thresholds
- Open reports in browser
CI/CD Testing
ci_test.sh - CI-optimized testing
bash scripts/ci_test.sh [OPTIONS]
- JUnit XML output
- Coverage XML for CI tools
- Environment variable configuration
- Excludes Docker tests
Validation Scripts
validate_docker_build.sh - Docker build validation
bash scripts/validate_docker_build.sh
Validates Docker setup, build, and container startup.
test_api_endpoints.sh - API endpoint testing
bash scripts/test_api_endpoints.sh
Tests all REST API endpoints with real simulations.
Other Scripts
migrate_price_data.py - Data migration utility
python scripts/migrate_price_data.py
Migrates price data between formats.
Quick Reference
| Task | Script | Command |
|---|---|---|
| Quick test | quick_test.sh |
bash scripts/quick_test.sh |
| Full test | run_tests.sh |
bash scripts/run_tests.sh |
| Coverage | coverage_report.sh |
bash scripts/coverage_report.sh -o |
| CI test | ci_test.sh |
bash scripts/ci_test.sh -f |
| Interactive | test.sh |
bash scripts/test.sh |
| Docker validation | validate_docker_build.sh |
bash scripts/validate_docker_build.sh |
| API testing | test_api_endpoints.sh |
bash scripts/test_api_endpoints.sh |
Common Options
Most test scripts support:
-h, --help- Show help-v, --verbose- Verbose output-f, --fail-fast- Stop on first failure-t, --type TYPE- Test type (unit, integration, e2e, all)-m, --markers MARKERS- Pytest markers-p, --parallel- Parallel execution
Documentation
For detailed usage, see:
Making Scripts Executable
If scripts are not executable:
chmod +x scripts/*.sh