- Weather.MapLayers: unit tests for all/0, default_id/0, valid_id?/1 (25→100%) - Rover.LinkMargin: link_margin_db ScoresFile round-trip tests (57→100%) - Rover.Elevation: SRTM tile file read path + void sentinel (44→94%) - Pskr.Aggregator: pending_count, empty flush tests (65→74%) - Buildings.MsFootprints: quadkey/bbox pure function tests (51→51%) - Weather.Grib2.Wgrib2: property tests for parse_lon_val_segment (23→23%) - test/support/data_case: File.rm_rf -> rm_rf to fix concurrent race
68 lines
2 KiB
Elixir
68 lines
2 KiB
Elixir
defmodule Microwaveprop.Buildings.MsFootprintsTest do
|
|
use ExUnit.Case, async: true
|
|
|
|
alias Microwaveprop.Buildings.MsFootprints
|
|
|
|
describe "quadkey/3" do
|
|
test "returns a string of length equal to zoom" do
|
|
assert String.length(MsFootprints.quadkey(33.0, -97.0, 9)) == 9
|
|
assert String.length(MsFootprints.quadkey(33.0, -97.0, 5)) == 5
|
|
end
|
|
|
|
test "returns the same quadkey for the same coordinates" do
|
|
q1 = MsFootprints.quadkey(33.0, -97.0, 9)
|
|
q2 = MsFootprints.quadkey(33.0, -97.0, 9)
|
|
assert q1 == q2
|
|
end
|
|
|
|
test "coordinates far apart produce different quadkeys" do
|
|
q1 = MsFootprints.quadkey(33.0, -97.0, 9)
|
|
q2 = MsFootprints.quadkey(40.0, -80.0, 9)
|
|
refute q1 == q2
|
|
end
|
|
end
|
|
|
|
describe "quadkeys_for_bbox/2" do
|
|
test "returns a list of quadkey strings" do
|
|
bbox = %{"south" => 32.0, "north" => 34.0, "west" => -98.0, "east" => -96.0}
|
|
keys = MsFootprints.quadkeys_for_bbox(bbox, 9)
|
|
|
|
assert is_list(keys)
|
|
assert length(keys) > 0
|
|
assert Enum.all?(keys, &is_binary/1)
|
|
end
|
|
|
|
test "each quadkey has the expected length" do
|
|
bbox = %{"south" => 32.0, "north" => 34.0, "west" => -98.0, "east" => -96.0}
|
|
keys = MsFootprints.quadkeys_for_bbox(bbox, 9)
|
|
|
|
Enum.each(keys, fn k ->
|
|
assert String.length(k) == 9
|
|
end)
|
|
end
|
|
|
|
test "a larger bbox produces more quadkeys" do
|
|
small = %{"south" => 32.5, "north" => 33.0, "west" => -97.5, "east" => -96.5}
|
|
large = %{"south" => 32.0, "north" => 34.0, "west" => -98.0, "east" => -96.0}
|
|
|
|
small_keys = MsFootprints.quadkeys_for_bbox(small, 9)
|
|
large_keys = MsFootprints.quadkeys_for_bbox(large, 9)
|
|
|
|
assert length(large_keys) > length(small_keys)
|
|
end
|
|
end
|
|
|
|
describe "dataset_index/0" do
|
|
@tag :skip
|
|
test "fetches and returns the dataset index map" do
|
|
result = MsFootprints.dataset_index()
|
|
assert is_map(result)
|
|
end
|
|
end
|
|
|
|
describe "cache_dir/0" do
|
|
test "returns a string" do
|
|
assert is_binary(MsFootprints.cache_dir())
|
|
end
|
|
end
|
|
end
|