Rushabh Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 1 | # ERPNext - web based ERP (http://erpnext.com) |
| 2 | # Copyright (C) 2012 Web Notes Technologies Pvt Ltd |
| 3 | # |
| 4 | # This program is free software: you can redistribute it and/or modify |
| 5 | # it under the terms of the GNU General Public License as published by |
| 6 | # the Free Software Foundation, either version 3 of the License, or |
| 7 | # (at your option) any later version. |
| 8 | # |
| 9 | # This program is distributed in the hope that it will be useful, |
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | # GNU General Public License for more details. |
| 13 | # |
| 14 | # You should have received a copy of the GNU General Public License |
| 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | |
Anand Doshi | 486f9df | 2012-07-19 13:40:31 +0530 | [diff] [blame] | 17 | from __future__ import unicode_literals |
Nabin Hait | a6f0550 | 2011-10-12 17:04:31 +0530 | [diff] [blame] | 18 | import unittest |
| 19 | |
| 20 | import webnotes |
| 21 | import webnotes.profile |
| 22 | webnotes.user = webnotes.profile.Profile() |
| 23 | |
| 24 | |
| 25 | from webnotes.model.doc import Document |
| 26 | from webnotes.model.code import get_obj |
| 27 | from webnotes.utils import cstr, flt |
| 28 | from webnotes.model.doclist import getlist |
| 29 | sql = webnotes.conn.sql |
| 30 | |
| 31 | from sandbox.testdata import leaves |
| 32 | #---------------------------------------------------------- |
| 33 | |
| 34 | |
| 35 | class TestStockEntry(unittest.TestCase): |
| 36 | #=========================================================================== |
| 37 | def setUp(self): |
| 38 | webnotes.conn.begin() |
| 39 | leaves.emp.save(new = 1, make_autoname = 0) |
| 40 | |
| 41 | def test_leave_bal(self): |
| 42 | leaves.l_all.save(1) |
| 43 | leaves.l_app1.save(1) |
| 44 | leaves.l_app2.save(1) |
| 45 | |
| 46 | la1 = get_obj('Leave Application', leaves.l_app1.name, with_children=1) |
| 47 | la1.validate() |
| 48 | la1.doc.docstatus = 1 |
| 49 | la1.doc.save() |
| 50 | |
| 51 | self.assertTrue(la1.doc.total_leave_days == 2) |
| 52 | |
| 53 | la1.doc.half_day = 1 |
| 54 | la1.validate() |
| 55 | la1.doc.save() |
| 56 | |
| 57 | self.assertTrue(la1.doc.total_leave_days == .5) |
| 58 | |
| 59 | print "Test case for leave applied no of days" |
| 60 | |
| 61 | |
| 62 | la2 = get_obj('Leave Application', leaves.l_app2.name, with_children=1) |
| 63 | la2.validate() |
| 64 | bal = la2.get_leave_balance() |
| 65 | self.assertTrue(bal, 18) |
| 66 | print "Test case for leave balance" |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | def tearDown(self): |
| 72 | webnotes.conn.rollback() |