File size: 1,424 Bytes
5065564
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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