test: Packets store_packet with various coordinate encodings
This commit is contained in:
parent
9cdc981bfb
commit
1524497531
1 changed files with 55 additions and 0 deletions
|
|
@ -220,6 +220,61 @@ defmodule Aprsme.PacketsTest do
|
|||
assert is_binary(packet.device_identifier)
|
||||
end
|
||||
|
||||
test "handles binary position from data_extended" do
|
||||
packet_data = %{
|
||||
sender: "STRPOS1",
|
||||
base_callsign: "STRPOS1",
|
||||
ssid: "0",
|
||||
destination: "APRS",
|
||||
raw_packet: "STRPOS1>APRS",
|
||||
data_type: "position",
|
||||
data_extended: %{
|
||||
latitude: "33.0",
|
||||
longitude: "-96.5"
|
||||
}
|
||||
}
|
||||
|
||||
assert {:ok, packet} = Packets.store_packet(packet_data)
|
||||
assert packet.sender == "STRPOS1"
|
||||
end
|
||||
|
||||
test "handles binary position with non-parseable decimal" do
|
||||
packet_data = %{
|
||||
sender: "BADPOS1",
|
||||
base_callsign: "BADPOS1",
|
||||
ssid: "0",
|
||||
destination: "APRS",
|
||||
raw_packet: "BADPOS1>APRS",
|
||||
data_type: "position",
|
||||
data_extended: %{
|
||||
latitude: "invalid",
|
||||
longitude: "-96.5"
|
||||
}
|
||||
}
|
||||
|
||||
# Without parseable lat, extract_position returns {nil, nil} — packet stores
|
||||
# but without position data.
|
||||
result = Packets.store_packet(packet_data)
|
||||
# Should either succeed (no position) or be a validation error.
|
||||
assert match?({:ok, _}, result) or match?({:error, _}, result)
|
||||
end
|
||||
|
||||
test "supports integer lat/lon that gets coerced to float" do
|
||||
packet_data = %{
|
||||
sender: "INTCOORD1",
|
||||
base_callsign: "INTCOORD1",
|
||||
ssid: "0",
|
||||
destination: "APRS",
|
||||
raw_packet: "INTCOORD1>APRS",
|
||||
data_type: "position",
|
||||
lat: 33,
|
||||
lon: -96
|
||||
}
|
||||
|
||||
assert {:ok, packet} = Packets.store_packet(packet_data)
|
||||
assert packet.sender == "INTCOORD1"
|
||||
end
|
||||
|
||||
test "handles a binary lat/lon that can be parsed" do
|
||||
packet_data = %{
|
||||
sender: "BINCOORD1",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue