Add Packets tests for round_coordinate types and MicE direction conversion
This commit is contained in:
parent
5066cf7c3b
commit
fe25bdda7d
1 changed files with 91 additions and 0 deletions
|
|
@ -327,6 +327,97 @@ defmodule Aprsme.PacketsTest do
|
||||||
end
|
end
|
||||||
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
|
describe "store_packet/1 with nested position shapes" do
|
||||||
test "extracts coordinates from data_extended.position with atom keys" do
|
test "extracts coordinates from data_extended.position with atom keys" do
|
||||||
# Hits find_coordinate_value(%{position: %{latitude: lat}}, :latitude)
|
# Hits find_coordinate_value(%{position: %{latitude: lat}}, :latitude)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue