Add validation to form for enforcing chronological order of PoP start and end dates
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import datetime
|
||||
|
||||
from atst.forms.task_order import CLINForm
|
||||
from atst.models import JEDICLINType
|
||||
from atst.utils.localization import translate
|
||||
|
||||
import tests.factories as factories
|
||||
|
||||
@@ -9,3 +12,21 @@ def test_clin_form_jedi_clin_type():
|
||||
clin = factories.CLINFactory.create(jedi_clin_type=jedi_type)
|
||||
clin_form = CLINForm(obj=clin)
|
||||
assert clin_form.jedi_clin_type.data == jedi_type.value
|
||||
|
||||
|
||||
def test_clin_form_start_date_before_end_date():
|
||||
invalid_start = datetime.date(2020, 12, 12)
|
||||
invalid_end = datetime.date(2020, 1, 1)
|
||||
invalid_clin = factories.CLINFactory.create(
|
||||
start_date=invalid_start, end_date=invalid_end
|
||||
)
|
||||
clin_form = CLINForm(obj=invalid_clin)
|
||||
assert not clin_form.validate()
|
||||
assert translate("forms.task_order.start_date_error") in clin_form.start_date.errors
|
||||
valid_start = datetime.date(2020, 1, 1)
|
||||
valid_end = datetime.date(2020, 12, 12)
|
||||
valid_clin = factories.CLINFactory.create(
|
||||
start_date=valid_start, end_date=valid_end
|
||||
)
|
||||
valid_clin_form = CLINForm(obj=valid_clin)
|
||||
assert valid_clin_form.validate()
|
||||
|
Reference in New Issue
Block a user