fix: tests

This commit is contained in:
Rucha Mahabal
2021-04-26 16:03:10 +05:30
parent 4716ebea5a
commit 7a84d76489
3 changed files with 44 additions and 44 deletions

View File

@@ -167,15 +167,11 @@ class EmployeeHoursReport:
def set_employee_department_and_name(self): def set_employee_department_and_name(self):
for emp in self.stats_by_employee: for emp in self.stats_by_employee:
emp_name = frappe.db.get_value(
'Employee', emp, 'employee_name'
)
emp_dept = frappe.db.get_value( emp_dept = frappe.db.get_value(
'Employee', emp, 'department' 'Employee', emp, 'department'
) )
self.stats_by_employee[emp]['department'] = emp_dept self.stats_by_employee[emp]['department'] = emp_dept
self.stats_by_employee[emp]['employee_name'] = emp_name
def calculate_utilizations(self): def calculate_utilizations(self):
TOTAL_HOURS = flt(self.standard_working_hours * self.day_span, 2) TOTAL_HOURS = flt(self.standard_working_hours * self.day_span, 2)

View File

@@ -20,6 +20,8 @@ class TestEmployeeUtilization(unittest.TestCase):
# Create test timesheets # Create test timesheets
cls.create_test_timesheets() cls.create_test_timesheets()
frappe.db.set_value("HR Settings", "HR Settings", "standard_working_hours", 9)
@classmethod @classmethod
def create_test_timesheets(cls): def create_test_timesheets(cls):
timesheet1 = frappe.new_doc("Timesheet") timesheet1 = frappe.new_doc("Timesheet")
@@ -94,13 +96,13 @@ class TestEmployeeUtilization(unittest.TestCase):
expected_data = [ expected_data = [
{ {
'employee': self.test_emp1, 'employee': self.test_emp1,
'employee_name': emp1_data.employee_name,
'department': emp1_data.department,
'billed_hours': 5.0, 'billed_hours': 5.0,
'non_billed_hours': 0.0, 'non_billed_hours': 0.0,
'department': emp1_data.department,
'total_hours': 18.0, 'total_hours': 18.0,
'untracked_hours': 13.0, 'untracked_hours': 13.0,
'per_util': 27.78 'per_util': 27.78,
'per_util_billed_only': 27.78
} }
] ]
@@ -120,13 +122,13 @@ class TestEmployeeUtilization(unittest.TestCase):
expected_data = [ expected_data = [
{ {
'employee': self.test_emp2, 'employee': self.test_emp2,
'employee_name': emp2_data.employee_name,
'department': emp2_data.department,
'billed_hours': 0.0, 'billed_hours': 0.0,
'non_billed_hours': 10.0, 'non_billed_hours': 10.0,
'department': emp2_data.department,
'total_hours': 18.0, 'total_hours': 18.0,
'untracked_hours': 8.0, 'untracked_hours': 8.0,
'per_util': 55.56 'per_util': 55.56,
'per_util_billed_only': 0.0
} }
] ]
@@ -155,7 +157,7 @@ class TestEmployeeUtilization(unittest.TestCase):
report = execute(filters) report = execute(filters)
summary = report[4] summary = report[4]
expected_summary_values = ['41.67%', 5.0, 10.0, 21.0] expected_summary_values = ['41.67%', '13.89%', 5.0, 10.0]
self.assertEqual(len(summary), 4) self.assertEqual(len(summary), 4)
@@ -171,22 +173,22 @@ class TestEmployeeUtilization(unittest.TestCase):
return [ return [
{ {
'employee': self.test_emp2, 'employee': self.test_emp2,
'employee_name': emp2_data.employee_name,
'department': emp2_data.department,
'billed_hours': 0.0, 'billed_hours': 0.0,
'non_billed_hours': 10.0, 'non_billed_hours': 10.0,
'department': emp2_data.department,
'total_hours': 18.0, 'total_hours': 18.0,
'untracked_hours': 8.0, 'untracked_hours': 8.0,
'per_util': 55.56 'per_util': 55.56,
'per_util_billed_only': 0.0
}, },
{ {
'employee': self.test_emp1, 'employee': self.test_emp1,
'employee_name': emp1_data.employee_name,
'department': emp1_data.department,
'billed_hours': 5.0, 'billed_hours': 5.0,
'non_billed_hours': 0.0, 'non_billed_hours': 0.0,
'department': emp1_data.department,
'total_hours': 18.0, 'total_hours': 18.0,
'untracked_hours': 13.0, 'untracked_hours': 13.0,
'per_util': 27.78 'per_util': 27.78,
'per_util_billed_only': 27.78
} }
] ]

View File

@@ -21,6 +21,8 @@ class TestProjectProfitability(unittest.TestCase):
self.sales_invoice.due_date = nowdate() self.sales_invoice.due_date = nowdate()
self.sales_invoice.submit() self.sales_invoice.submit()
frappe.db.set_value("HR Settings", "HR Settings", "standard_working_hours", 8)
def test_project_profitability(self): def test_project_profitability(self):
filters = { filters = {
'company': '_Test Company', 'company': '_Test Company',