From dbe537bfa79114c09b76b8b950e24a46e969827c Mon Sep 17 00:00:00 2001 From: Neha Sacher Date: Fri, 8 Oct 2021 13:48:17 +0530 Subject: [PATCH 1/4] ix: fixed the test cases for HR module --- .../salary_structure/test_salary_structure.py | 4 +-- .../shift_assignment/test_shift_assignment.py | 4 ++- .../shift_request/test_shift_request.py | 4 ++- .../hr/doctype/shift_type/test_shift_type.py | 27 ++++++++++++------- 4 files changed, 25 insertions(+), 14 deletions(-) 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..7ee908ca730a 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 + pass + + +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 + From f594ace205ca8a95f7c93e7a1b616caf3027a7b1 Mon Sep 17 00:00:00 2001 From: Neha Sacher Date: Fri, 8 Oct 2021 16:51:37 +0530 Subject: [PATCH 2/4] fix: fixed the leave test cases --- erpnext/hr/doctype/shift_type/test_shift_type.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/shift_type/test_shift_type.py b/erpnext/hr/doctype/shift_type/test_shift_type.py index 7ee908ca730a..6a53000120ba 100644 --- a/erpnext/hr/doctype/shift_type/test_shift_type.py +++ b/erpnext/hr/doctype/shift_type/test_shift_type.py @@ -8,7 +8,7 @@ class TestShiftType(unittest.TestCase): def test_make_shift_type(self): - pass + create_shift_type() def create_shift_type(): From bd9024e5ce3bf426996f64f0bc9c32c9011f628f Mon Sep 17 00:00:00 2001 From: Neha Sacher Date: Fri, 8 Oct 2021 17:04:18 +0530 Subject: [PATCH 3/4] fix: fixed the shift type test case --- erpnext/hr/doctype/shift_type/test_shift_type.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/shift_type/test_shift_type.py b/erpnext/hr/doctype/shift_type/test_shift_type.py index 6a53000120ba..c74ee3fa32ab 100644 --- a/erpnext/hr/doctype/shift_type/test_shift_type.py +++ b/erpnext/hr/doctype/shift_type/test_shift_type.py @@ -8,7 +8,8 @@ class TestShiftType(unittest.TestCase): def test_make_shift_type(self): - create_shift_type() + shift = create_shift_type() + self.assertEqual(shift, "Day Shift") def create_shift_type(): From 2eaad7c28c15c1400e530ed4aa119ad2a8f558c4 Mon Sep 17 00:00:00 2001 From: sahil28297 <37302950+sahil28297@users.noreply.github.com> Date: Fri, 8 Oct 2021 17:11:29 +0530 Subject: [PATCH 4/4] Update erpnext/hr/doctype/shift_type/test_shift_type.py --- erpnext/hr/doctype/shift_type/test_shift_type.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/erpnext/hr/doctype/shift_type/test_shift_type.py b/erpnext/hr/doctype/shift_type/test_shift_type.py index c74ee3fa32ab..f3c46a5fb7b0 100644 --- a/erpnext/hr/doctype/shift_type/test_shift_type.py +++ b/erpnext/hr/doctype/shift_type/test_shift_type.py @@ -8,8 +8,7 @@ class TestShiftType(unittest.TestCase): def test_make_shift_type(self): - shift = create_shift_type() - self.assertEqual(shift, "Day Shift") + self.assertEqual(create_shift_type(), "Day Shift") def create_shift_type():