Coverage for benefits/routes.py: 100%
98 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 cdt_identity.routes import Routes as OAuthRoutes
4class Routes:
5 """Django routes in the form of `app:name` for the Benefits application."""
7 @property
8 def INDEX(self):
9 """Entry point to the app."""
10 return "core:index"
12 @property
13 def HELP(self):
14 """Application help page."""
15 return "core:help"
17 @property
18 def LOGGED_OUT(self):
19 """The user has logged out of OAuth for claims verification."""
20 return "core:logged_out"
22 @property
23 def SERVER_ERROR(self):
24 """Generic 500 handler."""
25 return "core:server_error"
27 @property
28 def AGENCY_INDEX(self):
29 """The landing page for an agency."""
30 return "core:agency_index"
32 @property
33 def AGENCY_CARD(self):
34 """Agency card flow redirect for an agency."""
35 return "core:agency_card"
37 @property
38 def AGENCY_ELIGIBILITY_INDEX(self):
39 """The user picks a flow and a transit agency is configured for them."""
40 return "core:agency_eligibility_index"
42 @property
43 def AGENCY_PUBLIC_KEY(self):
44 """Agency's eligibility API public key."""
45 return "core:agency_public_key"
47 @property
48 def OAUTH_LOGIN(self):
49 """Start of the identity proofing phase for claims verification."""
50 return OAuthRoutes.route_login
52 @property
53 def OAUTH_LOGOUT(self):
54 """OAuth initiate logout."""
55 return OAuthRoutes.route_logout
57 @property
58 def OAUTH_SYSTEM_ERROR(self):
59 """OAuth error not caused by the user."""
60 return OAuthRoutes.route("system_error")
62 @property
63 def ELIGIBILITY_INDEX(self):
64 """Start of eligibility phase, the user picks a flow."""
65 return "eligibility:index"
67 @property
68 def ELIGIBILITY_START(self):
69 """Flow-specific eligibility information."""
70 return "eligibility:start"
72 @property
73 def ELIGIBILITY_CONFIRM(self):
74 """Agency card specific eligibility form."""
75 return "eligibility:confirm"
77 @property
78 def ELIGIBILITY_UNVERIFIED(self):
79 """The user's eligibility was not verified."""
80 return "eligibility:unverified"
82 @property
83 def ENROLLMENT_INDEX(self):
84 """Start of the enrollment phase."""
85 return "enrollment:index"
87 @property
88 def ENROLLMENT_TOKEN(self):
89 """Acquire a TransitProcessor API token for enrollment."""
90 return "enrollment:token"
92 @property
93 def ENROLLMENT_SUCCESS(self):
94 """User has successfully enrolled and completed a Benefits flow."""
95 return "enrollment:success"
97 @property
98 def ENROLLMENT_RETRY(self):
99 """User entered their card details incorrectly or another recoverable problem."""
100 return "enrollment:retry"
102 @property
103 def ENROLLMENT_REENROLLMENT_ERROR(self):
104 """User tried to enroll when they are already enrolled in an expiring discount."""
105 return "enrollment:reenrollment_error"
107 @property
108 def ENROLLMENT_SYSTEM_ERROR(self):
109 """Enrollment error not caused by the user."""
110 return "enrollment:system_error"
112 @property
113 def ADMIN_INDEX(self):
114 """Admin index page"""
115 return "admin:index"
117 @property
118 def IN_PERSON_ELIGIBILITY(self):
119 """In-person (e.g. agency assisted) eligibility"""
120 return "in_person:eligibility"
122 @property
123 def IN_PERSON_ENROLLMENT(self):
124 """In-person (e.g. agency assisted) enrollment"""
125 return "in_person:enrollment"
127 @property
128 def IN_PERSON_ENROLLMENT_TOKEN(self):
129 """Acquire a TransitProcessor API token for in-person enrollment."""
130 return "in_person:token"
132 @property
133 def IN_PERSON_SERVER_ERROR(self):
134 """Generic error handler for the in_person app."""
135 return "in_person:error"
137 @property
138 def IN_PERSON_ENROLLMENT_RETRY(self):
139 """In-person user entered their card details incorrectly or another recoverable problem."""
140 return "in_person:retry"
142 @property
143 def IN_PERSON_ENROLLMENT_REENROLLMENT_ERROR(self):
144 """In-person user tried to enroll when they are already enrolled in an expiring discount."""
145 return "in_person:reenrollment_error"
147 @property
148 def IN_PERSON_ENROLLMENT_SUCCESS(self):
149 """Successful in-person enrollment"""
150 return "in_person:success"
152 @property
153 def IN_PERSON_ENROLLMENT_SYSTEM_ERROR(self):
154 """Enrollment error not caused by the user during in-person enrollment."""
155 return "in_person:system_error"
157 def to_dict(self) -> dict[str, str]:
158 """Get a mapping of property name --> value for each `@property` in the Routes collection."""
159 return {prop: str(getattr(self, prop)) for prop in dir(Routes) if isinstance(getattr(Routes, prop), property)}
161 @staticmethod
162 def name(route: str) -> str:
163 """Returns just the name portion of the app:name structure of the route."""
164 return route.split(":")[-1]
167routes = Routes()