3740588efa
Refactor/daip2-9 code refactor * add missing import * refactor ac_smart_chunking.py * update tests * removed old and unused imports * removed outdated import * forgot to import re * refactor bottom up funcs * remove unused imports from file_processing.py * refactor dict_operations.py * remove unused import from conditional_funcs.py * replace top_down_funcs with one_to_n_funcs and remove top_down_funcs.py * remove duplicate import from one_to_n_funcs.py * refactor all utils.py imports * refactor error handling by removing last code in utils and integrating InvalidDateException into postprocessing_funcs * refactor import in claude_funcs.py to use string_funcs directly and (hopefully) resolve circular import * refactor regex_funcs.py to use postprocessing_funcs for add_hyphen_if_needed calls * refactor hotfix_helper_funcs.py to use postprocessing_funcs for add_hyphen_if_needed calls * refactor postprocess.py to remove unused imports * add numpy import to string_funcs * fix tests after utils refactor * move adhoc from tests to scripts * remove unused imports * remove scripts from mypy checking * isort * Merged main into refactor/daip-2-9-code-refactor Approved-by: Katon Minhas
44 lines
1.9 KiB
Python
44 lines
1.9 KiB
Python
import pytest
|
|
from postprocessing_funcs import convert_to_us_date_format, InvalidDateException
|
|
|
|
|
|
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)
|