Skip to content

Commit

Permalink
Feature test increase ok method on check (#327)
Browse files Browse the repository at this point in the history
* Added checks for ok method in check

* Added ok boolean method for check
  • Loading branch information
canimus authored Sep 28, 2024
1 parent a8f0164 commit e2c3256
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cuallee/polars_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ def _evaluate_status(pass_rate, pass_threshold):
pl.Config.set_tbl_cols(12)
return pl.DataFrame(computation_basis)


def ok(check: Check, dataframe: pl.DataFrame) -> bool:
"""True when all rules in the check pass validation"""

Expand All @@ -540,4 +541,4 @@ def ok(check: Check, dataframe: pl.DataFrame) -> bool:
operator.methodcaller("to_series"),
operator.methodcaller("select", "status"),
)
return _all_pass(summary(check, dataframe))
return _all_pass(summary(check, dataframe))
24 changes: 24 additions & 0 deletions test/unit/class_check/test_ok.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest
from cuallee import Check
import pandas as pd
import polars as pl
import duckdb as dk
from pyspark.sql import SparkSession


def test_pandas_ok(check: Check):
df = pd.DataFrame({"A": range(10)})
check.is_complete("A")
assert check.ok(df)


def test_polars_ok(check: Check):
df = pl.DataFrame({"A": range(10)})
check.is_complete("A")
assert check.ok(df)


def test_pyspark_ok(check: Check, spark: SparkSession):
df = spark.range(10)
check.is_complete("id")
assert check.ok(df)

0 comments on commit e2c3256

Please sign in to comment.