|
| 1 | +# Test Suite Refactoring Issue |
| 2 | + |
| 3 | +## Overview |
| 4 | +The current test suite has significant issues that prevent tests from running properly. Out of 27 test files with 226 tests collected, there are 8 import errors preventing test execution. Additionally, there are major gaps in test coverage and outdated test implementations. |
| 5 | + |
| 6 | +## Critical Issues Found |
| 7 | + |
| 8 | +### 1. Import Errors (8 files affected) |
| 9 | +- Tests are importing non-existent classes/functions: |
| 10 | + - `RealtimeClient` should be `ProjectXRealtimeClient` |
| 11 | + - `ProjectXConfigError` doesn't exist in exceptions.py |
| 12 | + - Multiple tests using outdated async class names |
| 13 | + |
| 14 | +### 2. Outdated Test References |
| 15 | +- 9 test files still reference old async classes: |
| 16 | + - `AsyncProjectX` (now `ProjectX`) |
| 17 | + - `AsyncOrderManager` (now `OrderManager`) |
| 18 | + - `AsyncPositionManager` (now `PositionManager`) |
| 19 | + - `create_async_trading_suite` (now `create_trading_suite`) |
| 20 | + |
| 21 | +### 3. Missing Test Coverage |
| 22 | +Critical components with no test coverage: |
| 23 | +- **Indicators module** (9 modules, 0 tests) |
| 24 | + - momentum indicators |
| 25 | + - overlap indicators |
| 26 | + - volatility indicators |
| 27 | + - volume indicators |
| 28 | + - base classes |
| 29 | +- **Client module components** (refactored into submodules) |
| 30 | +- **Realtime module components** (refactored into submodules) |
| 31 | +- **Utils module components** (refactored into submodules) |
| 32 | + |
| 33 | +### 4. Duplicate and Redundant Tests |
| 34 | +- Multiple versions of same tests (async and sync) |
| 35 | +- Test files for both old and new implementations |
| 36 | +- Comprehensive test files that duplicate basic test files |
| 37 | + |
| 38 | +## Specific Files Requiring Fixes |
| 39 | + |
| 40 | +### Files with Import Errors: |
| 41 | +1. `test_async_order_manager_comprehensive.py` - RealtimeClient import |
| 42 | +2. `test_async_realtime.py` - RealtimeClient import |
| 43 | +3. `test_config.py` - ProjectXConfigError import |
| 44 | +4. `test_async_integration_comprehensive.py` - RealtimeClient import |
| 45 | +5. `test_async_orderbook.py` - RealtimeClient import |
| 46 | +6. `test_async_realtime_data_manager.py` - RealtimeClient import |
| 47 | +7. `test_integration.py` - RealtimeClient import |
| 48 | +8. `test_order_manager_init.py` - RealtimeClient import |
| 49 | +9. `test_position_manager_init.py` - RealtimeClient import |
| 50 | + |
| 51 | +### Files with Outdated References: |
| 52 | +All async test files need updating to use new non-async class names. |
| 53 | + |
| 54 | +## Proposed Action Plan |
| 55 | + |
| 56 | +### Phase 1: Fix Import Errors |
| 57 | +1. Update all `RealtimeClient` imports to `ProjectXRealtimeClient` |
| 58 | +2. Remove or fix `ProjectXConfigError` references |
| 59 | +3. Update all async class imports to new names |
| 60 | + |
| 61 | +### Phase 2: Remove Redundant Tests |
| 62 | +1. Consolidate duplicate async/sync test files |
| 63 | +2. Remove tests for deprecated functionality |
| 64 | +3. Merge comprehensive test files with basic ones |
| 65 | + |
| 66 | +### Phase 3: Add Missing Test Coverage |
| 67 | +1. Create test suite for indicators module: |
| 68 | + - Test each indicator category |
| 69 | + - Test class-based and function interfaces |
| 70 | + - Test Polars DataFrame operations |
| 71 | +2. Add tests for refactored modules: |
| 72 | + - Client submodules |
| 73 | + - Realtime submodules |
| 74 | + - Utils submodules |
| 75 | + |
| 76 | +### Phase 4: Modernize Test Structure |
| 77 | +1. Use pytest fixtures consistently |
| 78 | +2. Add proper mocking for external API calls |
| 79 | +3. Implement test markers properly (unit, integration, slow) |
| 80 | +4. Add async test support where needed |
| 81 | + |
| 82 | +### Phase 5: Test Organization |
| 83 | +1. Restructure tests to mirror source code structure: |
| 84 | + ``` |
| 85 | + tests/ |
| 86 | + ├── unit/ |
| 87 | + │ ├── client/ |
| 88 | + │ ├── indicators/ |
| 89 | + │ ├── order_manager/ |
| 90 | + │ ├── position_manager/ |
| 91 | + │ └── utils/ |
| 92 | + ├── integration/ |
| 93 | + └── conftest.py |
| 94 | + ``` |
| 95 | + |
| 96 | +## Success Criteria |
| 97 | +- [ ] All tests can be collected without import errors |
| 98 | +- [ ] Test coverage > 80% for all modules |
| 99 | +- [ ] No duplicate or redundant tests |
| 100 | +- [ ] Clear separation between unit and integration tests |
| 101 | +- [ ] All tests pass in CI/CD pipeline |
| 102 | +- [ ] Tests follow modern pytest patterns |
| 103 | + |
| 104 | +## Priority |
| 105 | +**High** - The test suite is currently broken and preventing proper validation of code changes. |
| 106 | + |
| 107 | +## Labels |
| 108 | +- bug |
| 109 | +- testing |
| 110 | +- refactoring |
| 111 | +- technical-debt |
0 commit comments