Coverage for benefits / routes.py: 100%

119 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-01 15:39 +0000

1from cdt_identity.routes import Routes as OAuthRoutes 

2 

3 

4class Routes: 

5 """Django routes in the form of `app:name` for the Benefits application.""" 

6 

7 @property 

8 def INDEX(self): 

9 """Entry point to the app.""" 

10 return "core:index" 

11 

12 @property 

13 def HELP(self): 

14 """Application help page.""" 

15 return "core:help" 

16 

17 @property 

18 def LOGGED_OUT(self): 

19 """The user has logged out of OAuth for claims verification.""" 

20 return "core:logged_out" 

21 

22 @property 

23 def SERVER_ERROR(self): 

24 """Generic 500 handler.""" 

25 return "core:server_error" 

26 

27 @property 

28 def AGENCY_INDEX(self): 

29 """The landing page for an agency.""" 

30 return "core:agency_index" 

31 

32 @property 

33 def AGENCY_CARD(self): 

34 """Agency card flow redirect for an agency.""" 

35 return "core:agency_card" 

36 

37 @property 

38 def AGENCY_PUBLIC_KEY(self): 

39 """Agency's eligibility API public key.""" 

40 return "core:agency_public_key" 

41 

42 @property 

43 def OAUTH_LOGIN(self): 

44 """Start of the identity proofing phase for claims verification.""" 

45 return OAuthRoutes.route_login 

46 

47 @property 

48 def OAUTH_LOGOUT(self): 

49 """OAuth initiate logout.""" 

50 return OAuthRoutes.route_logout 

51 

52 @property 

53 def OAUTH_SYSTEM_ERROR(self): 

54 """OAuth error not caused by the user.""" 

55 return OAuthRoutes.route("system_error") 

56 

57 @property 

58 def ADDITIONAL_AGENCIES(self): 

59 """For agencies that participate in a group, user acknowledges bulk enrollment.""" 

60 return "core:additional-agencies" 

61 

62 @property 

63 def ELIGIBILITY_INDEX(self): 

64 """Start of eligibility phase, the user picks a flow.""" 

65 return "eligibility:index" 

66 

67 @property 

68 def ELIGIBILITY_START(self): 

69 """Flow-specific eligibility information.""" 

70 return "eligibility:start" 

71 

72 @property 

73 def ELIGIBILITY_CONFIRM(self): 

74 """Agency card specific eligibility form.""" 

75 return "eligibility:confirm" 

76 

77 @property 

78 def ELIGIBILITY_UNVERIFIED(self): 

79 """The user's eligibility was not verified.""" 

80 return "eligibility:unverified" 

81 

82 @property 

83 def ENROLLMENT_INDEX(self): 

84 """Start of the enrollment phase.""" 

85 return "enrollment:index" 

86 

87 @property 

88 def ENROLLMENT_LITTLEPAY_INDEX(self): 

89 """Start of the enrollment phase, using Littlepay.""" 

90 return "littlepay:index" 

91 

92 @property 

93 def ENROLLMENT_LITTLEPAY_TOKEN(self): 

94 """Acquire a Littlepay card tokenization access token for enrollment.""" 

95 return "littlepay:token" 

96 

97 @property 

98 def ENROLLMENT_SWITCHIO_INDEX(self): 

99 """Start of the enrollment phase, using Switchio.""" 

100 return "switchio:index" 

101 

102 @property 

103 def ENROLLMENT_SWITCHIO_GATEWAY_URL(self): 

104 """Establish a registration request and receive back a tokenization gateway URL.""" 

105 return "switchio:gateway_url" 

106 

107 @property 

108 def ENROLLMENT_SUCCESS(self): 

109 """User has successfully enrolled and completed a Benefits flow.""" 

110 return "enrollment:success" 

111 

112 @property 

113 def ENROLLMENT_RETRY(self): 

114 """User entered their card details incorrectly or another recoverable problem.""" 

115 return "enrollment:retry" 

116 

117 @property 

118 def ENROLLMENT_REENROLLMENT_ERROR(self): 

119 """User tried to enroll when they are already enrolled in an expiring discount.""" 

120 return "enrollment:reenrollment_error" 

121 

122 @property 

123 def ENROLLMENT_SYSTEM_ERROR(self): 

124 """Enrollment error not caused by the user.""" 

125 return "enrollment:system_error" 

126 

127 @property 

128 def ADMIN_INDEX(self): 

129 """Admin index page""" 

130 return "admin:index" 

131 

132 @property 

133 def IN_PERSON_ADDITIONAL_AGENCIES(self): 

134 """In-person (e.g. agency assisted) additional agencies prompt""" 

135 return "in_person:additional_agencies" 

136 

137 @property 

138 def IN_PERSON_ELIGIBILITY(self): 

139 """In-person (e.g. agency assisted) eligibility""" 

140 return "in_person:eligibility" 

141 

142 @property 

143 def IN_PERSON_ENROLLMENT(self): 

144 """In-person (e.g. agency assisted) enrollment""" 

145 return "in_person:enrollment" 

146 

147 @property 

148 def IN_PERSON_ENROLLMENT_LITTLEPAY_INDEX(self): 

149 """In-person (e.g. agency assisted) enrollment using Littlepay""" 

150 return "in_person:enrollment_littlepay_index" 

151 

152 @property 

153 def IN_PERSON_ENROLLMENT_SWITCHIO_INDEX(self): 

154 """In-person (e.g. agency assisted) enrollment using Switchio""" 

155 return "in_person:enrollment_switchio_index" 

156 

157 @property 

158 def IN_PERSON_ENROLLMENT_LITTLEPAY_TOKEN(self): 

159 """Acquire a Littlepay access token for in-person enrollment.""" 

160 return "in_person:enrollment_littlepay_token" 

161 

162 @property 

163 def IN_PERSON_ENROLLMENT_SWITCHIO_GATEWAY_URL(self): 

164 """Switchio Gateway for in-person (e.g. agency assisted) enrollment""" 

165 return "in_person:enrollment_switchio_gateway" 

166 

167 @property 

168 def IN_PERSON_SERVER_ERROR(self): 

169 """Generic error handler for the in_person app.""" 

170 return "in_person:error" 

171 

172 @property 

173 def IN_PERSON_ENROLLMENT_RETRY(self): 

174 """In-person user entered their card details incorrectly or another recoverable problem.""" 

175 return "in_person:retry" 

176 

177 @property 

178 def IN_PERSON_ENROLLMENT_REENROLLMENT_ERROR(self): 

179 """In-person user tried to enroll when they are already enrolled in an expiring discount.""" 

180 return "in_person:reenrollment_error" 

181 

182 @property 

183 def IN_PERSON_ENROLLMENT_SUCCESS(self): 

184 """Successful in-person enrollment""" 

185 return "in_person:success" 

186 

187 @property 

188 def IN_PERSON_ENROLLMENT_SYSTEM_ERROR(self): 

189 """Enrollment error not caused by the user during in-person enrollment.""" 

190 return "in_person:system_error" 

191 

192 def to_dict(self) -> dict[str, str]: 

193 """Get a mapping of property name --> value for each `@property` in the Routes collection.""" 

194 return {prop: str(getattr(self, prop)) for prop in dir(Routes) if isinstance(getattr(Routes, prop), property)} 

195 

196 @staticmethod 

197 def name(route: str) -> str: 

198 """Returns just the name portion of the app:name structure of the route.""" 

199 return route.split(":")[-1] 

200 

201 

202routes = Routes()