mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-27 04:31:11 -04:00
This makes it clearer we have tests for the code in forms.py, which I missed initially. In future we could also split up forms.py in a similar way, as it's currently _very long_. As part of grouping tests for code in forms.py, I've extracted some from test_validators.py, so that what remains is focussed on testing the code in validators.py.
33 lines
670 B
Python
33 lines
670 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'
|