-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
249 additions
and
18 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
Empty file.
50 changes: 50 additions & 0 deletions
50
tests/multicolumn_map_expectations/expect_multicolumn_values_to_be_unique.json
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,50 @@ | ||
{ | ||
"expectation_type" : "expect_multicolumn_values_to_be_unique", | ||
"datasets" : [{ | ||
"data" : { | ||
"w" : [2, 3, 4, 5, 6, 7, 8, 9, 10, null], | ||
"x" : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], | ||
"y" : [2, 3, 4, 5, 6, 7, 8, 9, 10, null], | ||
"z" : [1, 2, 3, 4, 5, null, null, null, null, null], | ||
"a" : [1, 1, 1, 1, 1, 2, 2, 2, 2, null], | ||
"b" : [1, 2, 1, 2, 1, 2, 1, 2, 1, null] | ||
}, | ||
"tests" : [{ | ||
"title": "Basic test; ignore if all are missing", | ||
"exact_match_out" : false, | ||
"in": { | ||
"column_list": ["w", "x"], | ||
"ignore_row_if": "all_values_are_missing" | ||
}, | ||
"out": { | ||
"unexpected_list": {"w": {}, "x": {}}, | ||
"unexpected_index_list": [], | ||
"success": true | ||
} | ||
},{ | ||
"title": "Basic test; ignore if any are missing", | ||
"exact_match_out" : false, | ||
"in": { | ||
"column_list": ["w", "x"], | ||
"ignore_row_if": "any_value_is_missing" | ||
}, | ||
"out": { | ||
"unexpected_list": {"w": {}, "x": {}}, | ||
"unexpected_index_list": [], | ||
"success": true | ||
} | ||
},{ | ||
"title": "Unexpected Values", | ||
"exact_match_out" : false, | ||
"in": { | ||
"column_list": ["a", "b"] | ||
}, | ||
"out": { | ||
"unexpected_list": {"a": {"0": 1.0, "2": 1.0, "4": 1.0, "5": 2.0, "7": 2.0}, | ||
"b": {"0": 1.0, "2": 1.0, "4": 1.0, "5": 2.0, "7": 2.0}}, | ||
"unexpected_index_list": [0,2,4,5,7], | ||
"success": false | ||
} | ||
}] | ||
}] | ||
} |
66 changes: 66 additions & 0 deletions
66
tests/multicolumn_map_expectations/test_multicolumn_map_expectations.py
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,66 @@ | ||
### | ||
### | ||
# | ||
# This file should not be modified. To adjust test cases, edit the related json file(s). | ||
# | ||
### | ||
### | ||
|
||
|
||
import os | ||
import json | ||
import glob | ||
import warnings | ||
|
||
from tests.test_utils import get_dataset, candidate_test_is_on_temporary_notimplemented_list, evaluate_json_test | ||
|
||
contexts = ['PandasDataset', 'SqlAlchemyDataset'] | ||
|
||
|
||
def pytest_generate_tests(metafunc): | ||
|
||
# Load all the JSON files in the directory | ||
dir_path = os.path.dirname(os.path.realpath(__file__)) | ||
test_configuration_files = glob.glob(dir_path+'/*.json') | ||
|
||
parametrized_tests = [] | ||
ids = [] | ||
for c in contexts: | ||
for filename in test_configuration_files: | ||
file = open(filename) | ||
test_configuration = json.load(file) | ||
|
||
if candidate_test_is_on_temporary_notimplemented_list(c, test_configuration["expectation_type"]): | ||
warnings.warn("Skipping generation of tests for expectation " + test_configuration["expectation_type"] + | ||
" and context " + c) | ||
else: | ||
for d in test_configuration['datasets']: | ||
my_dataset = get_dataset(c, d["data"]) | ||
|
||
for test in d["tests"]: | ||
parametrized_tests.append({ | ||
"expectation_type": test_configuration["expectation_type"], | ||
"dataset": my_dataset, | ||
"test": test, | ||
}) | ||
|
||
ids.append( | ||
c+":"+test_configuration["expectation_type"]+":"+test["title"]) | ||
|
||
metafunc.parametrize( | ||
"test_case", | ||
parametrized_tests, | ||
ids=ids | ||
) | ||
|
||
|
||
def test_case_runner(test_case): | ||
# Note: this should never be done in practice, but we are wiping expectations to reuse datasets during testing. | ||
test_case["dataset"]._initialize_expectations() | ||
|
||
|
||
evaluate_json_test( | ||
test_case["dataset"], | ||
test_case["expectation_type"], | ||
test_case["test"] | ||
) |
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