Coverage for benefits/enrollment/context/flow.py: 100%

34 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-04-22 21:13 +0000

1from dataclasses import dataclass, asdict 

2from typing import Optional 

3 

4from benefits.core.context import AgencySlug, SystemName, formatted_gettext_lazy as _ 

5 

6 

7@dataclass 

8class EnrollmentIndex: 

9 headline: str 

10 next_step: str 

11 partner_post_link: str 

12 alert_include: Optional[str] = "" 

13 

14 def dict(self): 

15 return asdict(self) 

16 

17 

18class DefaultEnrollmentIndex(EnrollmentIndex): 

19 def __init__( 

20 self, 

21 headline=_("Your eligibility is confirmed! You’re almost there."), 

22 next_step=_("The next step is to enroll the contactless card you will use to tap to ride for a reduced fare."), 

23 partner_post_link=_(", to enter your contactless card details."), 

24 alert_include="", 

25 ): 

26 super().__init__( 

27 headline=headline, next_step=next_step, partner_post_link=partner_post_link, alert_include=alert_include 

28 ) 

29 

30 

31class AgencyCardEnrollmentIndex(DefaultEnrollmentIndex): 

32 def __init__(self): 

33 super().__init__(headline=_("We found your record! Now let’s enroll your contactless card.")) 

34 

35 

36class CalFreshEnrollmentIndex(DefaultEnrollmentIndex): 

37 def __init__(self): 

38 super().__init__( 

39 next_step=_("The next step is to connect your contactless card to your transit benefit"), 

40 partner_post_link=".", 

41 alert_include="enrollment/includes/alert-box--warning--calfresh.html", 

42 ) 

43 

44 

45enrollment_index = { 

46 SystemName.AGENCY_CARD: AgencyCardEnrollmentIndex(), 

47 SystemName.COURTESY_CARD: AgencyCardEnrollmentIndex(), 

48 SystemName.REDUCED_FARE_MOBILITY_ID: AgencyCardEnrollmentIndex(), 

49 SystemName.CALFRESH: CalFreshEnrollmentIndex(), 

50} 

51 

52 

53@dataclass 

54class EnrollmentSuccess: 

55 success_message: str 

56 thank_you_message: str 

57 

58 def dict(self): 

59 return asdict(self) 

60 

61 

62class DefaultEnrollmentSuccess(EnrollmentSuccess): 

63 def __init__(self, transportation_type): 

64 super().__init__( 

65 success_message=_( 

66 "You were not charged anything today. When boarding {transportation_type}, tap your contactless card and you " 

67 "will be charged a reduced fare. You will need to re-enroll if you choose to change the card you use to " 

68 "pay for transit service.", 

69 transportation_type=transportation_type, 

70 ), 

71 thank_you_message=_("Thank you for using Cal-ITP Benefits!"), 

72 ) 

73 

74 

75class AgencyCardEnrollmentSuccess(EnrollmentSuccess): 

76 def __init__(self, transit_benefit, transportation_type): 

77 super().__init__( 

78 success_message=_( 

79 "Your contactless card is now enrolled in {transit_benefit}. When boarding {transportation_type}, tap this " 

80 "card and you will be charged a reduced fare. You will need to re-enroll if you choose to change the card you " 

81 "use to pay for transit service.", 

82 transit_benefit=transit_benefit, 

83 transportation_type=transportation_type, 

84 ), 

85 thank_you_message=_("You were not charged anything today. Thank you for using Cal-ITP Benefits!"), 

86 ) 

87 

88 

89enrollment_success = { 

90 AgencySlug.CST.value: DefaultEnrollmentSuccess( 

91 transportation_type=_("a CST bus"), 

92 ), 

93 SystemName.AGENCY_CARD.value: AgencyCardEnrollmentSuccess( 

94 transit_benefit=_("a CST Agency Card transit benefit"), transportation_type=_("a CST bus") 

95 ), 

96 AgencySlug.MST.value: DefaultEnrollmentSuccess(transportation_type=_("an MST bus")), 

97 SystemName.COURTESY_CARD.value: AgencyCardEnrollmentSuccess( 

98 transit_benefit=_("an MST Courtesy Card transit benefit"), transportation_type="an MST bus" 

99 ), 

100 AgencySlug.SACRT.value: DefaultEnrollmentSuccess(transportation_type=_("a SacRT bus")), 

101 AgencySlug.SBMTD.value: DefaultEnrollmentSuccess(transportation_type=_("an SBMTD bus")), 

102 SystemName.REDUCED_FARE_MOBILITY_ID.value: AgencyCardEnrollmentSuccess( 

103 transit_benefit=_("an SBMTD Reduced Fare Mobility ID transit benefit"), transportation_type=_("an SBMTD bus") 

104 ), 

105 AgencySlug.NEVCO.value: DefaultEnrollmentSuccess(transportation_type=_("a Nevada County Connects bus")), 

106}