Aperture / tests /test_models.py
KSvend
refactor: rename "indicators" to "EO products" throughout
df6bf75
"""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