@@ -132,6 +132,7 @@ def test_half_day_compensatory_leave(self):
132
132
def test_request_on_leave_period_boundary (self ):
133
133
frappe .db .delete ("Leave Period" )
134
134
create_leave_period ("2023-01-01" , "2023-12-31" , "_Test Company" )
135
+ create_holiday_list ("2023-01-01" , "2023-12-31" )
135
136
136
137
employee = get_employee ()
137
138
boundary_date = "2023-12-31"
@@ -149,9 +150,11 @@ def test_request_on_leave_period_boundary(self):
149
150
reason = "test" ,
150
151
)
151
152
)
153
+ compensatory_leave_request .insert ()
152
154
self .assertRaises (frappe .ValidationError , compensatory_leave_request .submit )
153
155
154
- create_leave_period ("2023-01-01" , "2023-12-31" , "_Test Company" )
156
+ create_leave_period ("2024-01-01" , "2024-12-31" , "_Test Company" )
157
+ compensatory_leave_request .reload ()
155
158
compensatory_leave_request .submit ()
156
159
157
160
@@ -195,20 +198,27 @@ def mark_attendance(employee, date=None, status="Present"):
195
198
attendance .submit ()
196
199
197
200
198
- def create_holiday_list ():
199
- if frappe .db .exists ("Holiday List" , "_Test Compensatory Leave" ):
200
- return
201
+ def create_holiday_list (from_date = None , to_date = None ):
202
+ list_name = "_Test Compensatory Leave"
203
+ if frappe .db .exists ("Holiday List" , list_name ):
204
+ frappe .db .delete ("Holiday List" , list_name )
205
+ frappe .db .delete ("Holiday" , {"parent" : list_name })
206
+
207
+ if from_date :
208
+ holiday_date = add_days (from_date , 1 )
209
+ else :
210
+ holiday_date = today ()
201
211
202
212
holiday_list = frappe .get_doc (
203
213
{
204
214
"doctype" : "Holiday List" ,
205
- "from_date" : add_months (today (), - 3 ),
206
- "to_date" : add_months (today (), 3 ),
215
+ "from_date" : from_date or add_months (today (), - 3 ),
216
+ "to_date" : to_date or add_months (today (), 3 ),
207
217
"holidays" : [
208
- {"description" : "Test Holiday" , "holiday_date" : today () },
209
- {"description" : "Test Holiday 1" , "holiday_date" : add_days (today () , - 1 )},
218
+ {"description" : "Test Holiday" , "holiday_date" : holiday_date },
219
+ {"description" : "Test Holiday 1" , "holiday_date" : add_days (holiday_date , - 1 )},
210
220
],
211
- "holiday_list_name" : "_Test Compensatory Leave" ,
221
+ "holiday_list_name" : list_name ,
212
222
}
213
223
)
214
224
holiday_list .save ()
0 commit comments