From e8838b21bdbc5f9711c488f4eb291cf220643279 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Mon, 15 Jul 2024 16:33:19 +0000 Subject: [PATCH] fix(tests): keep form tests --- tests/pytest/eligibility/test_forms.py | 38 +++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/tests/pytest/eligibility/test_forms.py b/tests/pytest/eligibility/test_forms.py index 1707130e4..1460bc9e9 100644 --- a/tests/pytest/eligibility/test_forms.py +++ b/tests/pytest/eligibility/test_forms.py @@ -1,4 +1,4 @@ -from benefits.eligibility.forms import CSTAgencyCard +from benefits.eligibility.forms import CSTAgencyCard, MSTCourtesyCard, SBMTDMobilityPass def test_CSTAgencyCard(): @@ -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