Skip to content

Commit

Permalink
fix(tests): keep form tests
Browse files Browse the repository at this point in the history
  • Loading branch information
machikoyasuda committed Jul 15, 2024
1 parent 3683cbb commit 3a86db1
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion tests/pytest/eligibility/test_forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from benefits.eligibility.forms import CSTAgencyCard
from benefits.eligibility.forms import CSTAgencyCard, MSTCourtesyCard, SBMTDMobilityPass


def test_CSTAgencyCard():
Expand All @@ -17,3 +17,39 @@ def test_CSTAgencyCard():
assert name_attrs["data-custom-validity"] == "Please enter your last name."

assert form.use_custom_validity


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

0 comments on commit 3a86db1

Please sign in to comment.