prop/test/mix/tasks/reset_enrichment_test.exs
Graham McIntire ded9c054ac
Multi-point path enrichment for HRRR, IEMRE, and weather data
Enqueue worker now gathers atmospheric data at pos1, midpoint, and pos2
along each QSO path instead of only pos1. Existing has_* guards prevent
duplicate fetches at each grid point.

- Add Radio.qso_path_points/1 for path point extraction
- Update hrrr_job_for_qso, iemre_job_for_qso, jobs_for_qso to iterate path points
- Refactor Weather into find_nearest_hrrr/3 and find_nearest_iemre/3
- Add hrrr_profiles_for_path/1 and iemre_for_path/1 query functions
- Add mix reset_enrichment task to trigger re-processing
2026-03-30 16:09:01 -05:00

65 lines
1.6 KiB
Elixir

defmodule Mix.Tasks.ResetEnrichmentTest do
use Microwaveprop.DataCase, async: true
alias Microwaveprop.Radio.Qso
alias Mix.Tasks.ResetEnrichment
defp create_queued_qso do
import Ecto.Query
default = %{
station1: "W5XD",
station2: "K5TR",
qso_timestamp: ~U[2026-03-28 18:00:00Z],
mode: "CW",
band: Decimal.new("1296"),
grid1: "EM12",
grid2: "EM00",
pos1: %{"lat" => 32.9, "lon" => -97.0},
pos2: %{"lat" => 30.3, "lon" => -97.7},
distance_km: Decimal.new("295")
}
{:ok, qso} =
%Qso{}
|> Qso.changeset(default)
|> Repo.insert()
# Set all queued flags to true (not in changeset cast)
Qso
|> where([q], q.id == ^qso.id)
|> Repo.update_all(set: [weather_queued: true, hrrr_queued: true, iemre_queued: true, terrain_queued: true])
Repo.get!(Qso, qso.id)
end
describe "run/1" do
test "resets weather_queued, hrrr_queued, and iemre_queued to false" do
qso = create_queued_qso()
assert qso.weather_queued == true
assert qso.hrrr_queued == true
assert qso.iemre_queued == true
ResetEnrichment.run([])
updated = Repo.get!(Qso, qso.id)
assert updated.weather_queued == false
assert updated.hrrr_queued == false
assert updated.iemre_queued == false
end
test "does not reset terrain_queued" do
qso = create_queued_qso()
ResetEnrichment.run([])
updated = Repo.get!(Qso, qso.id)
assert updated.terrain_queued == true
end
test "handles empty database" do
assert :ok = ResetEnrichment.run([])
end
end
end