-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change CsvExtractionEngine behavior (#1334)
- Loading branch information
1 parent
d0a1891
commit c746174
Showing
8 changed files
with
48 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 11 additions & 7 deletions
18
tests/unit/engines/extraction/test_csv_extraction_engine.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
import pytest | ||
|
||
from griptape.engines import CsvExtractionEngine | ||
from tests.mocks.mock_prompt_driver import MockPromptDriver | ||
|
||
|
||
class TestCsvExtractionEngine: | ||
@pytest.fixture() | ||
def engine(self): | ||
return CsvExtractionEngine(column_names=["test1"]) | ||
return CsvExtractionEngine( | ||
column_names=["header"], prompt_driver=MockPromptDriver(mock_output="header\nmock output") | ||
) | ||
|
||
def test_extract_text(self, engine): | ||
result = engine.extract_text("foo") | ||
result = engine.extract_text("mock output") | ||
|
||
assert len(result.value) == 1 | ||
assert result.value[0].value == "test1: mock output" | ||
assert len(result.value) == 2 | ||
assert result.value[0].value == "header" | ||
assert result.value[1].value == "mock output" | ||
|
||
def test_text_to_csv_rows(self, engine): | ||
result = engine.text_to_csv_rows("foo,bar\nbaz,maz", ["test1", "test2"]) | ||
result = engine.text_to_csv_rows("key,value\nfoo,bar\nbaz,maz") | ||
|
||
assert len(result) == 2 | ||
assert result[0].value == "test1: foo\ntest2: bar" | ||
assert result[1].value == "test1: baz\ntest2: maz" | ||
assert result[0].value == "foo,bar" | ||
assert result[1].value == "baz,maz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters