Coverage for benefits/routes.py: 100%

106 statements  

« prev     ^ index     » next       coverage.py v7.6.7, created at 2024-11-22 18:00 +0000

1class Routes: 

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

3 

4 @property 

5 def INDEX(self): 

6 """Entry point to the app.""" 

7 return "core:index" 

8 

9 @property 

10 def HELP(self): 

11 """Application help page.""" 

12 return "core:help" 

13 

14 @property 

15 def LOGGED_OUT(self): 

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

17 return "core:logged_out" 

18 

19 @property 

20 def SERVER_ERROR(self): 

21 """Generic 500 handler.""" 

22 return "core:server_error" 

23 

24 @property 

25 def AGENCY_INDEX(self): 

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

27 return "core:agency_index" 

28 

29 @property 

30 def AGENCY_CARD(self): 

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

32 return "core:agency_card" 

33 

34 @property 

35 def AGENCY_ELIGIBILITY_INDEX(self): 

36 """The user picks a flow and a transit agency is configured for them.""" 

37 return "core:agency_eligibility_index" 

38 

39 @property 

40 def AGENCY_PUBLIC_KEY(self): 

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

42 return "core:agency_public_key" 

43 

44 @property 

45 def OAUTH_LOGIN(self): 

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

47 return "oauth:login" 

48 

49 @property 

50 def OAUTH_CANCEL(self): 

51 """OAuth cancel login.""" 

52 return "oauth:cancel" 

53 

54 @property 

55 def OAUTH_AUTHORIZE(self): 

56 """OAuth authorize access token for claims verification.""" 

57 return "oauth:authorize" 

58 

59 @property 

60 def OAUTH_LOGOUT(self): 

61 """OAuth initiate logout.""" 

62 return "oauth:logout" 

63 

64 @property 

65 def OAUTH_POST_LOGOUT(self): 

66 """OAuth complete logout.""" 

67 return "oauth:post_logout" 

68 

69 @property 

70 def OAUTH_SYSTEM_ERROR(self): 

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

72 return "oauth:system_error" 

73 

74 @property 

75 def ELIGIBILITY_INDEX(self): 

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

77 return "eligibility:index" 

78 

79 @property 

80 def ELIGIBILITY_START(self): 

81 """Flow-specific eligibility information.""" 

82 return "eligibility:start" 

83 

84 @property 

85 def ELIGIBILITY_CONFIRM(self): 

86 """Agency card specific eligibility form.""" 

87 return "eligibility:confirm" 

88 

89 @property 

90 def ELIGIBILITY_UNVERIFIED(self): 

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

92 return "eligibility:unverified" 

93 

94 @property 

95 def ENROLLMENT_INDEX(self): 

96 """Start of the enrollment phase.""" 

97 return "enrollment:index" 

98 

99 @property 

100 def ENROLLMENT_TOKEN(self): 

101 """Acquire a TransitProcessor API token for enrollment.""" 

102 return "enrollment:token" 

103 

104 @property 

105 def ENROLLMENT_SUCCESS(self): 

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

107 return "enrollment:success" 

108 

109 @property 

110 def ENROLLMENT_RETRY(self): 

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

112 return "enrollment:retry" 

113 

114 @property 

115 def ENROLLMENT_REENROLLMENT_ERROR(self): 

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

117 return "enrollment:reenrollment_error" 

118 

119 @property 

120 def ENROLLMENT_SYSTEM_ERROR(self): 

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

122 return "enrollment:system_error" 

123 

124 @property 

125 def ADMIN_INDEX(self): 

126 """Admin index page""" 

127 return "admin:index" 

128 

129 @property 

130 def IN_PERSON_ELIGIBILITY(self): 

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

132 return "in_person:eligibility" 

133 

134 @property 

135 def IN_PERSON_ENROLLMENT(self): 

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

137 return "in_person:enrollment" 

138 

139 @property 

140 def IN_PERSON_ENROLLMENT_TOKEN(self): 

141 """Acquire a TransitProcessor API token for in-person enrollment.""" 

142 return "in_person:token" 

143 

144 @property 

145 def IN_PERSON_SERVER_ERROR(self): 

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

147 return "in_person:error" 

148 

149 @property 

150 def IN_PERSON_ENROLLMENT_RETRY(self): 

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

152 return "in_person:retry" 

153 

154 @property 

155 def IN_PERSON_ENROLLMENT_REENROLLMENT_ERROR(self): 

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

157 return "in_person:reenrollment_error" 

158 

159 @property 

160 def IN_PERSON_ENROLLMENT_SUCCESS(self): 

161 """Successful in-person enrollment""" 

162 return "in_person:success" 

163 

164 @property 

165 def IN_PERSON_ENROLLMENT_SYSTEM_ERROR(self): 

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

167 return "in_person:system_error" 

168 

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

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

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

172 

173 @staticmethod 

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

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

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

177 

178 

179routes = Routes()