# test.py from date_calculator import DateCalculator from calendar_manager import CalendarManager from prediction_controller import PredictionController from prediction_storage import PredictionStorage def test_updated_functionality(): # Create necessary objects date_calculator = DateCalculator() calendar_manager = CalendarManager() prediction_storage = PredictionStorage("predictions.json") prediction_controller = PredictionController( calendar_manager, date_calculator, ["full_project", "half_project", "event"], prediction_storage ) # Add calendar entries with commentary calendar_manager.add_entry( "2023-01-01", "2023-01-10", "event", commentary="Annual company meeting" ) calendar_manager.add_entry( "2023-01-05", "2023-01-15", "event", commentary="Product launch conference" ) calendar_manager.add_entry( "2025-01-02", "2025-02-11", "full_project", commentary="Website redesign project" ) # Test adding commentary to existing entry entries = calendar_manager.list_entries() project_entry = entries[2] # Get the third entry (full_project) calendar_manager.add_commentary(project_entry.id, "Updated: Major redesign with new branding") # Make prediction with description prediction_controller.make_prediction( "2023-01-01", 2, description="Initial project timeline prediction" ) # Make another prediction prediction_controller.make_prediction( "2023-02-01", 1, description="Revised timeline after scope changes" ) # Retrieve and display stored predictions all_predictions = prediction_controller.get_all_predictions() print("\nAll stored predictions:") for pred in all_predictions: print(f"- {pred.id}: {pred.launch_date.strftime('%Y-%m-%d')} to {pred.predicted_date.strftime('%Y-%m-%d')} ({pred.duration_years} years)") print(f" Description: {pred.description}") # Search predictions if all_predictions: # Update description of first prediction first_pred_id = all_predictions[0].id prediction_controller.update_prediction_description( first_pred_id, "Updated: Initial project timeline with adjusted parameters" ) # Search by date range date_filtered = prediction_controller.search_predictions( start_date="2024-01-01", end_date="2025-12-31" ) print("\nPredictions ending in 2024-2025:") for pred in date_filtered: print(f"- {pred.id}: ends on {pred.predicted_date.strftime('%Y-%m-%d')}") # Display calendar entries with commentary print("\nCalendar entries with commentary:") for entry in calendar_manager.list_entries(): print(f"- {entry.keyword}: {entry.start_date.strftime('%Y-%m-%d')} to {entry.end_date.strftime('%Y-%m-%d')}") if entry.commentary: print(f" Commentary: {entry.commentary}") if __name__ == "__main__": test_updated_functionality()