-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: jonatank <[email protected]>
- Loading branch information
Showing
2 changed files
with
67 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
|
||
from cuallee import Check, CheckLevel, CustomComputeException | ||
import pandas as pd | ||
|
||
|
||
def test_positive(check: Check): | ||
df = pd.DataFrame({"id": range(10)}) | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.is_custom("id", lambda x: x.assign(test=(x["id"] >= 0))) | ||
rs = check.validate(df) | ||
assert rs.iloc[0].status == "PASS" | ||
assert rs.iloc[0].violations == 0 | ||
assert rs.iloc[0].pass_threshold == 1.0 | ||
|
||
|
||
def test_negative(check: Check): | ||
df = pd.DataFrame({"id": range(10)}) | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.is_custom("id", lambda x: x.assign(test=(x["id"] >= 5))) | ||
rs = check.validate(df) | ||
assert rs.iloc[0].status == "FAIL" | ||
assert rs.iloc[0].violations == 5 | ||
assert rs.iloc[0].pass_threshold == 1.0 | ||
|
||
|
||
def test_parameters(check: Check): | ||
df = pd.DataFrame({"id": range(10)}) | ||
with pytest.raises( | ||
CustomComputeException, | ||
match="Please provide a Callable/Function for validation", | ||
): | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.is_custom("id", "wrong value") | ||
check.validate(df) | ||
|
||
|
||
def test_coverage(check: Check): | ||
df = pd.DataFrame({"id": range(10)}) | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.is_custom("id", lambda x: x.assign(test=(x["id"] >= 5)), 0.4) | ||
rs = check.validate(df) | ||
assert rs.iloc[0].status == "PASS" | ||
assert rs.iloc[0].pass_threshold == 0.4 |