From 7a88184de60caa110bf70dfc7c4272d6ecee0ce3 Mon Sep 17 00:00:00 2001 From: Jonathan Kwan Date: Wed, 3 Jan 2024 02:15:30 +0000 Subject: [PATCH] Updated test_engine to use JSON inputs Co-authored-by: Erika Nesse Co-authored-by: dwindleduck Co-authored-by: Alan Pinkert Co-authored-by: David Egan Co-authored-by: thatoldplatitude --- .../tests/test_rules_engine/test_engine.py | 116 +++++++++--------- 1 file changed, 61 insertions(+), 55 deletions(-) diff --git a/rules-engine/tests/test_rules_engine/test_engine.py b/rules-engine/tests/test_rules_engine/test_engine.py index 57603850..56ed3b55 100644 --- a/rules-engine/tests/test_rules_engine/test_engine.py +++ b/rules-engine/tests/test_rules_engine/test_engine.py @@ -153,30 +153,31 @@ def test_bp_ua_with_outlier(): def test_convert_to_intermediate_billing_periods(): - temperature_input = TemperatureInput( - dates=[ - date(2022, 12, 1), - date(2022, 12, 2), - date(2022, 12, 3), - date(2022, 12, 4), - date(2023, 1, 1), - date(2023, 1, 2), - date(2023, 1, 3), - date(2023, 1, 4), - date(2023, 2, 1), - date(2023, 2, 2), - date(2023, 2, 3), - date(2023, 2, 4), - date(2023, 3, 1), - date(2023, 3, 2), - date(2023, 3, 3), - date(2023, 3, 4), - date(2023, 4, 1), - date(2023, 4, 2), - date(2023, 4, 3), - date(2023, 4, 4), + + temperature_dict = { + 'dates':[ + '2022-12-01', + '2022-12-02', + '2022-12-03', + '2022-12-04', + '2023-01-01', + '2023-01-02', + '2023-01-03', + '2023-01-04', + '2023-02-01', + '2023-02-02', + '2023-02-03', + '2023-02-04', + '2023-03-01', + '2023-03-02', + '2023-03-03', + '2023-03-04', + '2023-04-01', + '2023-04-02', + '2023-04-03', + '2023-04-04', ], - temperatures=[ + 'temperatures':[ 41.7, 41.6, 32, @@ -198,41 +199,46 @@ def test_convert_to_intermediate_billing_periods(): 70, 69, ], - ) - billing_periods = [ - NormalizedBillingPeriodRecordInput( - period_start_date=date(2022, 12, 1), - period_end_date=date(2022, 12, 4), - usage=60, - inclusion_override=None, - ), - NormalizedBillingPeriodRecordInput( - period_start_date=date(2023, 1, 1), - period_end_date=date(2023, 1, 4), - usage=50, - inclusion_override=None, - ), - NormalizedBillingPeriodRecordInput( - period_start_date=date(2023, 2, 1), - period_end_date=date(2023, 2, 4), - usage=45, - inclusion_override=None, - ), - NormalizedBillingPeriodRecordInput( - period_start_date=date(2023, 3, 1), - period_end_date=date(2023, 3, 4), - usage=30, - inclusion_override=None, - ), - NormalizedBillingPeriodRecordInput( - period_start_date=date(2023, 4, 1), - period_end_date=date(2023, 4, 4), - usage=0.96, - inclusion_override=None, - ), + } + + temperature_input = TemperatureInput(**temperature_dict) + + billing_periods_dict = [ + { + 'period_start_date':'2022-12-01', + 'period_end_date':'2022-12-04', + 'usage':60, + 'inclusion_override':None, + }, + { + 'period_start_date':'2023-01-01', + 'period_end_date':'2023-01-04', + 'usage':50, + 'inclusion_override':None, + }, + { + 'period_start_date':'2023-02-01', + 'period_end_date':'2023-02-04', + 'usage':45, + 'inclusion_override':None, + }, + { + 'period_start_date':'2023-03-01', + 'period_end_date':'2023-03-04', + 'usage':30, + 'inclusion_override':None, + }, + { + 'period_start_date':'2023-04-01', + 'period_end_date':'2023-04-04', + 'usage':0.96, + 'inclusion_override':None, + }, ] + billing_periods = [NormalizedBillingPeriodRecordInput(**x) for x in billing_periods_dict] + results = engine.convert_to_intermediate_billing_periods( temperature_input, billing_periods )