-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add are_complete * finish are_complete test cases * correct bracket typo * reverse conftest for local dvp * fix test cases
- Loading branch information
1 parent
905f59a
commit d08ad66
Showing
3 changed files
with
62 additions
and
5 deletions.
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,49 @@ | ||
import pytest | ||
import pandas as pd | ||
|
||
from google.cloud import bigquery | ||
|
||
from cuallee import Check, CheckLevel | ||
|
||
|
||
def test_positive(): | ||
df = bigquery.dataset.Table('bigquery-public-data.chicago_taxi_trips.taxi_trips') | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.are_complete(("taxi_id", "unique_key")) | ||
rs = check.validate(df) | ||
assert rs.status.str.match('PASS')[1] | ||
assert rs.violations[1] == 0 | ||
assert rs.pass_rate[1] == 1.0 | ||
|
||
|
||
def test_negative(): | ||
df = bigquery.dataset.Table('bigquery-public-data.chicago_taxi_trips.taxi_trips') | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.are_complete(("trip_start_timestamp", "trip_end_timestamp")) | ||
rs = check.validate(df) | ||
assert rs.status.str.match('FAIL')[1] | ||
assert rs.violations[1] == 9217 | ||
assert rs.pass_threshold[1] == 1.0 | ||
assert rs.pass_rate[1] == 0.9999558876219533 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"rule_column", [tuple(["taxi_id", "unique_key"]), list(["taxi_id", "unique_key"])], ids=("tuple", "list") | ||
) | ||
def test_parameters(spark, rule_column): | ||
df = bigquery.dataset.Table('bigquery-public-data.chicago_taxi_trips.taxi_trips') | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.are_complete(rule_column) | ||
rs = check.validate(df) | ||
assert rs.status.str.match('PASS')[1] | ||
|
||
|
||
def test_coverage(): | ||
df = bigquery.dataset.Table('bigquery-public-data.chicago_taxi_trips.taxi_trips') | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.are_complete(("trip_start_timestamp", "trip_end_timestamp"), 0.7) | ||
rs = check.validate(df) | ||
assert rs.status.str.match('PASS')[1] | ||
assert rs.violations[1] == 9217 | ||
assert rs.pass_threshold[1] == 0.7 | ||
assert rs.pass_rate[1] == 0.9999558876219533 #207167439/207176656 |
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