|
2 | 2 | # Copyright 2017-2018 Tecnativa - Pedro M. Baeza |
3 | 3 | # Copyright 2018 Brainbean Apps |
4 | 4 | # Copyright 2020 InitOS Gmbh |
| 5 | +# Copyright 2024 Pierre Verkest |
5 | 6 | # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). |
| 7 | +from datetime import datetime |
6 | 8 |
|
7 | 9 | from odoo.tests.common import TransactionCase |
8 | 10 |
|
@@ -188,3 +190,27 @@ def test_number_of_hours_excluding_employee_2(self): |
188 | 190 |
|
189 | 191 | self.assertEqual(leave_request.number_of_days, 2) |
190 | 192 | self.assertEqual(leave_request.number_of_hours_display, 16) |
| 193 | + |
| 194 | + def test_compute_week_hours_without_public_holidays(self): |
| 195 | + self.assertEqual( |
| 196 | + self.calendar.with_context( |
| 197 | + employee_id=self.employee_1.id, exclude_public_holidays=True |
| 198 | + ).get_work_hours_count( |
| 199 | + datetime.combine(datetime(1946, 12, 16), datetime.min.time()), |
| 200 | + datetime.combine(datetime(1946, 12, 22), datetime.max.time()), |
| 201 | + compute_leaves=False, |
| 202 | + ), |
| 203 | + 40, |
| 204 | + ) |
| 205 | + |
| 206 | + def test_compute_week_hours_with_public_holidays(self): |
| 207 | + self.assertEqual( |
| 208 | + self.calendar.with_context( |
| 209 | + employee_id=self.employee_1.id, exclude_public_holidays=True |
| 210 | + ).get_work_hours_count( |
| 211 | + datetime.combine(datetime(1946, 12, 23), datetime.min.time()), |
| 212 | + datetime.combine(datetime(1946, 12, 29), datetime.max.time()), |
| 213 | + compute_leaves=False, |
| 214 | + ), |
| 215 | + 32, |
| 216 | + ) |
0 commit comments