raise holiday block list exception only when submitting
diff --git a/hr/doctype/employee/test_employee.py b/hr/doctype/employee/test_employee.py
index a9c715b..01c2087 100644
--- a/hr/doctype/employee/test_employee.py
+++ b/hr/doctype/employee/test_employee.py
@@ -7,7 +7,7 @@
"gender": "Female",
"status": "Active",
"company": "_Test Company",
- "user_id": "test@erpnext.com"
+ "user_id": "test@example.com"
}],
[{
"doctype":"Employee",
@@ -18,5 +18,17 @@
"gender": "Male",
"status": "Active",
"company": "_Test Company",
- "user_id": "test1@erpnext.com"
-}]]
\ No newline at end of file
+ "user_id": "test1@example.com"
+}],
+[{
+ "doctype":"Employee",
+ "employee_name": "_Test Employee 2",
+ "naming_series": "_T-Employee-",
+ "date_of_joining": "2010-01-01",
+ "date_of_birth": "1980-01-01",
+ "gender": "Male",
+ "status": "Active",
+ "company": "_Test Company",
+ "user_id": "test2@example.com"
+}]
+]
\ No newline at end of file
diff --git a/hr/doctype/holiday_block_list/test_holiday_block_list.py b/hr/doctype/holiday_block_list/test_holiday_block_list.py
index 5ec4dd1..e9f3b78 100644
--- a/hr/doctype/holiday_block_list/test_holiday_block_list.py
+++ b/hr/doctype/holiday_block_list/test_holiday_block_list.py
@@ -15,6 +15,6 @@
"parent": "_Test Holiday Block List",
"parenttype": "Holiday Block List",
"parentfield": "holiday_block_list_allowed",
- "allow_user": "test1@erpnext.com",
+ "allow_user": "test1@example.com",
}
]]
\ No newline at end of file
diff --git a/hr/doctype/leave_application/test_leave_application.py b/hr/doctype/leave_application/test_leave_application.py
index 8fe11d6..cd74d01 100644
--- a/hr/doctype/leave_application/test_leave_application.py
+++ b/hr/doctype/leave_application/test_leave_application.py
@@ -4,8 +4,8 @@
from hr.doctype.leave_application.leave_application import LeaveDayBlockedError
class TestLeaveApplication(unittest.TestCase):
- def get_application(self):
- application = webnotes.model_wrapper(test_records[1])
+ def get_application(self, doclist):
+ application = webnotes.model_wrapper(doclist)
application.doc.from_date = "2013-01-01"
application.doc.to_date = "2013-01-05"
return application
@@ -15,25 +15,37 @@
webnotes.conn.set_value("Employee", "_T-Employee-0001", "department",
"_Test Department with Block List")
- application = self.get_application()
- self.assertRaises(LeaveDayBlockedError, application.insert)
+ application = self.get_application(test_records[1])
+ application.insert()
+ self.assertRaises(LeaveDayBlockedError, application.submit)
- webnotes.session.user = "test1@erpnext.com"
+ webnotes.session.user = "test1@example.com"
from webnotes.profile import add_role
- add_role("test1@erpnext.com", "HR User")
+ add_role("test1@example.com", "HR User")
+ application = self.get_application(test_records[1])
self.assertTrue(application.insert())
def test_global_block_list(self):
- application = self.get_application()
+ application = self.get_application(test_records[3])
+ application.doc.leave_approver = "test@example.com"
webnotes.conn.set_value("Holiday Block List", "_Test Holiday Block List",
"applies_to_all_departments", 1)
- webnotes.conn.set_value("Employee", "_T-Employee-0001", "department",
+ webnotes.conn.set_value("Employee", "_T-Employee-0002", "department",
"_Test Department")
- webnotes.session.user = "test@erpnext.com"
+
+ webnotes.session.user = "test2@example.com"
+ from webnotes.profile import add_role
+ add_role("test2@example.com", "Employee")
- self.assertRaises(LeaveDayBlockedError, application.insert)
+ application.insert()
+
+ webnotes.session.user = "test@example.com"
+ from webnotes.profile import add_role
+ add_role("test@example.com", "Leave Approver")
+
+ self.assertRaises(LeaveDayBlockedError, application.submit)
test_records = [
[{
@@ -53,4 +65,23 @@
"fiscal_year": "_Test Fiscal Year 2013",
"employee": "_T-Employee-0001",
"company": "_Test Company"
- }]]
+ }],
+ [{
+ "doctype": "Leave Allocation",
+ "leave_type": "_Test Leave Type",
+ "fiscal_year": "_Test Fiscal Year 2013",
+ "employee":"_T-Employee-0002",
+ "new_leaves_allocated": 15,
+ "docstatus": 1
+ }],
+ [{
+ "doctype": "Leave Application",
+ "leave_type": "_Test Leave Type",
+ "from_date": "2013-05-01",
+ "to_date": "2013-05-05",
+ "posting_date": "2013-01-02",
+ "fiscal_year": "_Test Fiscal Year 2013",
+ "employee": "_T-Employee-0002",
+ "company": "_Test Company"
+ }]
+]