Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: increase accuracy of assertion #2259

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions hrms/hr/doctype/leave_block_list/test_leave_block_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ def test_get_applicable_block_dates(self):
frappe.db.set_value(
"Department", "_Test Department - _TC", "leave_block_list", "_Test Leave Block List"
)
self.assertTrue(
getdate("2013-01-02")
in [d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03")]
)
block_days = [d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03")]
self.assertIn(getdate("2013-01-02"), block_days)

def test_get_applicable_block_dates_for_allowed_user(self):
frappe.set_user("test1@example.com")
Expand All @@ -37,10 +35,10 @@ def test_get_applicable_block_dates_all_lists(self):
frappe.db.set_value(
"Department", "_Test Department 1 - _TC", "leave_block_list", "_Test Leave Block List"
)
self.assertTrue(
getdate("2013-01-02")
in [d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03", all_lists=True)]
)
block_days = [
d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03", all_lists=True)
]
self.assertIn(getdate("2013-01-02"), block_days)

def test_get_applicable_block_dates_all_lists_for_leave_type(self):
frappe.set_user("test1@example.com")
Expand All @@ -52,10 +50,10 @@ def test_get_applicable_block_dates_all_lists_for_leave_type(self):
"2013-01-01", "2013-01-31", all_lists=True, leave_type="Casual Leave"
)
]
self.assertTrue(getdate("2013-01-16") in block_days)
self.assertTrue(getdate("2013-01-19") in block_days)
self.assertTrue(getdate("2013-01-02") in block_days)
self.assertFalse(getdate("2013-01-25") in block_days)
self.assertIn(getdate("2013-01-16"), block_days)
self.assertIn(getdate("2013-01-19"), block_days)
self.assertIn(getdate("2013-01-02"), block_days)
self.assertNotIn(getdate("2013-01-25"), block_days)

def test_get_applicable_block_dates_for_allowed_user_for_leave_type(self):
frappe.set_user("test1@example.com")
Expand All @@ -65,7 +63,7 @@ def test_get_applicable_block_dates_for_allowed_user_for_leave_type(self):
d.block_date
for d in get_applicable_block_dates("2013-01-01", "2013-01-31", leave_type="Casual Leave")
]
self.assertTrue(getdate("2013-01-19") in block_days)
self.assertFalse(getdate("2013-01-16") in block_days)
self.assertFalse(getdate("2013-01-02") in block_days)
self.assertFalse(getdate("2013-01-25") in block_days)
self.assertIn(getdate("2013-01-19"), block_days)
self.assertNotIn(getdate("2013-01-16"), block_days)
self.assertNotIn(getdate("2013-01-02"), block_days)
self.assertNotIn(getdate("2013-01-25"), block_days)
Loading