use regular WTForms DateField for requests dates
This commit is contained in:
@@ -3,33 +3,13 @@ from wtforms import Form
|
||||
import pendulum
|
||||
from werkzeug.datastructures import ImmutableMultiDict
|
||||
|
||||
from atst.forms.fields import DateField, NewlineListField
|
||||
|
||||
|
||||
class DateForm(Form):
|
||||
date = DateField()
|
||||
from atst.forms.fields import NewlineListField
|
||||
|
||||
|
||||
class NewlineListForm(Form):
|
||||
newline_list = NewlineListField()
|
||||
|
||||
|
||||
def test_date_ie_format():
|
||||
form = DateForm(data={"date": "12/24/2018"})
|
||||
assert form.date._value() == pendulum.date(2018, 12, 24)
|
||||
|
||||
|
||||
def test_date_sane_format():
|
||||
form = DateForm(data={"date": "2018-12-24"})
|
||||
assert form.date._value() == pendulum.date(2018, 12, 24)
|
||||
|
||||
|
||||
def test_date_insane_format():
|
||||
form = DateForm(data={"date": "hello"})
|
||||
with pytest.raises(ValueError):
|
||||
form.date._value()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"input_,expected",
|
||||
[
|
||||
|
Reference in New Issue
Block a user