File size: 2,026 Bytes
87be95e
df6bf75
87be95e
 
 
df6bf75
 
87be95e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
df6bf75
 
87be95e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""Tests for updated data models."""
from app.models import ProductResult, StatusLevel, TrendDirection, ConfidenceLevel


def test_indicator_result_new_fields():
    result = ProductResult(
        product_id="ndvi",
        headline="Test",
        status=StatusLevel.AMBER,
        trend=TrendDirection.DETERIORATING,
        confidence=ConfidenceLevel.MODERATE,
        map_layer_path="/tmp/test.tif",
        chart_data={"dates": [], "values": []},
        summary="Test summary",
        methodology="Test methodology",
        limitations=["Test"],
        anomaly_months=3,
        z_score_current=-1.8,
        hotspot_pct=15.2,
        confidence_factors={
            "temporal": 0.75,
            "observation_density": 0.5,
            "baseline_depth": 1.0,
            "spatial_completeness": 0.9,
        },
    )
    assert result.anomaly_months == 3
    assert result.z_score_current == -1.8
    assert result.hotspot_pct == 15.2
    assert result.confidence_factors["baseline_depth"] == 1.0


def test_indicator_result_defaults_for_new_fields():
    result = ProductResult(
        product_id="ndvi",
        headline="Test",
        status=StatusLevel.GREEN,
        trend=TrendDirection.STABLE,
        confidence=ConfidenceLevel.LOW,
        map_layer_path="/tmp/test.tif",
        chart_data={},
        summary="",
        methodology="",
        limitations=[],
    )
    assert result.anomaly_months == 0
    assert result.z_score_current == 0.0
    assert result.hotspot_pct == 0.0
    assert result.confidence_factors == {}


def test_compound_signal_model():
    from app.models import CompoundSignal
    signal = CompoundSignal(
        name="land_conversion",
        triggered=True,
        confidence="strong",
        description="NDVI decline overlaps with settlement growth",
        indicators=["ndvi", "buildup"],
        overlap_pct=25.3,
        affected_ha=145.0,
    )
    assert signal.triggered is True
    assert signal.confidence == "strong"
    assert len(signal.indicators) == 2