-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: test case to validate function in pipeline layer
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
wren-ai-service/tests/pytest/pipelines/generation/test_semantics_enrichment.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 |
---|---|---|
@@ -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 |