plexus.test_prediction_commands module
Comprehensive tests for PredictionCommands.py - the mission-critical scoring system.
This test suite focuses on the most critical aspects of the prediction pipeline: - Score.Input creation and text/metadata preparation - Prediction orchestration and error handling - Parallel processing coordination - Integration with scorecard registry - Cost tracking and resource cleanup
The prediction system is the core of Plexus scoring and handles: 1. Input text and metadata preparation for predictions 2. Async prediction orchestration with proper cleanup 3. Multi-score parallel processing 4. Error propagation and recovery 5. Progress tracking and feedback integration
- class plexus.test_prediction_commands.MockScore(name='test_score', costs=None)
Bases:
objectMock score instance for testing
- __init__(name='test_score', costs=None)
- async async_setup()
- get_accumulated_costs()
- async predict(input_data)
- class plexus.test_prediction_commands.MockScorecard(key='test_scorecard')
Bases:
objectMock scorecard for testing
- __init__(key='test_scorecard')
- class plexus.test_prediction_commands.TestEdgeCasesAndErrorHandling
Bases:
objectTest edge cases and error handling scenarios
- test_score_input_with_decimal_in_metadata(mock_scorecard)
Test Score.Input creation with Decimal objects in metadata
- test_score_input_with_numeric_item_id(mock_scorecard, sample_pandas_row)
Test Score.Input creation with numeric item_id (should be converted to string)
- test_score_input_with_unicode_text(mock_scorecard)
Test Score.Input creation with Unicode and special characters
- test_score_input_with_very_long_text(mock_scorecard)
Test Score.Input creation with very long text content
- class plexus.test_prediction_commands.TestFeedbackComparison
Bases:
objectTest feedback comparison functionality
- test_create_feedback_comparison_basic()
Test basic feedback comparison creation
- test_create_feedback_comparison_case_insensitive()
Test that feedback comparison is case insensitive
- test_create_feedback_comparison_disagreement()
Test feedback comparison when prediction disagrees with ground truth
- class plexus.test_prediction_commands.TestIntegrationWithScoreRegistry
Bases:
objectTest integration with the Score registry system
- test_score_from_name_error_handling(mock_scorecard, sample_pandas_row)
Test error handling when Score.from_name fails
- test_score_from_name_integration(mock_scorecard, sample_pandas_row)
Test that create_score_input properly integrates with Score.from_name
- class plexus.test_prediction_commands.TestPredictScoreImpl
Bases:
objectTest the core prediction implementation with proper resource management
- async test_predict_score_impl_cost_calculation_error(mock_scorecard)
Test handling when cost calculation fails
- async test_predict_score_impl_success(mock_scorecard)
Test successful prediction implementation with proper setup and cleanup
- async test_predict_score_impl_with_score_without_costs(mock_scorecard)
Test prediction when score doesn’t have cost tracking
- class plexus.test_prediction_commands.TestPredictionOrchestration
Bases:
objectTest the core prediction orchestration and async handling
- async test_predict_score_with_batch_processing_pause(mock_scorecard, sample_pandas_row)
Test that BatchProcessingPause exceptions are properly propagated
- async test_predict_score_with_empty_result(mock_scorecard, sample_pandas_row)
Test handling when prediction returns None or empty result
- async test_predict_score_with_general_exception(mock_scorecard, sample_pandas_row)
Test error handling for general exceptions during prediction
- async test_successful_predict_score(mock_scorecard, sample_pandas_row)
Test successful prediction with proper async orchestration
- class plexus.test_prediction_commands.TestScoreInputCreation
Bases:
objectTest the critical Score.Input creation and validation process
- test_basic_score_input_creation(mock_scorecard, sample_pandas_row)
Test basic Score.Input creation from sample data
- test_metadata_item_id_preservation(mock_scorecard)
Test that existing item_id in metadata is preserved
- test_score_input_with_complex_metadata(mock_scorecard, sample_row_with_complex_metadata)
Test Score.Input creation with complex nested metadata
- test_score_input_with_empty_text(mock_scorecard)
Test Score.Input creation with empty text
- test_score_input_with_malformed_metadata(mock_scorecard)
Test Score.Input creation with invalid JSON metadata - should handle gracefully
- test_score_input_with_missing_input_class(mock_scorecard, sample_pandas_row)
Test fallback to Score.Input when custom Input class is not available
- test_score_input_with_none_sample_row(mock_scorecard)
Test Score.Input creation when sample_row is None (fallback case)
- plexus.test_prediction_commands.mock_scorecard()
Mock scorecard for testing
- plexus.test_prediction_commands.sample_pandas_row()
Create a sample pandas row with text and metadata
- plexus.test_prediction_commands.sample_row_with_complex_metadata()
Create a sample row with complex nested metadata