Skip to content

Commit

Permalink
Add several tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rich-iannone committed Feb 23, 2025
1 parent 43b37a0 commit b6b5786
Show file tree
Hide file tree
Showing 2 changed files with 254 additions and 36 deletions.
32 changes: 22 additions & 10 deletions pointblank/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
VALIDATION_REPORT_FIELDS,
)
from pointblank._constants_autobriefs import AUTOBRIEFS_TEXT
from pointblank.column import Column, col, ColumnSelector, ColumnSelectorNarwhals
from pointblank.column import Column, col, ColumnSelector, ColumnSelectorNarwhals, ColumnLiteral
from pointblank.schema import Schema, _get_schema_validation_info
from pointblank.thresholds import (
Thresholds,
Expand Down Expand Up @@ -7683,10 +7683,16 @@ def _create_autobrief(
lang=lang, column=column, value_1=values[0], value_2=values[1], not_=True
)

if assertion_type in ["col_vals_in_set", "col_vals_not_in_set"]:
if assertion_type == "col_vals_in_set":
return _create_autobrief_set(lang=lang, column=column, values=values)

if assertion_type == "col_vals_not_in_set":
return _create_autobrief_set(lang=lang, column=column, values=values, not_=True)

if assertion_type in ["col_vals_null", "col_vals_not_null"]:
if assertion_type == "col_vals_null":
return _create_autobrief_null(lang=lang, column=column)

if assertion_type == "col_vals_not_null":
return _create_autobrief_null(lang=lang, column=column, not_=True)

if assertion_type == "col_vals_regex":
Expand Down Expand Up @@ -7724,7 +7730,7 @@ def _create_autobrief_comparison(

column_text = _prep_column_text(column=column)

values_text = values
values_text = _prep_values_text(values=values, lang=lang, limit=3)

compare_expectation_text = AUTOBRIEFS_TEXT["compare_expectation_text"][lang]

Expand All @@ -7747,19 +7753,22 @@ def _create_autobrief_between(

column_text = _prep_column_text(column=column)

value_1_text = _prep_values_text(values=value_1, lang=lang, limit=3)
value_2_text = _prep_values_text(values=value_2, lang=lang, limit=3)

if not not_:
autobrief = AUTOBRIEFS_TEXT["between_expectation_text"][lang].format(
column_text=column_text,
column_computed_text=column_computed_text,
value_1=value_1,
value_2=value_2,
value_1=value_1_text,
value_2=value_2_text,
)
else:
autobrief = AUTOBRIEFS_TEXT["not_between_expectation_text"][lang].format(
column_text=column_text,
column_computed_text=column_computed_text,
value_1=value_1,
value_2=value_2,
value_1=value_1_text,
value_2=value_2_text,
)

return autobrief
Expand Down Expand Up @@ -7869,7 +7878,7 @@ def _create_autobrief_rows_distinct(lang: str, columns_subset: list[str] | None)

def _create_autobrief_row_count_match(lang: str, value: int) -> str:

values_text = str(value["count"])
values_text = _prep_values_text(value["count"], lang=lang)

autobrief = AUTOBRIEFS_TEXT["row_count_match_n_expectation_text"][lang].format(
values_text=values_text
Expand All @@ -7880,7 +7889,7 @@ def _create_autobrief_row_count_match(lang: str, value: int) -> str:

def _create_autobrief_col_count_match(lang: str, value: int) -> str:

values_text = str(value["count"])
values_text = _prep_values_text(value["count"], lang=lang)

autobrief = AUTOBRIEFS_TEXT["col_count_match_n_expectation_text"][lang].format(
values_text=values_text
Expand All @@ -7899,6 +7908,9 @@ def _prep_values_text(
limit: int = 3,
) -> str:

if isinstance(values, ColumnLiteral):
return f"`{values}`"

if isinstance(values, (str, int, float)):
values = [values]

Expand Down
Loading

0 comments on commit b6b5786

Please sign in to comment.