Skip to content

Commit

Permalink
add processors tests
Browse files Browse the repository at this point in the history
Signed-off-by: Yotam-Perlitz <[email protected]>
  • Loading branch information
perlitz committed Jan 8, 2025
1 parent 89b0ce0 commit 52982a6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/library/test_collections_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Slice,
Wrap,
)
from unitxt.processors import AddPrefix, GetSQL
from unitxt.test_utils.operators import check_operator

from tests.utils import UnitxtTestCase
Expand Down Expand Up @@ -113,3 +114,25 @@ def test_chunk(self):
inputs = [{"x": [0, 1, 2]}, {"x": [0, 1]}, {"x": [3]}]
targets = [{"x": [[0, 1], [2]]}, {"x": [[0, 1]]}, {"x": [[3]]}]
check_operator(operator=operator, inputs=inputs, targets=targets, tester=self)

def test_add_prefix(self):
operator = AddPrefix(field="text", prefix="Hello ")
inputs = [{"text": "World"}, {"text": "Hello there"}, {"text": " Hello again"}]
targets = [
{"text": "Hello World"},
{"text": "Hello there"},
{"text": "Hello again"},
]
check_operator(operator=operator, inputs=inputs, targets=targets, tester=self)

def test_get_sql_with_simple_query(self):
operator = GetSQL(field="text")
inputs = [{"text": "SELECT * FROM table;"}]
targets = [{"text": "SELECT * FROM table"}]
check_operator(operator=operator, inputs=inputs, targets=targets, tester=self)

def test_get_sql_with_code_block(self):
operator = GetSQL(field="text")
inputs = [{"text": "```SELECT id FROM table```"}]
targets = [{"text": "SELECT id FROM table"}]
check_operator(operator=operator, inputs=inputs, targets=targets, tester=self)

0 comments on commit 52982a6

Please sign in to comment.