- Add 17 missing @spec annotations (layouts, error_json, error_html, skewt_svg) - Move 12+ nested alias/import/require to module top level - Add phx-change/id attributes to 11 raw HTML <form> tags - Remove 4 unused LiveView assigns (:bounds, :data_provider) - Add 3 missing doctest references (HrrrNativeClient, BulkFetch, Accounts) - Break 2 long lines (path_compute.ex:382) - Strengthen weak test assertions (is_binary→byte_size, is_list→!=[]) - Replace Module.concat with Module.safe_concat (2 occurrences) - Replace length/1 > 0 with list != [] (9 occurrences) - Remove no-op assert true, fix no-assertion tests Remaining: 24 socket.assigns introspection warnings (deliberate test pattern for observable behavior testing), 1 formatter-resistant long line, 3 app-code usage warnings.
50 lines
1.3 KiB
Elixir
50 lines
1.3 KiB
Elixir
defmodule Microwaveprop.Buildings.BulkFetchTest do
|
|
use ExUnit.Case, async: false
|
|
|
|
import ExUnit.CaptureLog
|
|
|
|
alias Microwaveprop.Buildings.BulkFetch
|
|
|
|
doctest BulkFetch
|
|
|
|
setup do
|
|
prev = Application.get_env(:microwaveprop, :ms_footprints_http_get)
|
|
|
|
on_exit(fn ->
|
|
if prev,
|
|
do: Application.put_env(:microwaveprop, :ms_footprints_http_get, prev),
|
|
else: Application.delete_env(:microwaveprop, :ms_footprints_http_get)
|
|
end)
|
|
|
|
:ok
|
|
end
|
|
|
|
describe "run/4" do
|
|
test "returns the result struct with zero counters when index is empty" do
|
|
# Stub the dataset index fetch to return empty TSV -> no quadkeys
|
|
# in index -> no downloads attempted.
|
|
Application.put_env(:microwaveprop, :ms_footprints_http_get, fn _url, _opts ->
|
|
{:ok, %{status: 200, body: "Location\tQuadkey\tUrl\tSize\n"}}
|
|
end)
|
|
|
|
# Need to invalidate the dataset_index cache so our stub takes effect.
|
|
Microwaveprop.Cache.invalidate(:ms_footprints_index)
|
|
|
|
capture_log(fn ->
|
|
result = BulkFetch.run(32.8, -97.0, 1, concurrency: 1)
|
|
send(self(), result)
|
|
end)
|
|
|
|
assert_received %{
|
|
downloaded: 0,
|
|
cached: 0,
|
|
failed: 0,
|
|
missing: missing,
|
|
cache_dir: cache_dir
|
|
}
|
|
|
|
assert is_integer(missing)
|
|
assert byte_size(cache_dir) > 0
|
|
end
|
|
end
|
|
end
|