mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-08 20:33:47 -05:00
39 lines
724 B
Python
39 lines
724 B
Python
import pytest
|
|
from wtforms import Form, StringField
|
|
|
|
from app.main.forms import StripWhitespaceForm, StripWhitespaceStringField
|
|
|
|
|
|
class ExampleForm(StripWhitespaceForm):
|
|
foo = StringField("Foo")
|
|
|
|
|
|
class ExampleFormSpecialField(Form):
|
|
foo = StripWhitespaceStringField("foo")
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"submitted_data",
|
|
[
|
|
"bar",
|
|
" bar ",
|
|
"""
|
|
\t bar
|
|
""",
|
|
" \u180E\u200B \u200C bar \u200D \u2060\uFEFF ",
|
|
],
|
|
)
|
|
@pytest.mark.parametrize(
|
|
"form",
|
|
[
|
|
ExampleForm,
|
|
ExampleFormSpecialField,
|
|
],
|
|
)
|
|
def test_form_strips_all_whitespace(
|
|
notify_admin,
|
|
form,
|
|
submitted_data,
|
|
):
|
|
assert form(foo=submitted_data).foo.data == "bar"
|