From 1e2857fdcc99e31467bb06558010266d59696357 Mon Sep 17 00:00:00 2001 From: Christina Gosnell Date: Tue, 7 Nov 2023 13:30:05 -0500 Subject: [PATCH] add report year validation test --- test/validate/service_territory_test.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/validate/service_territory_test.py b/test/validate/service_territory_test.py index 78aa9022cd..550aeb44bd 100644 --- a/test/validate/service_territory_test.py +++ b/test/validate/service_territory_test.py @@ -46,3 +46,22 @@ def test_minmax_rows( pv.check_max_rows, expected_rows=expected_rows, margin=0.0, df_name=df_name ) ) + + +def test_report_year_discrepency_in_demand_hourly_pa_ferc714(pudl_out_orig): + """Test if the vast majority of the years in the two date columns line up.""" + demand_hourly_pa_ferc714 = pudl_out_orig.demand_hourly_pa_ferc714() + mismatched_report_years = demand_hourly_pa_ferc714[ + ( + demand_hourly_pa_ferc714.utc_datetime.dt.year + != demand_hourly_pa_ferc714.report_date.dt.year + ) + ] + if ( + off_ratio := len(mismatched_report_years) / len(demand_hourly_pa_ferc714) + ) > 0.001: + raise AssertionError( + f"Found more ({off_ratio:.2%}) than expected (>.1%) FERC714 records" + " where the report year from the utc_datetime differs from the " + "report_date column." + )