Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINTENANCE] Expand test of a column map metric to underscore functionality. #3072

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 20 additions & 4 deletions tests/expectations/metrics/test_core.py
Expand Up @@ -522,7 +522,7 @@ def test_map_column_value_lengths_between_pd():


def test_map_unique_pd_column_exists():
engine = build_pandas_engine(pd.DataFrame({"a": [1, 2, 3, 3, None]}))
engine = build_pandas_engine(pd.DataFrame({"a": [1, 2, 3, 3, 4, None]}))

metrics: dict = {}

Expand All @@ -532,7 +532,7 @@ def test_map_unique_pd_column_exists():
table_columns_metric, results = get_table_columns_metric(engine=engine)
metrics.update(results)

desired_metric = MetricConfiguration(
condition_metric = MetricConfiguration(
metric_name="column_values.unique.condition",
metric_domain_kwargs={"column": "a"},
metric_value_kwargs=dict(),
Expand All @@ -541,11 +541,27 @@ def test_map_unique_pd_column_exists():
},
)
results = engine.resolve_metrics(
metrics_to_resolve=(desired_metric,),
metrics_to_resolve=(condition_metric,),
metrics=metrics,
)
metrics.update(results)

unexpected_count_metric = MetricConfiguration(
metric_name="column_values.unique.unexpected_count",
metric_domain_kwargs={"column": "a"},
metric_value_kwargs=dict(),
metric_dependencies={
"unexpected_condition": condition_metric,
"table.columns": table_columns_metric,
},
)
results = engine.resolve_metrics(
metrics_to_resolve=(unexpected_count_metric,), metrics=metrics
)
metrics.update(results)

assert list(results[desired_metric.id][0]) == [False, False, True, True]
assert list(metrics[condition_metric.id][0]) == [False, False, True, True, False]
assert metrics[unexpected_count_metric.id] == 2


def test_map_unique_pd_column_does_not_exist():
Expand Down