From 793667291457380a0341f2ce7f3d25934de56b5b Mon Sep 17 00:00:00 2001 From: matin Date: Mon, 21 Apr 2025 18:06:36 +0200 Subject: first try to add commentary and save functionalities by Claude --- test.py | 133 +++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 93 insertions(+), 40 deletions(-) (limited to 'test.py') diff --git a/test.py b/test.py index a2812c2..73225ce 100644 --- a/test.py +++ b/test.py @@ -1,40 +1,93 @@ -# test.py -from date_calculator import DateCalculator -from calendar_manager import CalendarManager -from prediction_controller import PredictionController - - - -def test_calculate_prediction(): - # Input event dates as strings - event1_str = ["2023-01-01", "2023-01-10"] - event2_str = ["2023-01-05", "2023-01-15"] - - # Input full project dates as strings - project1_str = ["2025-01-02", "2025-02-11"] - - # Input half project dates as strings - project2_str = ["2025-02-01", "2025-06-30"] - project3_str = ["2024-05-05", "2024-06-07"] - - date_calculator = DateCalculator() - calendar_manager = CalendarManager() - prediction_controller = PredictionController(calendar_manager, date_calculator, ["full_project", "half_project", "event"]) - - calendar_manager.add_entry(event1_str[0], event1_str[1], "event") - calendar_manager.add_entry(event2_str[0], event2_str[1], "event") - calendar_manager.add_entry(project1_str[0], project1_str[1], "full_project") - calendar_manager.add_entry(project2_str[0], project2_str[1], "half_project") - calendar_manager.add_entry(project3_str[0], project3_str[1], "half_project") - - # Set launch date and duration - prediction_controller.make_prediction("2023-01-01", 2) - - prediction = prediction_controller.get_prediction() - - # Output the result - print(f"Predicted completion date: {prediction}") - print(calendar_manager.list_entries()) - -# Run the test -test_calculate_prediction() \ No newline at end of file +# 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() \ No newline at end of file -- cgit v1.1