Files
notifications-admin/tests/app/main/forms/test_strip_whitespace.py
Ben Thorner e0b62bed70 Group form tests in a directory
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.
2022-03-11 11:17:43 +00:00

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'