Merged in task/unit-tests-investment-and-client (pull request #354)
Task/unit tests investment and client * move io_utils.py * add __init__.py * refactor: move string_funcs and update import paths to use utils namespace * rename string_funcs to string_utils * move and rename table_utils.py * refactor: rename claude_funcs to llm_utils in multiple files * update unit tests * added unit tests for src/string_utils.py * added unit tests for src/table_utils.py * added unit tests for src/llm_utils.py * added unit tests for src/io_utils.py * Merge branch 'main' into task/unit-tests-investment-and-client; TODO: fix unit tests * Unit tests to fix * fix unit tests * fix invalid references * add unit tests for preprocessing_funcs.py * move pytest-mock to test dependencies * Merge remote-tracking branch 'origin/main' into task/unit-tests-investment-and-client * add tests/string_utils_test.py * removed filename parameters for a few functions * save postprocessing_funcs_test midway * save postprocessing_funcs_test * postprocessing_funcs unit tests complete * Merge branch 'main' into task/unit-tests-investment-and-client Approved-by: Katon Minhas
This commit is contained in:
committed by
Alex Galarce
parent
64baf930f8
commit
04d268a2f8
@@ -5,10 +5,9 @@ import src.utils.llm_utils as llm_utils
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
|
||||
from src.enums.delimiters import Delimiter
|
||||
|
||||
class TestExtractTextFromDelimiters:
|
||||
class TestStringUtils:
|
||||
@pytest.mark.parametrize("raw_text, delimiter, match_index, expected", [
|
||||
("Here is the answer |this is a pipe answer| and |more text.|", Delimiter.PIPE, 0, "this is a pipe answer"),
|
||||
("Here is the answer |this is a pipe answer| and |more text.|", Delimiter.PIPE, -1, "more text."),
|
||||
@@ -24,7 +23,6 @@ class TestExtractTextFromDelimiters:
|
||||
result = extract_text_from_delimiters(raw_text, delimiter, match_index)
|
||||
assert result == expected
|
||||
|
||||
class TestJsonParsingSearch:
|
||||
@pytest.mark.parametrize("response_text, field_list, expected", [
|
||||
('{"name": "John", "age": "30", "city": "New York"}', ["name", "age", "city"], {"name": "John", "age": "30", "city": "New York"}),
|
||||
('{"name": "John", "city": "New York"}', ["name", "age", "city"], {"name": "John", "city": "New York"}),
|
||||
@@ -36,7 +34,6 @@ class TestJsonParsingSearch:
|
||||
def test_json_parsing_search(self, response_text, field_list, expected):
|
||||
assert json_parsing_search(response_text, field_list) == expected
|
||||
|
||||
class TestSecondaryStringToDict:
|
||||
@pytest.fixture
|
||||
def mock_invoke_claude(self, mocker):
|
||||
return mocker.patch.object(llm_utils, 'invoke_claude')
|
||||
@@ -79,7 +76,6 @@ class TestSecondaryStringToDict:
|
||||
assert result == {}
|
||||
mock_invoke_claude.assert_called_once()
|
||||
|
||||
class TestPrimaryStringToDict:
|
||||
@pytest.fixture
|
||||
def mock_secondary_string_to_dict(self, mocker):
|
||||
return mocker.patch.object(utils.string_utils, "secondary_string_to_dict")
|
||||
@@ -164,7 +160,6 @@ class TestPrimaryStringToDict:
|
||||
assert result == expected_output
|
||||
assert mock_secondary_string_to_dict.call_count == 4
|
||||
|
||||
class TestContainsReimbursement:
|
||||
@pytest.mark.parametrize("text, page, expected", [
|
||||
({"1": "This page contains a 10% reimbursement schedule.", "2": "No relevant content here."}, "1", True),
|
||||
({"1": "This page has no relevant content.", "2": "Still no relevant content here."}, "1", False),
|
||||
@@ -184,7 +179,6 @@ class TestContainsReimbursement:
|
||||
captured = capsys.readouterr()
|
||||
assert "contains_reimbursement - Invalid data type" in captured.out
|
||||
|
||||
class TestIsEmpty:
|
||||
@pytest.mark.parametrize("value, expected", [
|
||||
(None, True),
|
||||
("", True),
|
||||
@@ -199,4 +193,4 @@ class TestIsEmpty:
|
||||
])
|
||||
def test_is_empty(self, value, expected):
|
||||
result = is_empty(value)
|
||||
assert result == expected
|
||||
assert result == expected
|
||||
|
||||
Reference in New Issue
Block a user