47a01e13f0
New Prompt Method (starting with contract effective date) * add todos for Siddhant * moved effective date prompts to prompts.py and added docstring and type hints * moved effective date prompts to prompts.py and added docstring and type hints * fixed conflict Co-authored-by: Alex Galarce <agalarce@aarete.com> * modified contract effective date logic in existing smart chunking * Merged main into chore/contract_effective_date * updated extract_text_from_delimiters function and unit tests for it * Merge remote-tracking branch 'origin/main' into chore/contract_effective_date * added comments to preprocessing_funcs * preprocessing_funcs.py edited online with Bitbucket * utils.py edited online with Bitbucket * add debug line * add NA handling into fix_date_formatting() * add debug print statements * worked on review comments * fixed date checking * fixed date checking and added unit tests * Merged main into chore/contract_effective_date * added logic to handle case when smart chunking returns empty context for effective date * added comments to file_processing.py * optimized imports and removed a TODO * Merged main into chore/contract_effective_date * made prompt changes for effective date * keywords.py edited online with Bitbucket * Removed excess print statements Approved-by: Katon Minhas
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)
|