test: shift assignment
diff --git a/erpnext/hr/doctype/shift_assignment/test_shift_assignment.py b/erpnext/hr/doctype/shift_assignment/test_shift_assignment.py
index 7fe80a2..4c3c1ed 100644
--- a/erpnext/hr/doctype/shift_assignment/test_shift_assignment.py
+++ b/erpnext/hr/doctype/shift_assignment/test_shift_assignment.py
@@ -5,7 +5,7 @@
import frappe
import unittest
-from frappe.utils import nowdate
+from frappe.utils import nowdate, add_days
test_dependencies = ["Shift Type"]
@@ -20,8 +20,61 @@
"shift_type": "Day Shift",
"company": "_Test Company",
"employee": "_T-Employee-00001",
- "date": nowdate()
+ "start_date": nowdate()
}).insert()
shift_assignment.submit()
self.assertEqual(shift_assignment.docstatus, 1)
+
+ def test_overlapping_for_ongoing_shift(self):
+ # shift should be Ongoing if Only start_date is present and status = Active
+
+ shift_assignment_1 = frappe.get_doc({
+ "doctype": "Shift Assignment",
+ "shift_type": "Day Shift",
+ "company": "_Test Company",
+ "employee": "_T-Employee-00001",
+ "start_date": nowdate(),
+ "status": 'Active'
+ }).insert()
+ shift_assignment_1.submit()
+
+ self.assertEqual(shift_assignment_1.docstatus, 1)
+
+ shift_assignment = frappe.get_doc({
+ "doctype": "Shift Assignment",
+ "shift_type": "Day Shift",
+ "company": "_Test Company",
+ "employee": "_T-Employee-00001",
+ "start_date": add_days(nowdate(), 2)
+ })
+
+ self.assertRaises(frappe.ValidationError, shift_assignment.save)
+
+ def test_overlapping_for_fixed_period_shift(self):
+ # shift should is for Fixed period if Only start_date and end_date both are present and status = Active
+
+ shift_assignment_1 = frappe.get_doc({
+ "doctype": "Shift Assignment",
+ "shift_type": "Day Shift",
+ "company": "_Test Company",
+ "employee": "_T-Employee-00001",
+ "start_date": nowdate(),
+ "end_date": add_days(nowdate(), 30),
+ "status": 'Active'
+ }).insert()
+ shift_assignment_1.submit()
+
+
+ # it should not allowed within period of any shift.
+ shift_assignment_3 = frappe.get_doc({
+ "doctype": "Shift Assignment",
+ "shift_type": "Day Shift",
+ "company": "_Test Company",
+ "employee": "_T-Employee-00001",
+ "start_date":add_days(nowdate(), 10),
+ "end_date": add_days(nowdate(), 35),
+ "status": 'Active'
+ })
+
+ self.assertRaises(frappe.ValidationError, shift_assignment_3.save)
\ No newline at end of file