summaryrefslogtreecommitdiff
path: root/test.py
blob: 73225cef7df54a2dd3ef2a7e6b0a61a31f379c43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# 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()