Files
doczyai-pipelines/fieldExtraction/tests/postprocessing_funcs_test.py
T
Alex Galarce 53b38ea15c Merged in refactor/split-investment-and-client (pull request #347)
Refactor/split investment and client

* refactor: clean up tests

* Renamed tests/qcqa to tests/qa_qc for consistency

* comment out faulty test - see docstring note at top

* split to client/investment

* add __init__.py to investment and client to avoid mypy confusion

* fix imports

* update imports for consistency across investment module

* move back to one config

* try changing import to relative

* add init.py to src

* try relative import

* try one more sys.path.append

* fix path for client main

* fix imports in file_processing

* make prompts common

* move keywords out to `src`

* move smart_chunking_funcs to `src`

* fix mypy error

* start moving to explicit imports

* remove old keywords and fix imports for keywords and prompts

* change all imports to full paths

* fix unit tests

* add readme for new way of running things

* isort after all that import work

* remove unused sys.path.append from some tests


Approved-by: Katon Minhas
2025-01-08 21:59:47 +00:00

46 lines
1.9 KiB
Python

import pytest
from src.postprocessing_funcs import (InvalidDateException,
convert_to_us_date_format)
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)