From c04594d3caf1f6731cfd31e61f20cead510b64cd Mon Sep 17 00:00:00 2001 From: Simon Brugman Date: Wed, 15 Jun 2022 16:26:20 +0200 Subject: [PATCH] test: update tests --- tests/popmon/pipeline/test_metrics.py | 11 ++++++++-- tests/popmon/pipeline/test_report.py | 20 ++++++++++++++++--- .../visualization/test_report_generator.py | 3 ++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/tests/popmon/pipeline/test_metrics.py b/tests/popmon/pipeline/test_metrics.py index df236a45..0fcc5dfa 100644 --- a/tests/popmon/pipeline/test_metrics.py +++ b/tests/popmon/pipeline/test_metrics.py @@ -3,11 +3,15 @@ from popmon import resources from popmon.base import Pipeline +from popmon.config import Settings from popmon.io import JsonReader from popmon.pipeline.metrics import df_stability_metrics, stability_metrics def test_hists_stability_metrics(): + settings = Settings() + settings.comparison.window = 5 + # get histograms pipeline = Pipeline( modules=[ @@ -28,7 +32,7 @@ def test_hists_stability_metrics(): "date:A_score:num_employees", ] ds = stability_metrics( - hists, reference_type="rolling", window=5, features=hist_list + hists, settings=settings, reference_type="rolling", features=hist_list ) cols = ["profiles", "comparisons", "traffic_lights", "alerts"] @@ -37,6 +41,8 @@ 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 = { @@ -47,7 +53,8 @@ def test_df_stability_metrics(): "latitude": {"bin_width": 5.0, "bin_offset": 0.0}, } ds = df_stability_metrics( - pytest.test_df, + df=pytest.test_df, + settings=settings, time_axis="date", features=features, binning="unit", diff --git a/tests/popmon/pipeline/test_report.py b/tests/popmon/pipeline/test_report.py index a2efe8d8..790e1d8e 100644 --- a/tests/popmon/pipeline/test_report.py +++ b/tests/popmon/pipeline/test_report.py @@ -3,12 +3,16 @@ from popmon import resources from popmon.base import Pipeline +from popmon.config import Report, Settings from popmon.hist.filling import get_bin_specs from popmon.io import JsonReader from popmon.pipeline.report import df_stability_report, stability_report def test_hists_stability_report(): + settings = Settings() + settings.comparison.window = 5 + # get histograms pipeline = Pipeline( modules=[ @@ -28,7 +32,9 @@ def test_hists_stability_report(): "date:A_score", "date:A_score:num_employees", ] - stability_report(hists, reference_type="rolling", window=5, features=hist_list) + stability_report( + hists, reference_type="rolling", settings=settings, features=hist_list + ) def test_df_stability_report(): @@ -49,9 +55,17 @@ def test_df_stability_report(): bin_specs=bin_specs, ) + settings = Report() + settings.last_n = 4 + # regenerate report, changing the plot window settings - rep.regenerate(last_n=4) - rep.regenerate(skip_first_n=1, skip_last_n=1) + rep.regenerate(report_settings=settings) + + settings.last_n = 0 + settings.skip_first_n = 1 + settings.skip_last_n = 1 + + rep.regenerate(report_settings=settings) def test_df_stability_report_self(): diff --git a/tests/popmon/visualization/test_report_generator.py b/tests/popmon/visualization/test_report_generator.py index 8326f88e..81e3ce66 100644 --- a/tests/popmon/visualization/test_report_generator.py +++ b/tests/popmon/visualization/test_report_generator.py @@ -52,7 +52,8 @@ def test_report_generator(): for f in features: assert isinstance(datastore["comparison"][f], pd.DataFrame) - assert pipeline.modules[-2].last_n == 2 + assert isinstance(pipeline.modules[-2], SectionGenerator) + assert pipeline.modules[-2].last_n == 0 assert "final_report" in datastore assert ( isinstance(datastore["final_report"], str)