From fe25bdda7d458e22f1e092ce46118e12da4fb196 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 8 May 2026 12:18:28 -0500 Subject: [PATCH] Add Packets tests for round_coordinate types and MicE direction conversion --- test/aprsme/packets_test.exs | 91 ++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/test/aprsme/packets_test.exs b/test/aprsme/packets_test.exs index 3573bc0..41a28fa 100644 --- a/test/aprsme/packets_test.exs +++ b/test/aprsme/packets_test.exs @@ -327,6 +327,97 @@ defmodule Aprsme.PacketsTest do end end + describe "round_coordinate via store_packet for various coord types" do + test "stores Decimal-typed lat/lon" do + packet = %{ + sender: "DEC-LL", + base_callsign: "DEC-LL", + ssid: "0", + destination: "APRS", + raw_packet: "DEC-LL>APRS", + data_type: "position", + lat: Decimal.new("33.0"), + lon: Decimal.new("-96.5") + } + + assert {:ok, _packet} = Packets.store_packet(packet) + end + + test "stores integer-typed lat/lon" do + packet = %{ + sender: "INT-LL", + base_callsign: "INT-LL", + ssid: "0", + destination: "APRS", + raw_packet: "INT-LL>APRS", + data_type: "position", + lat: 33, + lon: -96 + } + + assert {:ok, _packet} = Packets.store_packet(packet) + end + + test "stores binary-string-typed lat/lon (parses via Float.parse)" do + packet = %{ + sender: "STR-LL", + base_callsign: "STR-LL", + ssid: "0", + destination: "APRS", + raw_packet: "STR-LL>APRS", + data_type: "position", + lat: "33.0", + lon: "-96.5" + } + + assert {:ok, _packet} = Packets.store_packet(packet) + end + end + + describe "extract_position_from_mic_e via store_packet with full MicE map keys" do + test "stores a packet whose data_extended is a fully-keyed MicE map" do + packet = %{ + sender: "MICE-FULL", + base_callsign: "MICE-FULL", + ssid: "0", + destination: "APRS", + raw_packet: "MICE-FULL>APRS", + data_type: "mic_e", + data_extended: %{ + lat_degrees: 33, + lat_minutes: 30.0, + lat_direction: :north, + lon_degrees: 96, + lon_minutes: 30.0, + lon_direction: :west + } + } + + assert {:ok, _packet} = Packets.store_packet(packet) + end + + test "south/west directions go negative via apply_direction" do + packet = %{ + sender: "MICE-SW", + base_callsign: "MICE-SW", + ssid: "0", + destination: "APRS", + raw_packet: "MICE-SW>APRS", + data_type: "mic_e", + data_extended: %{ + lat_degrees: 33, + lat_minutes: 0.0, + lat_direction: :south, + lon_degrees: 96, + lon_minutes: 0.0, + lon_direction: :east + } + } + + assert {:ok, _packet} = Packets.store_packet(packet) + end + end + describe "store_packet/1 with nested position shapes" do test "extracts coordinates from data_extended.position with atom keys" do # Hits find_coordinate_value(%{position: %{latitude: lat}}, :latitude)