|
1 | 1 | import pytest |
2 | 2 | from django.utils import timezone |
3 | 3 | from model_bakery import baker |
4 | | -from service.operation_designated_operator_timeline_service import OperationDesignatedOperatorTimelineService |
| 4 | +from service.operation_designated_operator_timeline_service import ( |
| 5 | + OperationDesignatedOperatorTimelinePlus, |
| 6 | + OperationDesignatedOperatorTimelineService, |
| 7 | +) |
5 | 8 |
|
6 | 9 | pytestmark = pytest.mark.django_db |
7 | 10 |
|
@@ -103,55 +106,58 @@ def test_get_operation_designated_operators_for_reporting_years_returns_matching |
103 | 106 | "registration.tests.utils.operation_designated_operator_timeline", |
104 | 107 | operation=operation, |
105 | 108 | operator=operator1, |
106 | | - start_date=timezone.datetime(2024, 6, 1).date(), |
107 | | - end_date=timezone.datetime(2025, 5, 31).date(), |
| 109 | + start_date=timezone.make_aware(timezone.datetime(2024, 6, 1)), |
| 110 | + end_date=timezone.make_aware(timezone.datetime(2025, 5, 31)), |
108 | 111 | ) |
109 | 112 | timeline2 = baker.make_recipe( |
110 | 113 | "registration.tests.utils.operation_designated_operator_timeline", |
111 | 114 | operation=operation, |
112 | 115 | operator=operator2, |
113 | | - start_date=timezone.datetime(2025, 5, 31).date(), |
| 116 | + start_date=timezone.make_aware(timezone.datetime(2025, 5, 31)), |
114 | 117 | end_date=None, |
115 | 118 | ) |
116 | 119 |
|
117 | 120 | result = OperationDesignatedOperatorTimelineService.get_operation_designated_operators_for_reporting_years( |
118 | 121 | operation_ids={operation.id}, |
119 | | - reporting_years={2023, 2024, 2025}, |
| 122 | + min_year=2023, |
| 123 | + max_year=2025, |
120 | 124 | ) |
121 | 125 |
|
122 | 126 | assert len(result) == 2 |
123 | 127 | assert (operation.id, 2023) not in result |
124 | 128 |
|
125 | | - result_2024 = result[(operation.id, 2024)] |
126 | | - assert result_2024.operation == timeline1.operation |
127 | | - assert result_2024.operator == timeline1.operator |
128 | | - assert result_2024.start_date == timeline1.start_date |
129 | | - assert result_2024.end_date == timeline1.end_date |
130 | | - assert result_2024.has_been_transferred is True |
| 129 | + assert result[(operation.id, 2024)] == OperationDesignatedOperatorTimelinePlus( |
| 130 | + operation=timeline1.operation, |
| 131 | + operator=timeline1.operator, |
| 132 | + start_date=timeline1.start_date, |
| 133 | + end_date=timeline1.end_date, |
| 134 | + ) |
131 | 135 |
|
132 | | - result_2025 = result[(operation.id, 2025)] |
133 | | - assert result_2025.operation == timeline2.operation |
134 | | - assert result_2025.operator == timeline2.operator |
135 | | - assert result_2025.start_date == timeline2.start_date |
136 | | - assert result_2025.end_date == timeline2.end_date |
137 | | - assert result_2025.has_been_transferred is False |
| 136 | + assert result[(operation.id, 2025)] == OperationDesignatedOperatorTimelinePlus( |
| 137 | + operation=timeline2.operation, |
| 138 | + operator=timeline2.operator, |
| 139 | + start_date=timeline2.start_date, |
| 140 | + end_date=timeline2.end_date, |
| 141 | + ) |
138 | 142 |
|
139 | 143 | @staticmethod |
140 | 144 | def test_get_operation_designated_operators_for_reporting_years_returns_empty_when_operation_ids_empty(): |
141 | 145 | result = OperationDesignatedOperatorTimelineService.get_operation_designated_operators_for_reporting_years( |
142 | 146 | operation_ids=set(), |
143 | | - reporting_years={2024, 2025}, |
| 147 | + min_year=2024, |
| 148 | + max_year=2025, |
144 | 149 | ) |
145 | 150 |
|
146 | 151 | assert result == {} |
147 | 152 |
|
148 | 153 | @staticmethod |
149 | | - def test_get_operation_designated_operators_for_reporting_years_returns_empty_when_reporting_years_empty(): |
| 154 | + def test_get_operation_designated_operators_for_reporting_years_returns_empty_when_year_range_is_empty(): |
150 | 155 | operation = baker.make_recipe("registration.tests.utils.operation") |
151 | 156 |
|
152 | 157 | result = OperationDesignatedOperatorTimelineService.get_operation_designated_operators_for_reporting_years( |
153 | 158 | operation_ids={operation.id}, |
154 | | - reporting_years=set(), |
| 159 | + min_year=2025, |
| 160 | + max_year=2024, |
155 | 161 | ) |
156 | 162 |
|
157 | 163 | assert result == {} |
0 commit comments