# Step 02: Complete Message Formatter Coverage

## Status Reference
- **Current Status**: Pending
- **Dependency**: Step 01 must be complete
- **Target Module**: `storm_logger/core/formatters/message_formatter.py`
- **Current Coverage**: ~40% (after Step 01)
- **Target Coverage**: 100%

## Objectives
1. Identify all uncovered lines in message_formatter.py
2. Create targeted tests for each uncovered method/branch
3. Achieve 100% coverage for this critical module
4. Ensure all edge cases are tested

## Coverage Gap Analysis

### Methods Needing Additional Tests
Based on the coverage report, these methods have low/no coverage:

#### 1. Format Methods (lines 178-234)
- `_format_performance_message`
- `_format_security_message`
- `_format_business_critical_message`
- `_format_ux_message`
- `_format_integration_message`
- `_format_for_stakeholder`
- `_format_metric_from_message`

#### 2. Utility Methods (lines 252-324)
- `format_test_message` - edge cases
- `format_metric_message` - complex scenarios
- `_extract_business_context` - all branches

#### 3. Specialized Formatters (lines 342-427)
- `format_django_spellbook_tip` - all variations
- `format_midas_optimization` - all patterns
- `format_business_recommendation` - all contexts

#### 4. Pattern Methods (lines 455-524)
- `_apply_technology_transformations`
- `_apply_custom_patterns`
- `_apply_context_formatting`

#### 5. Error Handling (lines 567-636)
- Exception scenarios
- Fallback behaviors
- Edge cases with None/empty inputs

## Test Creation Plan

### Phase 1: Core Formatting Tests
```python
# Tests to create:
- test_format_with_all_message_types
- test_format_edge_cases
- test_format_with_complex_context
- test_format_performance_all_scenarios
- test_format_security_all_patterns
```

### Phase 2: Business Logic Tests
```python
# Tests to create:
- test_business_critical_all_indicators
- test_ux_message_all_patterns
- test_integration_message_complete
- test_stakeholder_formatting_all_types
- test_metric_extraction_complex
```

### Phase 3: Pattern and Transformation Tests
```python
# Tests to create:
- test_technology_transformations_complete
- test_custom_patterns_advanced
- test_context_formatting_all_components
- test_business_impact_all_scenarios
```

### Phase 4: Edge Cases and Error Handling
```python
# Tests to create:
- test_none_empty_inputs_all_methods
- test_exception_handling
- test_fallback_behaviors
- test_malformed_inputs
- test_unicode_special_characters
```

## Implementation Strategy

### 1. Coverage-Driven Development
- Run coverage after each test addition
- Target specific uncovered lines
- Use branch coverage to find missing paths

### 2. Systematic Approach
- Test one method completely before moving to next
- Document covered lines in comments
- Track progress in status.json

### 3. Quality Assurance
- Each test should be meaningful, not just for coverage
- Test business logic, not just code execution
- Include negative test cases

## Success Criteria
- 100% line coverage for message_formatter.py
- 100% branch coverage for critical methods
- All tests passing without warnings
- No test duplication or redundancy

## Next Steps
1. Run coverage report to identify exact uncovered lines
2. Create test file: `test_message_formatter_complete.py`
3. Implement tests method by method
4. Update status.json with progress
5. Move to Step 03 once 100% coverage achieved

## Automation Notes
- Use coverage.py to track progress programmatically
- Create helper functions to avoid test duplication
- Use parameterized tests where appropriate
- Commit after each major method is fully covered