fix: tests and sider issues
This commit is contained in:
parent
4686527928
commit
dcbf0c9eca
@ -120,8 +120,8 @@
|
||||
"fieldname": "interviewers",
|
||||
"fieldtype": "Table MultiSelect",
|
||||
"label": "Interviewers",
|
||||
"options": "Interviewer",
|
||||
"reqd": 1
|
||||
"mandatory_depends_on": "eval:doc.status==='Scheduled';",
|
||||
"options": "Interviewer"
|
||||
},
|
||||
{
|
||||
"fetch_from": "employee.date_of_joining",
|
||||
@ -218,7 +218,7 @@
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2021-12-07 14:08:29.355390",
|
||||
"modified": "2021-12-07 23:39:22.645401",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Exit Interview",
|
||||
|
@ -4,6 +4,7 @@
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.core.doctype.user_permission.test_user_permission import create_user
|
||||
from frappe.tests.test_webform import create_custom_doctype, create_webform
|
||||
from frappe.utils import getdate
|
||||
@ -13,6 +14,9 @@ from erpnext.hr.doctype.exit_interview.exit_interview import send_exit_questionn
|
||||
|
||||
|
||||
class TestExitInterview(unittest.TestCase):
|
||||
def setUp(self):
|
||||
frappe.db.sql('delete from `tabExit Interview`')
|
||||
|
||||
def test_duplicate_interview(self):
|
||||
employee = make_employee('employeeexit1@example.com')
|
||||
frappe.db.set_value('Employee', employee, 'relieving_date', getdate())
|
||||
@ -23,6 +27,8 @@ class TestExitInterview(unittest.TestCase):
|
||||
|
||||
def test_relieving_date_validation(self):
|
||||
employee = make_employee('employeeexit2@example.com')
|
||||
# unset relieving date
|
||||
frappe.db.set_value('Employee', employee, 'relieving_date', None)
|
||||
|
||||
interview = create_exit_interview(employee, save=False)
|
||||
self.assertRaises(frappe.ValidationError, interview.save)
|
||||
@ -52,9 +58,13 @@ class TestExitInterview(unittest.TestCase):
|
||||
def test_send_exit_questionnaire(self):
|
||||
create_custom_doctype()
|
||||
create_webform()
|
||||
template = create_notification_template()
|
||||
|
||||
webform = frappe.db.get_all('Web Form', limit=1)
|
||||
frappe.db.set_value('HR Settings', 'HR Settings', 'exit_questionnaire_web_form', webform[0].name)
|
||||
frappe.db.set_value('HR Settings', 'HR Settings', {
|
||||
'exit_questionnaire_web_form': webform[0].name,
|
||||
'exit_questionnaire_notification_template': template
|
||||
})
|
||||
|
||||
employee = make_employee('employeeexit3@example.com')
|
||||
frappe.db.set_value('Employee', employee, 'relieving_date', getdate())
|
||||
@ -87,3 +97,21 @@ def create_exit_interview(employee, save=True):
|
||||
if save:
|
||||
return doc.insert()
|
||||
return doc
|
||||
|
||||
|
||||
def create_notification_template():
|
||||
template = frappe.db.exists('Email Template', _('Exit Questionnaire Notification'))
|
||||
if not template:
|
||||
base_path = frappe.get_app_path('erpnext', 'hr', 'doctype')
|
||||
response = frappe.read_file(os.path.join(base_path, 'exit_interview/exit_questionnaire_notification_template.html'))
|
||||
|
||||
template = frappe.get_doc({
|
||||
'doctype': 'Email Template',
|
||||
'name': _('Exit Questionnaire Notification'),
|
||||
'response': response,
|
||||
'subject': _('Exit Questionnaire Notification'),
|
||||
'owner': frappe.session.user,
|
||||
}).insert(ignore_permissions=True)
|
||||
template = template.name
|
||||
|
||||
return template
|
@ -5,13 +5,16 @@ from frappe.utils import add_days, getdate
|
||||
|
||||
from erpnext.hr.doctype.employee.test_employee import make_employee
|
||||
from erpnext.hr.doctype.exit_interview.test_exit_interview import create_exit_interview
|
||||
from erpnext.hr.doctype.full_and_final_statement.test_full_and_final_statement import create_full_and_final_statement
|
||||
from erpnext.hr.doctype.full_and_final_statement.test_full_and_final_statement import (
|
||||
create_full_and_final_statement,
|
||||
)
|
||||
from erpnext.hr.report.employee_exits.employee_exits import execute
|
||||
|
||||
|
||||
class TestEmployeeExits(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
create_company()
|
||||
frappe.db.sql("delete from `tabEmployee` where company='Test Company'")
|
||||
frappe.db.sql("delete from `tabFull and Final Statement` where company='Test Company'")
|
||||
frappe.db.sql("delete from `tabExit Interview` where company='Test Company'")
|
||||
@ -24,26 +27,30 @@ class TestEmployeeExits(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def create_records(cls):
|
||||
cls.emp1 = make_employee('employeeexit1@example.com',
|
||||
cls.emp1 = make_employee(
|
||||
'employeeexit1@example.com',
|
||||
company='Test Company',
|
||||
date_of_joining=getdate('01-10-2021'),
|
||||
relieving_date=add_days(getdate(), 14),
|
||||
designation='Accountant'
|
||||
)
|
||||
cls.emp2 = make_employee('employeeexit2@example.com',
|
||||
cls.emp2 = make_employee(
|
||||
'employeeexit2@example.com',
|
||||
company='Test Company',
|
||||
date_of_joining=getdate('01-12-2021'),
|
||||
relieving_date=add_days(getdate(), 15),
|
||||
designation='Accountant'
|
||||
)
|
||||
|
||||
cls.emp3 = make_employee('employeeexit3@example.com',
|
||||
cls.emp3 = make_employee(
|
||||
'employeeexit3@example.com',
|
||||
company='Test Company',
|
||||
date_of_joining=getdate('02-12-2021'),
|
||||
relieving_date=add_days(getdate(), 29),
|
||||
designation='Engineer'
|
||||
)
|
||||
cls.emp4 = make_employee('employeeexit4@example.com',
|
||||
cls.emp4 = make_employee(
|
||||
'employeeexit4@example.com',
|
||||
company='Test Company',
|
||||
date_of_joining=getdate('01-12-2021'),
|
||||
relieving_date=add_days(getdate(), 30),
|
||||
@ -90,34 +97,36 @@ class TestEmployeeExits(unittest.TestCase):
|
||||
|
||||
employee1 = frappe.get_doc('Employee', self.emp1)
|
||||
employee2 = frappe.get_doc('Employee', self.emp2)
|
||||
expected_data = [{
|
||||
'employee': employee1.name,
|
||||
'employee_name': employee1.employee_name,
|
||||
'date_of_joining': employee1.date_of_joining,
|
||||
'relieving_date': employee1.relieving_date,
|
||||
'department': employee1.department,
|
||||
'designation': employee1.designation,
|
||||
'reports_to': None,
|
||||
'exit_interview': self.interview1.name,
|
||||
'interview_status': self.interview1.status,
|
||||
'employee_status': '',
|
||||
'questionnaire': employee1.name,
|
||||
'full_and_final_statement': self.fnf1.name
|
||||
},
|
||||
{
|
||||
'employee': employee2.name,
|
||||
'employee_name': employee2.employee_name,
|
||||
'date_of_joining': employee2.date_of_joining,
|
||||
'relieving_date': employee2.relieving_date,
|
||||
'department': employee2.department,
|
||||
'designation': employee2.designation,
|
||||
'reports_to': None,
|
||||
'exit_interview': self.interview2.name,
|
||||
'interview_status': self.interview2.status,
|
||||
'employee_status': '',
|
||||
'questionnaire': employee2.name,
|
||||
'full_and_final_statement': self.fnf2.name
|
||||
}]
|
||||
expected_data = [
|
||||
{
|
||||
'employee': employee1.name,
|
||||
'employee_name': employee1.employee_name,
|
||||
'date_of_joining': employee1.date_of_joining,
|
||||
'relieving_date': employee1.relieving_date,
|
||||
'department': employee1.department,
|
||||
'designation': employee1.designation,
|
||||
'reports_to': None,
|
||||
'exit_interview': self.interview1.name,
|
||||
'interview_status': self.interview1.status,
|
||||
'employee_status': '',
|
||||
'questionnaire': employee1.name,
|
||||
'full_and_final_statement': self.fnf1.name
|
||||
},
|
||||
{
|
||||
'employee': employee2.name,
|
||||
'employee_name': employee2.employee_name,
|
||||
'date_of_joining': employee2.date_of_joining,
|
||||
'relieving_date': employee2.relieving_date,
|
||||
'department': employee2.department,
|
||||
'designation': employee2.designation,
|
||||
'reports_to': None,
|
||||
'exit_interview': self.interview2.name,
|
||||
'interview_status': self.interview2.status,
|
||||
'employee_status': '',
|
||||
'questionnaire': employee2.name,
|
||||
'full_and_final_statement': self.fnf2.name
|
||||
}
|
||||
]
|
||||
|
||||
self.assertEqual(expected_data, report[1]) # rows
|
||||
|
||||
@ -189,33 +198,45 @@ class TestEmployeeExits(unittest.TestCase):
|
||||
|
||||
employee3 = frappe.get_doc('Employee', self.emp3)
|
||||
employee4 = frappe.get_doc('Employee', self.emp4)
|
||||
expected_data = [{
|
||||
'employee': employee3.name,
|
||||
'employee_name': employee3.employee_name,
|
||||
'date_of_joining': employee3.date_of_joining,
|
||||
'relieving_date': employee3.relieving_date,
|
||||
'department': employee3.department,
|
||||
'designation': employee3.designation,
|
||||
'reports_to': None,
|
||||
'exit_interview': self.interview3.name,
|
||||
'interview_status': self.interview3.status,
|
||||
'employee_status': '',
|
||||
'questionnaire': employee3.name,
|
||||
'full_and_final_statement': None
|
||||
},
|
||||
{
|
||||
'employee': employee4.name,
|
||||
'employee_name': employee4.employee_name,
|
||||
'date_of_joining': employee4.date_of_joining,
|
||||
'relieving_date': employee4.relieving_date,
|
||||
'department': employee4.department,
|
||||
'designation': employee4.designation,
|
||||
'reports_to': None,
|
||||
'exit_interview': None,
|
||||
'interview_status': None,
|
||||
'employee_status': None,
|
||||
'questionnaire': None,
|
||||
'full_and_final_statement': None
|
||||
}]
|
||||
expected_data = [
|
||||
{
|
||||
'employee': employee3.name,
|
||||
'employee_name': employee3.employee_name,
|
||||
'date_of_joining': employee3.date_of_joining,
|
||||
'relieving_date': employee3.relieving_date,
|
||||
'department': employee3.department,
|
||||
'designation': employee3.designation,
|
||||
'reports_to': None,
|
||||
'exit_interview': self.interview3.name,
|
||||
'interview_status': self.interview3.status,
|
||||
'employee_status': '',
|
||||
'questionnaire': employee3.name,
|
||||
'full_and_final_statement': None
|
||||
},
|
||||
{
|
||||
'employee': employee4.name,
|
||||
'employee_name': employee4.employee_name,
|
||||
'date_of_joining': employee4.date_of_joining,
|
||||
'relieving_date': employee4.relieving_date,
|
||||
'department': employee4.department,
|
||||
'designation': employee4.designation,
|
||||
'reports_to': None,
|
||||
'exit_interview': None,
|
||||
'interview_status': None,
|
||||
'employee_status': None,
|
||||
'questionnaire': None,
|
||||
'full_and_final_statement': None
|
||||
}
|
||||
]
|
||||
|
||||
self.assertEqual(expected_data, report[1]) # rows
|
||||
self.assertEqual(expected_data, report[1]) # rows
|
||||
|
||||
|
||||
def create_company():
|
||||
if not frappe.db.exists('Company', 'Test Company'):
|
||||
frappe.get_doc({
|
||||
'doctype': 'Company',
|
||||
'company_name': 'Test Company',
|
||||
'default_currency': 'INR',
|
||||
'country': 'India'
|
||||
}).insert()
|
Loading…
x
Reference in New Issue
Block a user