Skip to content

Commit

Permalink
feat: test case to validate function in pipeline layer
Browse files Browse the repository at this point in the history
  • Loading branch information
paopa committed Feb 6, 2025
1 parent da3a680 commit 8d8cc13
Showing 1 changed file with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from src.pipelines.generation.semantics_description import output


def test_without_hallucination():
test_normalize = {
"model1": {
"name": "model1",
"columns": [{"name": "column1"}],
}
}
test_picked_models = [
{
"name": "model1",
"columns": [{"name": "column1"}],
}
]

result = output(test_normalize, test_picked_models)

assert "model1" in result
assert result["model1"]["name"] == "model1"
assert len(result["model1"]["columns"]) == 1
assert result["model1"]["columns"][0]["name"] == "column1"


def test_with_hallucination():
test_normalize = {
"model1": {
"name": "model1",
"columns": [{"name": "column1"}, {"name": "$column2$"}],
}
}
test_picked_models = [
{
"name": "model1",
"columns": [{"name": "column1"}, {"name": "column2"}],
}
]

result = output(test_normalize, test_picked_models)

assert "model1" in result
assert result["model1"]["name"] == "model1"
assert len(result["model1"]["columns"]) == 1
assert result["model1"]["columns"][0]["name"] == "column1"


def test_with_hallucination_and_no_columns():
test_normalize = {
"model1": {
"name": "model1",
"columns": [{"name": "$column2$"}],
}
}
test_picked_models = [
{
"name": "model1",
"columns": [{"name": "column1"}],
}
]

result = output(test_normalize, test_picked_models)

assert "model1" in result
assert result["model1"]["name"] == "model1"
assert len(result["model1"]["columns"]) == 0

0 comments on commit 8d8cc13

Please sign in to comment.