-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(eligibility/form): custom validation message for index and confi…
…rm fields (#2045)
- Loading branch information
Showing
5 changed files
with
103 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from benefits.eligibility.forms import MSTCourtesyCard, SBMTDMobilityPass | ||
|
||
|
||
def test_MSTCourtesyCard(): | ||
form = MSTCourtesyCard(data={"sub": "12345", "name": "Gonzalez"}) | ||
|
||
assert form.is_valid() | ||
|
||
sub_attrs = form.fields["sub"].widget.attrs | ||
assert sub_attrs["pattern"] == r"\d{5}" | ||
assert sub_attrs["inputmode"] == "numeric" | ||
assert sub_attrs["maxlength"] == 5 | ||
assert sub_attrs["data-custom-validity"] == "Please enter a 5-digit number." | ||
|
||
name_attrs = form.fields["name"].widget.attrs | ||
assert name_attrs["maxlength"] == 255 | ||
assert name_attrs["data-custom-validity"] == "Please enter your last name." | ||
|
||
assert form.use_custom_validity | ||
|
||
|
||
def test_SBMTDMobilityPass(): | ||
form = SBMTDMobilityPass(data={"sub": "1234", "name": "Barbara"}) | ||
|
||
assert form.is_valid() | ||
|
||
sub_attrs = form.fields["sub"].widget.attrs | ||
assert sub_attrs["pattern"] == r"\d{4}" | ||
assert sub_attrs["maxlength"] == 4 | ||
assert sub_attrs["inputmode"] == "numeric" | ||
assert sub_attrs["data-custom-validity"] == "Please enter a 4-digit number." | ||
|
||
name_attrs = form.fields["name"].widget.attrs | ||
assert name_attrs["maxlength"] == 255 | ||
assert name_attrs["data-custom-validity"] == "Please enter your last name." | ||
|
||
assert form.use_custom_validity |