Skip to content

Commit

Permalink
[FIX] fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
huguesdk committed Oct 9, 2024
1 parent f50e18a commit c9c8a6b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
48 changes: 24 additions & 24 deletions resource_multi_week_work_time_from_contracts/tests/test_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,38 @@
class TestCalendar(TestCalendarCommon):
def test_first_last_attendance_both_weeks(self):
result = self.parent_calendar.get_first_last_attendance(
datetime.date.fromisoformat("2024-07-08"),
datetime.date.fromisoformat("2024-07-21"),
datetime.date(2024, 7, 8),
datetime.date(2024, 7, 21),
)
# First date/attendance is the Wednesday.
self.assertEqual(result[0][0], datetime.date.fromisoformat("2024-07-10"))
self.assertEqual(result[0][0], datetime.date(2024, 7, 10))
self.assertEqual(result[0][1], self.child_1.attendance_ids[0])
# Last date/attendance is the Friday.
self.assertEqual(result[1][0], datetime.date.fromisoformat("2024-07-19"))
self.assertEqual(result[1][0], datetime.date(2024, 7, 19))
self.assertEqual(result[1][1], self.child_2.attendance_ids[-1])

def test_first_last_attendance_middle_to_middle(self):
result = self.parent_calendar.get_first_last_attendance(
datetime.date.fromisoformat("2024-07-11"),
datetime.date.fromisoformat("2024-07-16"),
datetime.date(2024, 7, 11),
datetime.date(2024, 7, 16),
)
# First date/attendance is the Thursday.
self.assertEqual(result[0][0], datetime.date.fromisoformat("2024-07-11"))
self.assertEqual(result[0][0], datetime.date(2024, 7, 11))
self.assertEqual(result[0][1], self.child_1.attendance_ids[1])
# Last date/attendance is the Monday.
self.assertEqual(result[1][0], datetime.date.fromisoformat("2024-07-15"))
self.assertEqual(result[1][0], datetime.date(2024, 7, 15))
self.assertEqual(result[1][1], self.child_2.attendance_ids[0])

def test_first_last_attendance_middle_to_before(self):
result = self.parent_calendar.get_first_last_attendance(
datetime.date.fromisoformat("2024-07-16"),
datetime.date.fromisoformat("2024-07-22"),
datetime.date(2024, 7, 16),
datetime.date(2024, 7, 22),
)
# First date/attendance is the Friday.
self.assertEqual(result[0][0], datetime.date.fromisoformat("2024-07-19"))
self.assertEqual(result[0][0], datetime.date(2024, 7, 19))
self.assertEqual(result[0][1], self.child_2.attendance_ids[1])
# Last date/attendance is the Friday of the week preceding the target date.
self.assertEqual(result[1][0], datetime.date.fromisoformat("2024-07-19"))
self.assertEqual(result[1][0], datetime.date(2024, 7, 19))
self.assertEqual(result[1][1], self.child_2.attendance_ids[1])

def test_first_last_attendance_middle_to_before_skip_a_week(self):
Expand All @@ -55,28 +55,28 @@ def test_first_last_attendance_middle_to_before_skip_a_week(self):
)
result = self.parent_calendar.get_first_last_attendance(
# Multi-week 2
datetime.date.fromisoformat("2024-07-16"),
datetime.date(2024, 7, 16),
# Multi-week 1
datetime.date.fromisoformat("2024-07-30"),
datetime.date(2024, 7, 30),
)
# First date/attendance is the Friday.
self.assertEqual(result[0][0], datetime.date.fromisoformat("2024-07-19"))
self.assertEqual(result[0][0], datetime.date(2024, 7, 19))
self.assertEqual(result[0][1], self.child_2.attendance_ids[1])
# Last date/attendance is the Friday of the second week preceding the
# target date.
self.assertEqual(result[1][0], datetime.date.fromisoformat("2024-07-19"))
self.assertEqual(result[1][0], datetime.date(2024, 7, 19))
self.assertEqual(result[1][1], self.child_2.attendance_ids[1])

def test_first_last_attendance_after_to_middle(self):
result = self.parent_calendar.get_first_last_attendance(
datetime.date.fromisoformat("2024-07-12"),
datetime.date.fromisoformat("2024-07-17"),
datetime.date(2024, 7, 12),
datetime.date(2024, 7, 17),
)
# First date/attendance is the Monday of the week succeeding the target date.
self.assertEqual(result[0][0], datetime.date.fromisoformat("2024-07-15"))
self.assertEqual(result[0][0], datetime.date(2024, 7, 15))
self.assertEqual(result[0][1], self.child_2.attendance_ids[0])
# Last date/attendance is the Monday.
self.assertEqual(result[1][0], datetime.date.fromisoformat("2024-07-15"))
self.assertEqual(result[1][0], datetime.date(2024, 7, 15))
self.assertEqual(result[1][1], self.child_2.attendance_ids[0])

def test_first_last_attendance_after_to_middle_skip_a_week(self):
Expand All @@ -91,14 +91,14 @@ def test_first_last_attendance_after_to_middle_skip_a_week(self):
)
result = self.parent_calendar.get_first_last_attendance(
# Multi-week 1.
datetime.date.fromisoformat("2024-07-12"),
datetime.date(2024, 7, 12),
# Multi-week 3.
datetime.date.fromisoformat("2024-07-24"),
datetime.date(2024, 7, 24),
)
# First date/attendance is the Monday of the second week succeeding the
# target date.
self.assertEqual(result[0][0], datetime.date.fromisoformat("2024-07-22"))
self.assertEqual(result[0][0], datetime.date(2024, 7, 22))
self.assertEqual(result[0][1], self.child_2.attendance_ids[0])
# Last date/attendance is the Monday.
self.assertEqual(result[1][0], datetime.date.fromisoformat("2024-07-22"))
self.assertEqual(result[1][0], datetime.date(2024, 7, 22))
self.assertEqual(result[1][1], self.child_2.attendance_ids[0])
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ git+https://github.com/beescoop/[email protected]#subdirectory=setup/product_main_su
git+https://github.com/beescoop/[email protected]#subdirectory=setup/sale_adapt_price_wizard
git+https://github.com/beescoop/[email protected]#subdirectory=setup/sale_suggested_price
git+https://github.com/beescoop/[email protected]#subdirectory=setup/purchase_order_responsible
freezegun

0 comments on commit c9c8a6b

Please sign in to comment.