From c9c8a6b0f396907131021e26046c1c59e0b934a9 Mon Sep 17 00:00:00 2001 From: hugues de keyzer Date: Wed, 9 Oct 2024 15:45:03 +0200 Subject: [PATCH] [FIX] fix tests --- .../tests/test_calendar.py | 48 +++++++++---------- test-requirements.txt | 1 + 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/resource_multi_week_work_time_from_contracts/tests/test_calendar.py b/resource_multi_week_work_time_from_contracts/tests/test_calendar.py index e602883a..7e2ef55f 100644 --- a/resource_multi_week_work_time_from_contracts/tests/test_calendar.py +++ b/resource_multi_week_work_time_from_contracts/tests/test_calendar.py @@ -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): @@ -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): @@ -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]) diff --git a/test-requirements.txt b/test-requirements.txt index 72d2977d..33ebd56d 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -17,3 +17,4 @@ git+https://github.com/beescoop/obeesdoo@12.0#subdirectory=setup/product_main_su git+https://github.com/beescoop/obeesdoo@12.0#subdirectory=setup/sale_adapt_price_wizard git+https://github.com/beescoop/obeesdoo@12.0#subdirectory=setup/sale_suggested_price git+https://github.com/beescoop/obeesdoo@12.0#subdirectory=setup/purchase_order_responsible +freezegun