summaryrefslogtreecommitdiff
path: root/test.py
blob: cbad19d7329a4275913a8b75dcf90e375f4b1e5c (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
# test.py
from date_calculator import DateCalculator
from calendar_manager import CalendarManager
from prediction_controller import PredictionController
from event_type_handler import EventTypeHandler
from config import EventConfig

def test_calculate_prediction():
    """Test the refactored prediction calculation system"""
    print("Testing refactored prediction calculation system...")
    
    # Input event dates as strings
    event1_str = ["2023-01-01", "2023-01-02"]
    event2_str = ["2023-01-05", "2023-01-15"]

    # Input full project dates as strings
    project1_str = ["2023-01-01", "2024-12-31"]

    # Input half project dates as strings
    project2_str = ["2025-01-01", "2026-12-31"]
    project3_str = ["2024-05-05", "2024-06-07"]

    # Initialize components
    date_calculator = DateCalculator()
    calendar_manager = CalendarManager()
    prediction_controller = PredictionController(calendar_manager, date_calculator)
    
    # Add entries to calendar
    print("Adding calendar entries...")
    # calendar_manager.add_entry(event2_str[0], event2_str[1], "Sonstige")
    calendar_manager.add_entry(project1_str[0], project1_str[1], "EZ pauschal")
    calendar_manager.add_entry(event1_str[0], event1_str[1], "Sonstige")
    calendar_manager.add_entry(project2_str[0], project2_str[1], "EZ pauschal")
    # calendar_manager.add_entry(project3_str[0], project3_str[1], "EZ 50%")

    # Test validation
    print("Testing input validation...")
    errors = prediction_controller.validate_prediction_inputs("2023-01-01", 2)
    if errors:
        print(f"Validation errors: {errors}")
    else:
        print("Input validation passed")

    # Calculate prediction
    print("Calculating prediction...")
    success = prediction_controller.make_prediction("2023-01-01", 1)
    
    if success:
        prediction = prediction_controller.get_prediction()
        print(f"Predicted completion date: {prediction}")
        print(calendar_manager.entries)
        # Test event type handler
        print("\nTesting EventTypeHandler...")
        entries = calendar_manager.list_entries()
        categorized = EventTypeHandler.categorize_events(entries)
        print(f"Categorized events: {list(categorized.keys())}")
        
        # Test accounted time calculation
        for entry in entries:
            accounted_time = EventTypeHandler.calculate_accounted_time(entry)
            print(f"Entry {entry.id}: {accounted_time}")
        
        print(f"\nAll calendar entries: {len(calendar_manager.list_entries())}")
    else:
        print("Prediction calculation failed")


if __name__ == "__main__":
    test_calculate_prediction()