Use multiple date formats in DateRange validator

This commit is contained in:
Patrick Smith
2018-08-10 13:46:50 -04:00
parent cb4f1281d3
commit 168436b156
4 changed files with 39 additions and 11 deletions

21
tests/domain/test_date.py Normal file
View File

@@ -0,0 +1,21 @@
import pytest
import pendulum
from atst.domain.date import parse_date
def test_date_with_slashes():
date_str = "1/2/2020"
assert parse_date(date_str) == pendulum.date(2020, 1, 2)
def test_date_with_dashes():
date_str = "2020-1-2"
assert parse_date(date_str) == pendulum.date(2020, 1, 2)
def test_invalid_date():
date_str = "This is not a valid data"
with pytest.raises(ValueError):
parse_date(date_str)