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