Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrugman committed Jun 15, 2022
1 parent c0994b4 commit c04594d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
11 changes: 9 additions & 2 deletions tests/popmon/pipeline/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand All @@ -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"]
Expand All @@ -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 = {
Expand All @@ -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",
Expand Down
20 changes: 17 additions & 3 deletions tests/popmon/pipeline/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand All @@ -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():
Expand All @@ -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():
Expand Down
3 changes: 2 additions & 1 deletion tests/popmon/visualization/test_report_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c04594d

Please sign in to comment.