Coverage for benefits/eligibility/context/flow.py: 100%
37 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-22 21:13 +0000
« 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
4from benefits.core.context import formatted_gettext_lazy as _, SystemName
5from benefits.routes import routes
8@dataclass
9class CTAButton:
10 text: str
11 route: str
12 fallback_text: Optional[str] = None
13 extra_classes: Optional[str] = None
16@dataclass
17class EligibilityStart:
18 page_title: str
19 headline_text: str
20 call_to_action_button: CTAButton
21 eligibility_item_headline: Optional[str] = None
22 eligibility_item_body: Optional[str] = None
24 def dict(self):
25 return asdict(self)
28class LoginGovEligibilityStart(EligibilityStart):
29 def __init__(self, page_title, headline_text):
30 super().__init__(
31 page_title=page_title,
32 headline_text=headline_text,
33 call_to_action_button=CTAButton(
34 text=_("Get started with"),
35 fallback_text="Login.gov",
36 route=routes.OAUTH_LOGIN,
37 extra_classes="login",
38 ),
39 )
42class AgencyCardEligibilityStart(EligibilityStart):
43 def __init__(self, headline_text, eligibility_item_headline, eligibility_item_body):
44 super().__init__(
45 page_title=_("Agency card overview"),
46 headline_text=headline_text,
47 eligibility_item_headline=eligibility_item_headline,
48 eligibility_item_body=eligibility_item_body,
49 call_to_action_button=CTAButton(text=_("Continue"), route=routes.ELIGIBILITY_CONFIRM),
50 )
53eligibility_start = {
54 SystemName.AGENCY_CARD.value: AgencyCardEligibilityStart(
55 headline_text=_("You selected an Agency Card transit benefit."),
56 eligibility_item_headline=_("Your current Agency Card number"),
57 eligibility_item_body=_(
58 "You do not need to have your physical CST Agency Card, but you will need to know the number."
59 ),
60 ),
61 SystemName.CALFRESH.value: LoginGovEligibilityStart(
62 page_title=_("CalFresh benefit overview"),
63 headline_text=_("You selected a CalFresh Cardholder transit benefit."),
64 ),
65 SystemName.COURTESY_CARD.value: AgencyCardEligibilityStart(
66 headline_text=_("You selected a Courtesy Card transit benefit."),
67 eligibility_item_headline=_("Your current Courtesy Card number"),
68 eligibility_item_body=_(
69 "You do not need to have your physical MST Courtesy Card, but you will need to know the number."
70 ),
71 ),
72 SystemName.MEDICARE.value: EligibilityStart(
73 page_title=_("Medicare benefit overview"),
74 headline_text=_("You selected a Medicare Cardholder transit benefit."),
75 eligibility_item_headline=_("An online account with Medicare.gov"),
76 eligibility_item_body=_(
77 "If you do not have an account you will be able to create one using your red, white, and blue Medicare card. "
78 "We use your Medicare.gov account to verify you qualify."
79 ),
80 call_to_action_button=CTAButton(text=_("Continue to Medicare.gov"), route=routes.OAUTH_LOGIN),
81 ),
82 SystemName.OLDER_ADULT.value: LoginGovEligibilityStart(
83 page_title=_("Older Adult benefit overview"),
84 headline_text=_("You selected an Older Adult transit benefit."),
85 ),
86 SystemName.REDUCED_FARE_MOBILITY_ID.value: AgencyCardEligibilityStart(
87 headline_text=_("You selected a Reduced Fare Mobility ID transit benefit."),
88 eligibility_item_headline=_("Your current Reduced Fare Mobility ID number"),
89 eligibility_item_body=_("You do not need to have your physical card, but you will need to know the number."),
90 ),
91 SystemName.VETERAN.value: LoginGovEligibilityStart(
92 page_title=_("Veterans benefit overview"),
93 headline_text=_("You selected a Veteran transit benefit."),
94 ),
95}
98@dataclass
99class EligibilityUnverified:
100 headline_text: str
101 body_text: str
102 button_text: str
104 def dict(self):
105 return asdict(self)
108class AgencyCardEligibilityUnverified(EligibilityUnverified):
109 def __init__(self, agency_card):
110 super().__init__(
111 headline_text=_("Your card information may not have been entered correctly."),
112 body_text=_(
113 "The number and last name must be entered exactly as they appear on your {agency_card}. "
114 "Please check your card and try again, or contact your transit agency for help.",
115 agency_card=agency_card,
116 ),
117 button_text=_("Try again"),
118 )
121eligibility_unverified = {
122 SystemName.AGENCY_CARD.value: AgencyCardEligibilityUnverified(agency_card=_("CST Agency Card")),
123 SystemName.COURTESY_CARD.value: AgencyCardEligibilityUnverified(agency_card=_("MST Courtesy Card")),
124 SystemName.REDUCED_FARE_MOBILITY_ID.value: AgencyCardEligibilityUnverified(
125 agency_card=_("SBMTD Reduced Fare Mobility ID card")
126 ),
127}