Nabin Hait | a6f0550 | 2011-10-12 17:04:31 +0530 | [diff] [blame] | 1 | import unittest |
| 2 | |
| 3 | import webnotes |
| 4 | import webnotes.profile |
| 5 | webnotes.user = webnotes.profile.Profile() |
| 6 | |
| 7 | |
| 8 | from webnotes.model.doc import Document |
| 9 | from webnotes.model.code import get_obj |
| 10 | from webnotes.utils import cstr, flt |
| 11 | from webnotes.model.doclist import getlist |
| 12 | sql = webnotes.conn.sql |
| 13 | |
| 14 | from sandbox.testdata import leaves |
| 15 | #---------------------------------------------------------- |
| 16 | |
| 17 | |
| 18 | class TestStockEntry(unittest.TestCase): |
| 19 | #=========================================================================== |
| 20 | def setUp(self): |
| 21 | webnotes.conn.begin() |
| 22 | leaves.emp.save(new = 1, make_autoname = 0) |
| 23 | |
| 24 | def test_leave_bal(self): |
| 25 | leaves.l_all.save(1) |
| 26 | leaves.l_app1.save(1) |
| 27 | leaves.l_app2.save(1) |
| 28 | |
| 29 | la1 = get_obj('Leave Application', leaves.l_app1.name, with_children=1) |
| 30 | la1.validate() |
| 31 | la1.doc.docstatus = 1 |
| 32 | la1.doc.save() |
| 33 | |
| 34 | self.assertTrue(la1.doc.total_leave_days == 2) |
| 35 | |
| 36 | la1.doc.half_day = 1 |
| 37 | la1.validate() |
| 38 | la1.doc.save() |
| 39 | |
| 40 | self.assertTrue(la1.doc.total_leave_days == .5) |
| 41 | |
| 42 | print "Test case for leave applied no of days" |
| 43 | |
| 44 | |
| 45 | la2 = get_obj('Leave Application', leaves.l_app2.name, with_children=1) |
| 46 | la2.validate() |
| 47 | bal = la2.get_leave_balance() |
| 48 | self.assertTrue(bal, 18) |
| 49 | print "Test case for leave balance" |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | def tearDown(self): |
| 55 | webnotes.conn.rollback() |