Coverage for benefits/enrollment/forms.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.17.5, created at 2026-11-23 20:53 +0000

1""" 

2The enrollment application: Form definitions for results from Hosted Card Verification Flow. 

3""" 

4 

5from django import forms 

6 

7from benefits.core.mixins import ValidateRecaptchaMixin 

8 

9 

10class CardTokenizeSuccessForm(forms.Form): 

11 """Form to bring client card token back to server.""" 

12 

13 id = "form-card-tokenize-success" 

14 method = "POST" 

15 

16 def __init__(self, data=None, action_url=None, *args, **kwargs): 

17 super().__init__(data, *args, **kwargs) 

18 self.action_url = action_url 

19 

20 # hidden input with no label 

21 card_token = forms.CharField(widget=forms.HiddenInput(), label="") 

22 

23 

24class RecaptchaedCardTokenizeSuccessForm(ValidateRecaptchaMixin, CardTokenizeSuccessForm): 

25 pass 

26 

27 

28class CardTokenizeFailForm(forms.Form): 

29 """Form to indicate card tokenization failure to server.""" 

30 

31 method = "POST" 

32 

33 def __init__(self, action_url, id, *args, **kwargs): 

34 # init super with an empty data dict 

35 # binds and makes immutable this form's data 

36 # since there are no form fields, the form is also marked as valid 

37 super().__init__({}, *args, **kwargs) 

38 self.id = id 

39 self.action_url = action_url