@@ -213,3 +213,109 @@ def test_sort_days_of_week():
213213 days_of_week = [1 ] # Tuesday
214214 sorted_days = _sort_days_of_week (days_of_week , 0 )
215215 assert sorted_days == [1 ]
216+
217+
218+ def test_validate_settings_invalid_days_of_week ():
219+ with pytest .raises (ValueError , match = "Invalid value for DaysOfWeek: Thor's Day" ):
220+ validate_settings (
221+ Recurrence (
222+ {
223+ "Pattern" : {
224+ "Type" : "Weekly" ,
225+ "Interval" : 1 ,
226+ "DaysOfWeek" : ["Thor's Day" ],
227+ "FirstDayOfWeek" : "Monday" ,
228+ },
229+ "Range" : valid_no_end_range (),
230+ }
231+ ),
232+ START ,
233+ END ,
234+ )
235+ with pytest .raises (ValueError , match = "Required parameter: Recurrence.Pattern.DaysOfWeek" ):
236+ validate_settings (
237+ Recurrence (
238+ {
239+ "Pattern" : {
240+ "Type" : "Weekly" ,
241+ "Interval" : 1 ,
242+ "DaysOfWeek" : [],
243+ "FirstDayOfWeek" : "Monday" ,
244+ },
245+ "Range" : valid_no_end_range (),
246+ }
247+ ),
248+ START ,
249+ END ,
250+ )
251+
252+
253+ def test_validate_settings_invalid_days_of_week_duplicate ():
254+ with pytest .raises (ValueError , match = "Duplicate day of the week found: Monday" ):
255+ validate_settings (
256+ Recurrence (
257+ {
258+ "Pattern" : {
259+ "Type" : "Weekly" ,
260+ "Interval" : 1 ,
261+ "DaysOfWeek" : ["Monday" , "Monday" ],
262+ "FirstDayOfWeek" : "Monday" ,
263+ },
264+ "Range" : valid_no_end_range (),
265+ }
266+ ),
267+ START ,
268+ END ,
269+ )
270+
271+
272+ def test_validate_settings_invalid_end_date_format ():
273+ with pytest .raises (ValueError , match = "Invalid value for EndDate: invalid-date-format" ):
274+ validate_settings (
275+ Recurrence (
276+ {
277+ "Pattern" : valid_daily_pattern (),
278+ "Range" : {
279+ "Type" : "EndDate" ,
280+ "EndDate" : "invalid-date-format" ,
281+ "NumberOfOccurrences" : 10 ,
282+ },
283+ }
284+ ),
285+ START ,
286+ END ,
287+ )
288+
289+
290+ def test_validate_settings_boundary_condition_ten_years ():
291+ end = START + timedelta (days = 3650 ) # Exactly 10 years
292+ recurrence = Recurrence (
293+ {
294+ "Pattern" : {
295+ "Type" : "Daily" ,
296+ "Interval" : 3651 , # Interval greater than the time window length
297+ "DaysOfWeek" : ["Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday" ],
298+ "FirstDayOfWeek" : "Sunday" ,
299+ },
300+ "Range" : valid_no_end_range (),
301+ }
302+ )
303+ validate_settings (recurrence , START , end )
304+ recurrence = Recurrence (
305+ {
306+ "Pattern" : {
307+ "Type" : "Daily" ,
308+ "Interval" : 3652 , # Interval greater than the time window length
309+ "DaysOfWeek" : ["Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday" ],
310+ "FirstDayOfWeek" : "Sunday" ,
311+ },
312+ "Range" : valid_no_end_range (),
313+ }
314+ )
315+ with pytest .raises (ValueError , match = "Time window duration exceeds ten years: end" ):
316+ validate_settings (recurrence , START , START + timedelta (days = 3652 ))
317+
318+
319+ def test_validate_settings_boundary_condition_interval ():
320+ end = START + timedelta (days = 1 ) # Exactly matches the interval duration for daily recurrence
321+ validate_settings (valid_daily_recurrence (), START , end )
0 commit comments