diff --git a/_delphi_utils_python/delphi_utils/validator/report.py b/_delphi_utils_python/delphi_utils/validator/report.py index aff9196e5..b30c0db38 100644 --- a/_delphi_utils_python/delphi_utils/validator/report.py +++ b/_delphi_utils_python/delphi_utils/validator/report.py @@ -104,9 +104,21 @@ def log(self, logger=None): warnings = len(self.raised_warnings), phase="validation") for error in self.unsuppressed_errors: - logger.critical(str(error), phase="validation") + date_str = "*" if error.date is None else error.date.isoformat() + logger.critical(str(error), + phase = "validation", + error_name = error.check_name, + signal = error.signal, + resolution = error.geo_type, + date = date_str) for warning in self.raised_warnings: - logger.warning(str(warning), phase="validation") + date_str = "*" if warning.date is None else warning.date.isoformat() + logger.warning(str(warning), + phase="validation", + error_name = warning.check_name, + signal = warning.signal, + resolution = warning.geo_type, + date = date_str) def print_and_exit(self, logger=None, die_on_failures=True): """Print results and exit. diff --git a/_delphi_utils_python/tests/validator/test_report.py b/_delphi_utils_python/tests/validator/test_report.py index 2478476e2..a904b7da3 100644 --- a/_delphi_utils_python/tests/validator/test_report.py +++ b/_delphi_utils_python/tests/validator/test_report.py @@ -12,6 +12,8 @@ class TestValidationReport: ERROR_2 = ValidationFailure("bad", filename="20201107_county_sig2.csv", message="msg 2") + WARNING_1 = ValidationFailure("wrong import", date = None) + WARNING_2 = ValidationFailure("right import", date = None) def test_add_raised_unsuppressed_error(self): """Test that an unsupressed error shows up in the unsuppressed error list.""" @@ -36,8 +38,8 @@ def test_str(self): report.increment_total_checks() report.increment_total_checks() report.increment_total_checks() - report.add_raised_warning(ImportWarning("wrong import")) - report.add_raised_warning(ImportWarning("right import")) + report.add_raised_warning(self.WARNING_1) + report.add_raised_warning(self.WARNING_2) report.add_raised_error(self.ERROR_1) report.add_raised_error(self.ERROR_2) @@ -48,15 +50,27 @@ def test_log(self): report.increment_total_checks() report.increment_total_checks() report.increment_total_checks() - report.add_raised_warning(ImportWarning("wrong import")) - report.add_raised_warning(ImportWarning("right import")) + report.add_raised_warning(self.WARNING_1) + report.add_raised_warning(self.WARNING_2) report.add_raised_error(self.ERROR_1) report.add_raised_error(self.ERROR_2) report.log(mock_logger) mock_logger.critical.assert_called_once_with( "bad failed for sig2 at resolution county on 2020-11-07: msg 2", - phase = "validation") + phase = "validation", error_name = "bad", + signal = "sig2", resolution = "county", + date = "2020-11-07") mock_logger.warning.assert_has_calls( - [mock.call("wrong import",phase = "validation"), - mock.call("right import", phase = "validation")]) + [mock.call("wrong import failed for None at resolution None on *: ", + phase = "validation", + error_name = "wrong import", + signal = None, + resolution = None, + date = '*'), + mock.call("right import failed for None at resolution None on *: ", + phase = "validation", + error_name = "right import", + signal = None, + resolution = None, + date = '*')])