@@ -419,6 +419,68 @@ def test_records_summary_context__birthdays(
419
419
assert context ["birthday_22nd" ] == formatted_22nd_bday
420
420
421
421
422
+ @pytest .mark .parametrize (
423
+ "dob, formatted_dob, formatted_18th_bday, formatted_22nd_bday" ,
424
+ [
425
+ (date (1986 , 6 , 15 ), "06/15/1986" , "06/15/2004" , "06/15/2008" ),
426
+ # born in leap year
427
+ (date (1996 , 2 , 29 ), "02/29/1996" , "03/01/2014" , "03/01/2018" ),
428
+ ],
429
+ )
430
+ def test_records_summary_context_no_batch_birthday (
431
+ batch , dob , formatted_dob , formatted_18th_bday , formatted_22nd_bday
432
+ ):
433
+ """
434
+ Test generate_context method for a batch that has no date of birth, but client info has
435
+ date of birth, (e.g. for portal imported batches)
436
+ """
437
+
438
+ PETITIONER_INFO_WITH_DOB = {"name" : "Pete Petitioner" , "dob" : dob }
439
+
440
+ offense = create_offense (
441
+ batch , "DURHAM" , DISTRICT_COURT , "10CR000001" , None , "NOT GUILTY" , "JURY TRIAL" , False
442
+ )
443
+ create_offense_record (offense , CHARGED , "SIMPLE ASSAULT" , "MISDEMEANOR" )
444
+
445
+ attorney = AttorneyFactory (name = "E. Toruney" )
446
+ client = ClientFactory (** PETITIONER_INFO_WITH_DOB )
447
+ context = generate_context (batch , attorney , client )
448
+
449
+ assert context ["dob" ] == formatted_dob
450
+ assert context ["birthday_18th" ] == formatted_18th_bday
451
+ assert context ["birthday_22nd" ] == formatted_22nd_bday
452
+
453
+
454
+ def test_records_summary_context_birthdays_discrepancy (batch ):
455
+ """
456
+ Test generate_context method where client date of birth does not match batch date of birth.
457
+ Client date of birth should be used in this case.
458
+ """
459
+
460
+ client_dob , formatted_dob , formatted_18th_bday , formatted_22nd_bday = (
461
+ date (1986 , 6 , 15 ),
462
+ "06/15/1986" ,
463
+ "06/15/2004" ,
464
+ "06/15/2008" ,
465
+ )
466
+ batch_dob = date (1993 , 5 , 22 )
467
+
468
+ PETITIONER_INFO_WITH_DOB = {"name" : "Pete Petitioner" , "dob" : client_dob }
469
+
470
+ offense = create_offense (
471
+ batch , "DURHAM" , DISTRICT_COURT , "10CR000001" , batch_dob , "NOT GUILTY" , "JURY TRIAL" , False
472
+ )
473
+ create_offense_record (offense , CHARGED , "SIMPLE ASSAULT" , "MISDEMEANOR" )
474
+
475
+ attorney = AttorneyFactory (name = "E. Toruney" )
476
+ client = ClientFactory (** PETITIONER_INFO_WITH_DOB )
477
+ context = generate_context (batch , attorney , client )
478
+
479
+ assert context ["dob" ] == formatted_dob
480
+ assert context ["birthday_18th" ] == formatted_18th_bday
481
+ assert context ["birthday_22nd" ] == formatted_22nd_bday
482
+
483
+
422
484
def test_records_summary_context__additional_offenses (batch ):
423
485
"""
424
486
Test generate_context method with many offense records in a table. Check that addl_offense_file_nos in the table has
0 commit comments