defmodule Microwaveprop.Propagation.DailyOutlookTest do use Microwaveprop.DataCase, async: false alias Microwaveprop.Propagation alias Microwaveprop.Propagation.ScoreCache setup do ScoreCache.clear() on_exit(fn -> ScoreCache.clear() end) :ok end describe "daily_outlook_at/3" do test "returns an empty list when no scores have been written" do assert Propagation.daily_outlook_at(32.9, -97.0, days: 3) == [] end test "groups scores by UTC date and picks the peak per day" do # Use a lat on the grid: snap(32.9) = 32.875 (step 0.125). Write at # the snapped coords so point_forecast's internal snap-to-grid finds # the scores on disk. lat = 32.875 lon = -97.0 band = 10_000 # Day A: 5Z @ 40, 17Z @ 80 → peak 80 # Day B: 5Z @ 60 → peak 60 day_a_1 = ~U[2026-04-20 05:00:00Z] day_a_2 = ~U[2026-04-20 17:00:00Z] day_b_1 = ~U[2026-04-21 05:00:00Z] Propagation.replace_scores( [%{lat: lat, lon: lon, valid_time: day_a_1, band_mhz: band, score: 40, factors: nil}], day_a_1 ) Propagation.replace_scores( [%{lat: lat, lon: lon, valid_time: day_a_2, band_mhz: band, score: 80, factors: nil}], day_a_2 ) Propagation.replace_scores( [%{lat: lat, lon: lon, valid_time: day_b_1, band_mhz: band, score: 60, factors: nil}], day_b_1 ) outlook = Propagation.daily_outlook_at(lat, lon, band_mhz: band, days: 30) # The helper returns entries in ascending date order. assert length(outlook) >= 2 day_a = Enum.find(outlook, &(&1.date == ~D[2026-04-20])) day_b = Enum.find(outlook, &(&1.date == ~D[2026-04-21])) assert day_a.peak_score == 80 assert day_b.peak_score == 60 end end end