diff --git a/erpnext/hr/doctype/salary_structure/test_salary_structure.py b/erpnext/hr/doctype/salary_structure/test_salary_structure.py index 3e55a1a068d0..efb2d7766d77 100644 --- a/erpnext/hr/doctype/salary_structure/test_salary_structure.py +++ b/erpnext/hr/doctype/salary_structure/test_salary_structure.py @@ -116,8 +116,8 @@ def make_salary_structure(salary_structure, payroll_frequency, employee=None, do "doctype": "Salary Structure", "name": salary_structure, "company": erpnext.get_default_company(), - "earnings": make_earning_salary_component(test_tax=test_tax), - "deductions": make_deduction_salary_component(test_tax=test_tax), + "earnings": make_earning_salary_component(setup=True, test_tax=test_tax), + "deductions": make_deduction_salary_component(setup=True, test_tax=test_tax), "payroll_frequency": payroll_frequency, "payment_account": get_random("Account") } diff --git a/erpnext/hr/doctype/shift_assignment/test_shift_assignment.py b/erpnext/hr/doctype/shift_assignment/test_shift_assignment.py index 7fe80a236c67..030c3c0de5e5 100644 --- a/erpnext/hr/doctype/shift_assignment/test_shift_assignment.py +++ b/erpnext/hr/doctype/shift_assignment/test_shift_assignment.py @@ -5,6 +5,7 @@ import frappe import unittest +from erpnext.hr.doctype.shift_type.test_shift_type import create_shift_type from frappe.utils import nowdate test_dependencies = ["Shift Type"] @@ -15,9 +16,10 @@ def setUp(self): frappe.db.sql("delete from `tabShift Assignment`") def test_make_shift_assignment(self): + shift = create_shift_type() shift_assignment = frappe.get_doc({ "doctype": "Shift Assignment", - "shift_type": "Day Shift", + "shift_type": shift, "company": "_Test Company", "employee": "_T-Employee-00001", "date": nowdate() diff --git a/erpnext/hr/doctype/shift_request/test_shift_request.py b/erpnext/hr/doctype/shift_request/test_shift_request.py index 1d0cf719c29d..673fd182a63e 100644 --- a/erpnext/hr/doctype/shift_request/test_shift_request.py +++ b/erpnext/hr/doctype/shift_request/test_shift_request.py @@ -5,6 +5,7 @@ import frappe import unittest +from erpnext.hr.doctype.shift_type.test_shift_type import create_shift_type from frappe.utils import nowdate class TestShiftRequest(unittest.TestCase): @@ -13,9 +14,10 @@ def setUp(self): frappe.db.sql("delete from `tab{doctype}`".format(doctype=doctype)) def test_make_shift_request(self): + shift = create_shift_type() shift_request = frappe.get_doc({ "doctype": "Shift Request", - "shift_type": "Day Shift", + "shift_type": shift, "company": "_Test Company", "employee": "_T-Employee-00001", "employee_name": "_Test Employee", diff --git a/erpnext/hr/doctype/shift_type/test_shift_type.py b/erpnext/hr/doctype/shift_type/test_shift_type.py index 535072a03580..f3c46a5fb7b0 100644 --- a/erpnext/hr/doctype/shift_type/test_shift_type.py +++ b/erpnext/hr/doctype/shift_type/test_shift_type.py @@ -8,13 +8,20 @@ class TestShiftType(unittest.TestCase): def test_make_shift_type(self): - if frappe.db.exists("Shift Type", "Day Shift"): - return - shift_type = frappe.get_doc({ - "doctype": "Shift Type", - "name": "Day Shift", - "start_time": "9:00:00", - "end_time": "18:00:00" - }) - shift_type.insert() - \ No newline at end of file + self.assertEqual(create_shift_type(), "Day Shift") + + +def create_shift_type(): + shift = frappe.db.exists("Shift Type", "Day Shift") + if shift: + return shift + + shift_type = frappe.get_doc({ + "doctype": "Shift Type", + "name": "Day Shift", + "start_time": "9:00:00", + "end_time": "18:00:00" + }) + shift_type.insert() + return shift_type.name +