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

ci: fix flaky test data (backport #1619) #1622

Merged
Merged
Show file tree
Hide file tree
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
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
Loading