Skip to content

Commit

Permalink
test: add assertions for form widget attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
angela-tran committed Apr 23, 2024
1 parent db6c6ea commit 2058dbd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/pytest/eligibility/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,26 @@ def test_MSTCourtesyCard():

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


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

0 comments on commit 2058dbd

Please sign in to comment.