| import warnings | |
| import pandas as pd | |
| from process_kpi.kpi_health_check.engine_v2 import evaluate_health_check | |
| def test_evaluate_health_check_avoids_concat_futurewarning_with_all_na_columns(): | |
| daily = pd.DataFrame( | |
| { | |
| "site_code": [1001, 1001, 1002, 1002], | |
| "date_only": pd.to_datetime( | |
| ["2026-03-01", "2026-03-02", "2026-03-01", "2026-03-02"] | |
| ), | |
| "City": [None, None, None, None], | |
| "kpi_a": [90.0, 91.0, 88.0, 87.0], | |
| "kpi_b": [1.0, 2.0, 3.0, 4.0], | |
| } | |
| ) | |
| rules_df = pd.DataFrame( | |
| { | |
| "RAT": ["LTE", "LTE"], | |
| "KPI": ["kpi_a", "kpi_b"], | |
| "direction": ["higher_is_better", "lower_is_better"], | |
| "sla": [95.0, pd.NA], | |
| "policy": ["enforce", "enforce"], | |
| } | |
| ) | |
| with warnings.catch_warnings(record=True) as caught: | |
| warnings.simplefilter("always") | |
| status_df, summary_df = evaluate_health_check( | |
| daily=daily, | |
| rat="LTE", | |
| rules_df=rules_df, | |
| baseline_days_n=1, | |
| recent_days_n=1, | |
| rel_threshold_pct=10.0, | |
| min_consecutive_days=1, | |
| granularity="Daily", | |
| ) | |
| future_warnings = [w for w in caught if issubclass(w.category, FutureWarning)] | |
| assert not future_warnings | |
| assert not status_df.empty | |
| assert not summary_df.empty | |