Last active
September 23, 2021 01:18
-
-
Save andrewdoss-bit/b8834b41b29a70d730e453f304e6908e to your computer and use it in GitHub Desktop.
validation_test_wrapper
This file contains hidden or 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
def test_data(df, tests): | |
"""Run provided data tests on provided data.""" | |
results = [] | |
for test_func, failure_message in tests: | |
results.append(test_func(df.copy())) | |
if results[-1]: | |
logger.info(f'Data test {test_func.__name__} passed.') | |
else: | |
logger.error(f'Data test {test_func.__name__} failed. {failure_message}') | |
logger.info(f'{sum(results)}/{len(results)} passed.') | |
return sum(results) == len(results) | |
nyt_cases_counties = [ | |
(cases_vs_deaths, "Death counts cannot exceed case counts."), | |
(unique_records, "Only one record per FIPs, per date allowed."), | |
(no_nulls_test, "All values are expected to be non-null."), | |
(cases_range_test, "Cases must be non-negative and <= 10M."), | |
(deaths_range_test, "Deaths must be non-negative and <= 100K.") | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment