From 4a5d9a02e3b74b5c430f45514dc6fc5ccb3b7aa8 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Tue, 4 Jan 2022 13:04:10 +0530 Subject: [PATCH] test: Update date utils test cases --- frappe/tests/test_utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/frappe/tests/test_utils.py b/frappe/tests/test_utils.py index 67586719c8..5d2b8a918f 100644 --- a/frappe/tests/test_utils.py +++ b/frappe/tests/test_utils.py @@ -15,6 +15,8 @@ import io from mimetypes import guess_type from datetime import datetime, timedelta, date +from unittest.mock import patch + class TestFilters(unittest.TestCase): def test_simple_dict(self): self.assertTrue(evaluate_filters({'doctype': 'User', 'status': 'Open'}, {'status': 'Open'})) @@ -309,6 +311,14 @@ class TestDiffUtils(unittest.TestCase): class TestDateUtils(unittest.TestCase): def test_first_day_of_week(self): + # Monday as start of the week + with patch.object(frappe.utils.data, "get_week_starts_on", return_value="Monday"): + self.assertEqual(frappe.utils.get_first_day_of_week("2020-12-25"), + frappe.utils.getdate("2020-12-21")) + self.assertEqual(frappe.utils.get_first_day_of_week("2020-12-20"), + frappe.utils.getdate("2020-12-14")) + + # Sunday as start of the week self.assertEqual(frappe.utils.get_first_day_of_week("2020-12-25"), frappe.utils.getdate("2020-12-20")) self.assertEqual(frappe.utils.get_first_day_of_week("2020-12-21"),