Employee Promotion, Transfer - test submit before date, create new employee

This commit is contained in:
Ranjith 2018-05-05 13:43:15 +05:30
parent 56b58017d1
commit a68a108234
2 changed files with 73 additions and 2 deletions

View File

@ -5,6 +5,31 @@ from __future__ import unicode_literals
import frappe import frappe
import unittest import unittest
from frappe.utils import getdate, add_days
from erpnext.hr.doctype.salary_structure.test_salary_structure import make_employee
class TestEmployeePromotion(unittest.TestCase): class TestEmployeePromotion(unittest.TestCase):
pass def setUp(self):
self.employee = make_employee("employee@promotions.com")
frappe.db.sql("""delete from `tabEmployee Promotion`""")
def test_submit_before_promotion_date(self):
promotion_obj = frappe.get_doc({
"doctype": "Employee Promotion",
"employee": self.employee,
"promotion_details" :[
{
"property": "Designation",
"current": "Software Developer",
"new": "Project Manager",
"fieldname": "designation"
}
]
})
promotion_obj.promotion_date = add_days(getdate(), 1)
promotion_obj.save()
self.assertRaises(frappe.DocstatusTransitionError, promotion_obj.submit)
promotion = frappe.get_doc("Employee Promotion", promotion_obj.name)
promotion.promotion_date = getdate()
promotion.submit()
self.assertEqual(promotion.docstatus, 1)

View File

@ -5,6 +5,52 @@ from __future__ import unicode_literals
import frappe import frappe
import unittest import unittest
from frappe.utils import getdate, add_days
from erpnext.hr.doctype.salary_structure.test_salary_structure import make_employee
class TestEmployeeTransfer(unittest.TestCase): class TestEmployeeTransfer(unittest.TestCase):
pass def setUp(self):
make_employee("employee2@transfers.com")
make_employee("employee3@transfers.com")
frappe.db.sql("""delete from `tabEmployee Transfer`""")
def test_submit_before_transfer_date(self):
transfer_obj = frappe.get_doc({
"doctype": "Employee Transfer",
"employee": frappe.get_value("Employee", {"user_id":"employee2@transfers.com"}, "name"),
"transfer_details" :[
{
"property": "Designation",
"current": "Software Developer",
"new": "Project Manager",
"fieldname": "designation"
}
]
})
transfer_obj.transfer_date = add_days(getdate(), 1)
transfer_obj.save()
self.assertRaises(frappe.DocstatusTransitionError, transfer_obj.submit)
transfer = frappe.get_doc("Employee Transfer", transfer_obj.name)
transfer.transfer_date = getdate()
transfer.submit()
self.assertEqual(transfer.docstatus, 1)
def test_new_employee_creation(self):
transfer = frappe.get_doc({
"doctype": "Employee Transfer",
"employee": frappe.get_value("Employee", {"user_id":"employee3@transfers.com"}, "name"),
"create_new_employee_id": 1,
"transfer_date": getdate(),
"transfer_details" :[
{
"property": "Designation",
"current": "Software Developer",
"new": "Project Manager",
"fieldname": "designation"
}
]
}).insert()
transfer.submit()
self.assertTrue(transfer.new_employee_id)
self.assertEqual(frappe.get_value("Employee", transfer.new_employee_id, "status"), "Active")
self.assertEqual(frappe.get_value("Employee", transfer.employee, "status"), "Left")