-
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.
* adapt conftest bq to run tests locally * added is_unique with test cases * black, flake and type ok on bq
- Loading branch information
1 parent
dc6d2c4
commit 398cb62
Showing
5 changed files
with
112 additions
and
45 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
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
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,41 @@ | ||
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.is_unique("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.is_unique("taxi_id") | ||
rs = check.validate(df) | ||
assert rs.status.str.match("FAIL")[1] | ||
assert rs.violations[1] == 208933883 | ||
assert rs.pass_threshold[1] == 1.0 | ||
assert rs.pass_rate[1] == 9738 / 208943621 | ||
|
||
|
||
# def test_parameters(): | ||
# return "😅 No parameters to be tested!" | ||
|
||
|
||
def test_coverage(): | ||
df = bigquery.dataset.Table("bigquery-public-data.chicago_taxi_trips.taxi_trips") | ||
check = Check(CheckLevel.WARNING, "pytest") | ||
check.is_unique("taxi_id", 0.000007) | ||
rs = check.validate(df) | ||
assert rs.status.str.match("PASS")[1] | ||
assert rs.violations[1] == 208933883 | ||
assert rs.pass_threshold[1] == 0.000007 | ||
assert rs.pass_rate[1] == 9738 / 208943621 |