test cases for leave
This commit is contained in:
parent
c7cf94ec7b
commit
a6f0550d40
55
erpnext/sandbox/test_leave.py
Normal file
55
erpnext/sandbox/test_leave.py
Normal file
@ -0,0 +1,55 @@
|
||||
import unittest
|
||||
|
||||
import webnotes
|
||||
import webnotes.profile
|
||||
webnotes.user = webnotes.profile.Profile()
|
||||
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes.utils import cstr, flt
|
||||
from webnotes.model.doclist import getlist
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
from sandbox.testdata import leaves
|
||||
#----------------------------------------------------------
|
||||
|
||||
|
||||
class TestStockEntry(unittest.TestCase):
|
||||
#===========================================================================
|
||||
def setUp(self):
|
||||
webnotes.conn.begin()
|
||||
leaves.emp.save(new = 1, make_autoname = 0)
|
||||
|
||||
def test_leave_bal(self):
|
||||
leaves.l_all.save(1)
|
||||
leaves.l_app1.save(1)
|
||||
leaves.l_app2.save(1)
|
||||
|
||||
la1 = get_obj('Leave Application', leaves.l_app1.name, with_children=1)
|
||||
la1.validate()
|
||||
la1.doc.docstatus = 1
|
||||
la1.doc.save()
|
||||
|
||||
self.assertTrue(la1.doc.total_leave_days == 2)
|
||||
|
||||
la1.doc.half_day = 1
|
||||
la1.validate()
|
||||
la1.doc.save()
|
||||
|
||||
self.assertTrue(la1.doc.total_leave_days == .5)
|
||||
|
||||
print "Test case for leave applied no of days"
|
||||
|
||||
|
||||
la2 = get_obj('Leave Application', leaves.l_app2.name, with_children=1)
|
||||
la2.validate()
|
||||
bal = la2.get_leave_balance()
|
||||
self.assertTrue(bal, 18)
|
||||
print "Test case for leave balance"
|
||||
|
||||
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
webnotes.conn.rollback()
|
54
erpnext/sandbox/testdata/leaves.py
vendored
Normal file
54
erpnext/sandbox/testdata/leaves.py
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
from webnotes.model.doc import Document
|
||||
|
||||
emp = Document(
|
||||
fielddata = {
|
||||
'doctype': 'Employee',
|
||||
'name': 'emp1',
|
||||
'employee_name': 'Nijil',
|
||||
'status': 'Active',
|
||||
'date_of_joining': '2011-01-01'
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
l_all = Document(
|
||||
fielddata = {
|
||||
'doctype' : 'Leave Allocation',
|
||||
'name': 'l_all',
|
||||
'employee' : 'emp1',
|
||||
'leave_type' : 'Casual Leave',
|
||||
'posting_date': '2011-03-01',
|
||||
'fiscal_year': '2011-2012',
|
||||
'total_leaves_allocated': 20,
|
||||
'docstatus': 1
|
||||
}
|
||||
)
|
||||
|
||||
l_app1 = Document(
|
||||
fielddata = {
|
||||
'doctype' : 'Leave Application',
|
||||
'name': 'l_app1',
|
||||
'employee' : 'emp1',
|
||||
'leave_type' : 'Casual Leave',
|
||||
'posting_date': '2011-03-01',
|
||||
'fiscal_year': '2011-2012',
|
||||
'from_date': '2011-08-01',
|
||||
'to_date': '2011-08-02',
|
||||
'total_leave_days': 2
|
||||
}
|
||||
)
|
||||
|
||||
l_app2 = Document(
|
||||
fielddata = {
|
||||
'doctype' : 'Leave Application',
|
||||
'name': 'l_app2',
|
||||
'employee' : 'emp1',
|
||||
'leave_type' : 'Casual Leave',
|
||||
'posting_date': '2011-03-01',
|
||||
'fiscal_year': '2011-2012',
|
||||
'from_date': '2011-08-15',
|
||||
'to_date': '2011-08-17',
|
||||
'total_leave_days': 3
|
||||
}
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user