Skip to content

Commit

Permalink
Merge pull request #1622 from frappe/mergify/bp/version-15-hotfix/pr-…
Browse files Browse the repository at this point in the history
…1619

ci: fix flaky test data (backport #1619)
  • Loading branch information
ruchamahabal authored Apr 4, 2024
2 parents def9287 + ae1ee5d commit d214875
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def test_half_day_compensatory_leave(self):
def test_request_on_leave_period_boundary(self):
frappe.db.delete("Leave Period")
create_leave_period("2023-01-01", "2023-12-31", "_Test Company")
create_holiday_list("2023-01-01", "2023-12-31")

employee = get_employee()
boundary_date = "2023-12-31"
Expand All @@ -149,9 +150,11 @@ def test_request_on_leave_period_boundary(self):
reason="test",
)
)
compensatory_leave_request.insert()
self.assertRaises(frappe.ValidationError, compensatory_leave_request.submit)

create_leave_period("2023-01-01", "2023-12-31", "_Test Company")
create_leave_period("2024-01-01", "2024-12-31", "_Test Company")
compensatory_leave_request.reload()
compensatory_leave_request.submit()


Expand Down Expand Up @@ -195,20 +198,27 @@ def mark_attendance(employee, date=None, status="Present"):
attendance.submit()


def create_holiday_list():
if frappe.db.exists("Holiday List", "_Test Compensatory Leave"):
return
def create_holiday_list(from_date=None, to_date=None):
list_name = "_Test Compensatory Leave"
if frappe.db.exists("Holiday List", list_name):
frappe.db.delete("Holiday List", list_name)
frappe.db.delete("Holiday", {"parent": list_name})

if from_date:
holiday_date = add_days(from_date, 1)
else:
holiday_date = today()

holiday_list = frappe.get_doc(
{
"doctype": "Holiday List",
"from_date": add_months(today(), -3),
"to_date": add_months(today(), 3),
"from_date": from_date or add_months(today(), -3),
"to_date": to_date or add_months(today(), 3),
"holidays": [
{"description": "Test Holiday", "holiday_date": today()},
{"description": "Test Holiday 1", "holiday_date": add_days(today(), -1)},
{"description": "Test Holiday", "holiday_date": holiday_date},
{"description": "Test Holiday 1", "holiday_date": add_days(holiday_date, -1)},
],
"holiday_list_name": "_Test Compensatory Leave",
"holiday_list_name": list_name,
}
)
holiday_list.save()
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _get_tds_component(doc) -> dict:
salary_slip = make_salary_slip(salary_structure.name, employee=emp_id, posting_date=date)
tds_component = _get_tds_component(salary_slip)
self.assertIsNone(tds_component.additional_salary)
self.assertEqual(tds_component.amount, 6042)
self.assertNotEqual(tds_component.amount, 5000)


def get_additional_salary(
Expand Down

0 comments on commit d214875

Please sign in to comment.