Skip to content

Commit 3989131

Browse files
committed
Fix NA_Values Testing
Move check_na_values to test_dynamic, changed test assertions to fit
1 parent 1098180 commit 3989131

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

_delphi_utils_python/tests/validator/test_dynamic.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,25 @@ def test_0_vs_many(self):
105105

106106
assert len(report.raised_errors) == 1
107107
assert report.raised_errors[0].check_name == "check_rapid_change_num_rows"
108-
108+
class TestCheckNaVals:
109+
params = {
110+
"common": {
111+
"data_source": "",
112+
"span_length": 1,
113+
"end_date": "2020-09-02"
114+
}
115+
}
116+
def test_missing(self):
117+
validator = DynamicValidator(self.params)
118+
report = ValidationReport([])
119+
data = {"val": [np.nan] * 14, "geo_id": [0,1] * 7, "time_value": ["2021-09-01"] * 14 }
120+
df = pd.DataFrame(data)
121+
#df.set_index(range(7), inplace=True)
122+
validator.check_na_vals(df, "geo", "signal", report)
123+
124+
assert len(report.raised_errors) == 2
125+
assert report.raised_errors[0].check_name == "check_val_missing (geo_id 0)"
126+
assert report.raised_errors[1].check_name == "check_val_missing (geo_id 1)"
109127

110128
class TestCheckAvgValDiffs:
111129
params = {

_delphi_utils_python/tests/validator/test_static.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -362,15 +362,6 @@ def test_empty_df(self):
362362

363363
assert len(report.raised_errors) == 0
364364

365-
def test_missing(self):
366-
validator = StaticValidator(self.params)
367-
report = ValidationReport([])
368-
df = pd.DataFrame([np.nan], columns=["val"])
369-
validator.check_bad_val(df, FILENAME, "signal", report)
370-
371-
assert len(report.raised_errors) == 1
372-
assert report.raised_errors[0].check_name == "check_val_missing"
373-
374365
def test_lt_0(self):
375366
validator = StaticValidator(self.params)
376367
report = ValidationReport([])

0 commit comments

Comments
 (0)