44 lines
1.9 KiB
Python
44 lines
1.9 KiB
Python
|
|
import pytest
|
||
|
|
from utils import convert_to_us_date_format, InvalidDateException, is_empty
|
||
|
|
|
||
|
|
|
||
|
|
class TestConvertToUSDateFormat:
|
||
|
|
def test_convert_to_us_date_format_valid(self):
|
||
|
|
assert convert_to_us_date_format("2023-12-01") == "12/01/2023"
|
||
|
|
assert convert_to_us_date_format("2023-01-12") == "01/12/2023"
|
||
|
|
assert convert_to_us_date_format("2023-13-01") == "01/13/2023"
|
||
|
|
|
||
|
|
def test_convert_to_us_date_format_invalid(self):
|
||
|
|
with pytest.raises(InvalidDateException):
|
||
|
|
convert_to_us_date_format("2023-13-32")
|
||
|
|
with pytest.raises(InvalidDateException):
|
||
|
|
convert_to_us_date_format("2023-00-01")
|
||
|
|
with pytest.raises(InvalidDateException):
|
||
|
|
convert_to_us_date_format("2023-12-00")
|
||
|
|
with pytest.raises(InvalidDateException):
|
||
|
|
convert_to_us_date_format("2023-12-32")
|
||
|
|
with pytest.raises(InvalidDateException):
|
||
|
|
convert_to_us_date_format("2023-13-13")
|
||
|
|
|
||
|
|
def test_convert_to_us_date_format_empty(self):
|
||
|
|
with pytest.raises(InvalidDateException):
|
||
|
|
convert_to_us_date_format("")
|
||
|
|
with pytest.raises(InvalidDateException):
|
||
|
|
convert_to_us_date_format("N/A")
|
||
|
|
with pytest.raises(InvalidDateException):
|
||
|
|
convert_to_us_date_format("null")
|
||
|
|
with pytest.raises(InvalidDateException):
|
||
|
|
convert_to_us_date_format("none")
|
||
|
|
|
||
|
|
def test_convert_to_us_date_format_invalid_format(self):
|
||
|
|
with pytest.raises(InvalidDateException):
|
||
|
|
convert_to_us_date_format("2023/12/01")
|
||
|
|
with pytest.raises(InvalidDateException):
|
||
|
|
convert_to_us_date_format("12-01-2023")
|
||
|
|
with pytest.raises(InvalidDateException):
|
||
|
|
convert_to_us_date_format("2023.12.01")
|
||
|
|
|
||
|
|
def test_convert_to_us_date_format_invalid_type(self):
|
||
|
|
with pytest.raises(TypeError):
|
||
|
|
convert_to_us_date_format(None)
|