|
| 1 | +# AutoGen v0.4 Test Suite |
| 2 | + |
| 3 | +This directory contains comprehensive tests for the AutoGen v0.4 integration with PraisonAI. The tests ensure that the new AutoGen v0.4 functionality works correctly while maintaining full backward compatibility with AutoGen v0.2. |
| 4 | + |
| 5 | +## Test Files Overview |
| 6 | + |
| 7 | +### 1. `test_autogen_v4_integration.py` |
| 8 | +**Primary Integration Tests** |
| 9 | +- Tests the core AutoGen v0.4 async execution functionality |
| 10 | +- Verifies proper integration with new v0.4 components: |
| 11 | + - `AutoGenV4AssistantAgent` |
| 12 | + - `OpenAIChatCompletionClient` |
| 13 | + - `RoundRobinGroupChat` |
| 14 | + - `TextMentionTermination` & `MaxMessageTermination` |
| 15 | +- Tests tool integration and agent creation patterns |
| 16 | +- Validates error handling and resource management |
| 17 | + |
| 18 | +### 2. `test_autogen_version_selection.py` |
| 19 | +**Version Selection Logic Tests** |
| 20 | +- Tests the `AUTOGEN_VERSION` environment variable behavior |
| 21 | +- Verifies automatic version preference (v0.4 preferred over v0.2) |
| 22 | +- Tests explicit version selection (`v0.2`, `v0.4`, `auto`) |
| 23 | +- Validates fallback logic when versions are unavailable |
| 24 | +- Tests case-insensitive version string handling |
| 25 | +- Verifies AgentOps tagging for different versions |
| 26 | + |
| 27 | +### 3. `test_autogen_v4_utils.py` |
| 28 | +**Utility Functions Tests** |
| 29 | +- Tests `sanitize_agent_name_for_autogen_v4()` function |
| 30 | +- Validates topic formatting in agent names and descriptions |
| 31 | +- Tests tool filtering for v0.4 (callable `run` methods) |
| 32 | +- Verifies task description construction |
| 33 | +- Tests result message extraction logic |
| 34 | +- Validates model configuration defaults |
| 35 | + |
| 36 | +### 4. `test_autogen_backward_compatibility.py` |
| 37 | +**Backward Compatibility Tests** |
| 38 | +- Ensures existing v0.2 code continues to work unchanged |
| 39 | +- Tests that the same configuration works with both versions |
| 40 | +- Verifies no breaking changes in the API |
| 41 | +- Tests tool compatibility across versions |
| 42 | +- Validates config structure compatibility |
| 43 | +- Tests smooth migration path from v0.2 to v0.4 |
| 44 | + |
| 45 | +### 5. `test_autogen_v4_edge_cases.py` |
| 46 | +**Edge Cases and Error Scenarios** |
| 47 | +- Tests empty configurations and missing fields |
| 48 | +- Validates handling of invalid tool references |
| 49 | +- Tests asyncio runtime error handling |
| 50 | +- Verifies model client and agent creation failures |
| 51 | +- Tests extreme agent names and Unicode characters |
| 52 | +- Validates memory-intensive operations |
| 53 | +- Tests malformed result message handling |
| 54 | + |
| 55 | +## Running the Tests |
| 56 | + |
| 57 | +### Run All AutoGen v0.4 Tests |
| 58 | +```bash |
| 59 | +python tests/run_autogen_v4_tests.py |
| 60 | +``` |
| 61 | + |
| 62 | +### Run Specific Test Categories |
| 63 | +```bash |
| 64 | +# Integration tests |
| 65 | +python tests/run_autogen_v4_tests.py integration |
| 66 | + |
| 67 | +# Version selection tests |
| 68 | +python tests/run_autogen_v4_tests.py version |
| 69 | + |
| 70 | +# Utility function tests |
| 71 | +python tests/run_autogen_v4_tests.py utils |
| 72 | + |
| 73 | +# Backward compatibility tests |
| 74 | +python tests/run_autogen_v4_tests.py compatibility |
| 75 | + |
| 76 | +# Edge case tests |
| 77 | +python tests/run_autogen_v4_tests.py edge_cases |
| 78 | +``` |
| 79 | + |
| 80 | +### Run Individual Test Files |
| 81 | +```bash |
| 82 | +# Run specific test file |
| 83 | +pytest tests/unit/test_autogen_v4_integration.py -v |
| 84 | + |
| 85 | +# Run specific test method |
| 86 | +pytest tests/unit/test_autogen_v4_integration.py::TestAutoGenV4Integration::test_version_detection_auto_prefers_v4 -v |
| 87 | +``` |
| 88 | + |
| 89 | +## Test Coverage |
| 90 | + |
| 91 | +The test suite covers: |
| 92 | + |
| 93 | +### ✅ **Core Functionality** |
| 94 | +- [x] AutoGen v0.4 async execution pattern |
| 95 | +- [x] Agent creation with v0.4 components |
| 96 | +- [x] Tool integration (callable `run` methods) |
| 97 | +- [x] Group chat creation and execution |
| 98 | +- [x] Termination conditions (text + max messages) |
| 99 | +- [x] Model client configuration and resource management |
| 100 | + |
| 101 | +### ✅ **Version Management** |
| 102 | +- [x] Environment variable handling (`AUTOGEN_VERSION`) |
| 103 | +- [x] Automatic version detection and preference |
| 104 | +- [x] Explicit version selection |
| 105 | +- [x] Fallback logic for missing versions |
| 106 | +- [x] Import error handling |
| 107 | +- [x] AgentOps integration and tagging |
| 108 | + |
| 109 | +### ✅ **Backward Compatibility** |
| 110 | +- [x] Existing v0.2 code continues working |
| 111 | +- [x] Same configuration works with both versions |
| 112 | +- [x] No breaking API changes |
| 113 | +- [x] Tool compatibility across versions |
| 114 | +- [x] Smooth migration path |
| 115 | + |
| 116 | +### ✅ **Error Handling** |
| 117 | +- [x] AsyncIO runtime errors |
| 118 | +- [x] Model client creation failures |
| 119 | +- [x] Agent creation failures |
| 120 | +- [x] Group chat execution failures |
| 121 | +- [x] Resource cleanup on errors |
| 122 | +- [x] Malformed configuration handling |
| 123 | + |
| 124 | +### ✅ **Edge Cases** |
| 125 | +- [x] Empty configurations |
| 126 | +- [x] Missing configuration fields |
| 127 | +- [x] Invalid tool references |
| 128 | +- [x] Extreme agent names |
| 129 | +- [x] Unicode character handling |
| 130 | +- [x] Memory-intensive operations |
| 131 | +- [x] Large configuration files |
| 132 | + |
| 133 | +## Mock Strategy |
| 134 | + |
| 135 | +The tests use comprehensive mocking to: |
| 136 | +- **Mock AutoGen Dependencies**: Tests work regardless of which AutoGen versions are installed |
| 137 | +- **Mock Async Components**: Proper async/await testing with `AsyncMock` |
| 138 | +- **Mock External APIs**: No real API calls during testing |
| 139 | +- **Mock File System**: No real file I/O during tests |
| 140 | +- **Isolated Testing**: Each test is independent and doesn't affect others |
| 141 | + |
| 142 | +## Test Environment |
| 143 | + |
| 144 | +The tests are designed to: |
| 145 | +- Run in CI/CD environments without AutoGen installed |
| 146 | +- Work with or without actual AutoGen v0.2/v0.4 dependencies |
| 147 | +- Provide comprehensive coverage of all code paths |
| 148 | +- Execute quickly with minimal external dependencies |
| 149 | +- Generate clear, actionable error messages |
| 150 | + |
| 151 | +## Integration with Existing Test Suite |
| 152 | + |
| 153 | +These tests integrate seamlessly with the existing PraisonAI test suite: |
| 154 | +- Follow the same testing patterns and conventions |
| 155 | +- Use the same fixtures and utilities from `conftest.py` |
| 156 | +- Compatible with the existing test runner infrastructure |
| 157 | +- Maintain consistent error handling and logging |
| 158 | + |
| 159 | +## Dependencies |
| 160 | + |
| 161 | +The test suite requires: |
| 162 | +- `pytest` (testing framework) |
| 163 | +- `unittest.mock` (mocking capabilities) |
| 164 | +- Standard Python library modules |
| 165 | + |
| 166 | +No actual AutoGen dependencies are required to run the tests. |
| 167 | + |
| 168 | +## Contributing |
| 169 | + |
| 170 | +When adding new AutoGen v0.4 functionality: |
| 171 | +1. Add corresponding tests to the appropriate test file |
| 172 | +2. Ensure both happy path and error scenarios are tested |
| 173 | +3. Verify backward compatibility is maintained |
| 174 | +4. Update this README if new test categories are added |
| 175 | +5. Run the full test suite to ensure no regressions |
| 176 | + |
| 177 | +## Test Results |
| 178 | + |
| 179 | +The test suite provides: |
| 180 | +- **Comprehensive Coverage**: All AutoGen v0.4 functionality is tested |
| 181 | +- **Clear Reporting**: Detailed test results and failure information |
| 182 | +- **Fast Execution**: Tests complete in under 1 minute |
| 183 | +- **Reliable Results**: Tests are deterministic and reproducible |
| 184 | +- **Easy Debugging**: Clear error messages and test isolation |
0 commit comments