From da7b6d8ee46833e5d6fb14da7abaf76b5e5e8493 Mon Sep 17 00:00:00 2001 From: Simon Brugman Date: Mon, 4 Jul 2022 14:37:23 +0200 Subject: [PATCH] test: update test syntax to new config --- tests/popmon/pipeline/test_metrics.py | 35 +++++++++---------- .../popmon/pipeline/test_report_pipelines.py | 10 +++--- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/tests/popmon/pipeline/test_metrics.py b/tests/popmon/pipeline/test_metrics.py index 0fcc5dfa..567db9aa 100644 --- a/tests/popmon/pipeline/test_metrics.py +++ b/tests/popmon/pipeline/test_metrics.py @@ -9,8 +9,15 @@ def test_hists_stability_metrics(): - settings = Settings() + settings = Settings(reference_type="rolling") settings.comparison.window = 5 + settings.features = [ + "date:bankrupt", + "date:country", + "date:bankrupt", + "date:A_score", + "date:A_score:num_employees", + ] # get histograms pipeline = Pipeline( @@ -24,16 +31,7 @@ def test_hists_stability_metrics(): hists = datastore["hists"] # generate metrics - hist_list = [ - "date:bankrupt", - "date:country", - "date:bankrupt", - "date:A_score", - "date:A_score:num_employees", - ] - ds = stability_metrics( - hists, settings=settings, reference_type="rolling", features=hist_list - ) + ds = stability_metrics(hists, settings=settings) cols = ["profiles", "comparisons", "traffic_lights", "alerts"] for c in cols: @@ -41,10 +39,7 @@ def test_hists_stability_metrics(): def test_df_stability_metrics(): - settings = Settings() - # generate metrics directly from dataframe - features = ["date:isActive", "date:eyeColor", "date:latitude"] bin_specs = { "date": { "bin_width": pd.Timedelta("1y").value, @@ -52,15 +47,19 @@ def test_df_stability_metrics(): }, "latitude": {"bin_width": 5.0, "bin_offset": 0.0}, } - ds = df_stability_metrics( - df=pytest.test_df, - settings=settings, + + settings = Settings( time_axis="date", - features=features, binning="unit", + features=["date:isActive", "date:eyeColor", "date:latitude"], bin_specs=bin_specs, ) + ds = df_stability_metrics( + df=pytest.test_df, + settings=settings, + ) + cols = ["profiles", "comparisons", "traffic_lights", "alerts"] for c in cols: assert c in list(ds.keys()) diff --git a/tests/popmon/pipeline/test_report_pipelines.py b/tests/popmon/pipeline/test_report_pipelines.py index 22a7d478..5381842d 100644 --- a/tests/popmon/pipeline/test_report_pipelines.py +++ b/tests/popmon/pipeline/test_report_pipelines.py @@ -18,7 +18,7 @@ def test_self_reference(): JsonReader( file_path=resources.data("example_histogram.json"), store_key="hists" ), - SelfReference(hists_key="hists", features=hist_list, settings=Settings()), + SelfReference(hists_key="hists", settings=Settings(features=hist_list)), ] ) pipeline.transform(datastore={}) @@ -35,8 +35,7 @@ def test_external_reference(): ExternalReference( hists_key="hists", ref_hists_key="hists", - features=hist_list, - settings=Settings(), + settings=Settings(features=hist_list), ), ] ) @@ -46,7 +45,7 @@ def test_external_reference(): def test_rolling_reference(): hist_list = ["date:country", "date:A_score:num_employees"] - settings = Settings() + settings = Settings(features=hist_list) settings.comparison.window = 5 pipeline = Pipeline( @@ -57,7 +56,6 @@ def test_rolling_reference(): RollingReference( hists_key="hists", settings=settings, - features=hist_list, ), ] ) @@ -73,7 +71,7 @@ def test_expanding_reference(): file_path=resources.data("example_histogram.json"), store_key="hists" ), ExpandingReference( - hists_key="hists", features=hist_list, settings=Settings() + hists_key="hists", settings=Settings(features=hist_list) ), ] )