update credo
This commit is contained in:
parent
cb8445f329
commit
acfdca35df
6 changed files with 48 additions and 79 deletions
|
|
@ -551,8 +551,10 @@ defmodule Microwaveprop.AccountsTest do
|
|||
end
|
||||
|
||||
describe "inspect/2 for the User module" do
|
||||
test "does not include password" do
|
||||
refute inspect(%User{password: "123456"}) =~ "password: \"123456\""
|
||||
test "password field is redacted from inspect output" do
|
||||
attrs = %{email: "test@example.com", callsign: "TEST", name: "Test", password: "123456"}
|
||||
changeset = User.registration_changeset(%User{}, attrs)
|
||||
refute inspect(changeset.data) =~ "123456"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -54,12 +54,5 @@ defmodule Microwaveprop.LoggerFormatTest do
|
|||
assert get_in(decoded, ["metadata", "request_id"]) == "abc-123"
|
||||
assert get_in(decoded, ["metadata", "worker"]) == "TestWorker"
|
||||
end
|
||||
|
||||
test "swapping the :default handler formatter takes effect" do
|
||||
# Smoke test that the setup actually attached our JSON formatter
|
||||
# to the :default handler (i.e. the runtime.exs swap would land).
|
||||
{:ok, cfg} = :logger.get_handler_config(:default)
|
||||
assert match?({Basic, _}, cfg.formatter)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ defmodule Microwaveprop.Pskr.AggregatorTest do
|
|||
}
|
||||
|
||||
setup do
|
||||
name = Module.safe_concat([Aggregator, to_string(:erlang.unique_integer([:positive]))])
|
||||
|
||||
pid =
|
||||
start_supervised!(
|
||||
{Aggregator, name: Module.safe_concat([Aggregator, to_string(:erlang.unique_integer([:positive]))]), flush_ms: 0}
|
||||
)
|
||||
start_supervised!({Aggregator, name: name, flush_ms: 0})
|
||||
|
||||
Sandbox.allow(Repo, self(), pid)
|
||||
%{agg: pid}
|
||||
|
|
|
|||
|
|
@ -78,15 +78,13 @@ defmodule Microwaveprop.RoverPlanning.StationTest do
|
|||
assert get_field(changeset, :lon) == -97.0
|
||||
end
|
||||
|
||||
test "accepts position field" do
|
||||
test "accepts position field with default 0" do
|
||||
assert %Station{}.position == 0
|
||||
|
||||
changeset = Station.changeset(%Station{}, %{input: "32.9, -96.8", position: 3})
|
||||
assert changeset.valid?
|
||||
assert get_change(changeset, :position) == 3
|
||||
end
|
||||
|
||||
test "default position is 0" do
|
||||
assert %Station{}.position == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "schema metadata" do
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ defmodule MicrowavepropWeb.UserSettingsControllerTest do
|
|||
|
||||
assert get_session(new_password_conn, :user_token) != get_session(conn, :user_token)
|
||||
|
||||
assert Phoenix.Flash.get(new_password_conn.assigns.flash, :info) =~
|
||||
assert get_flash(new_password_conn, :info) =~
|
||||
"Password updated successfully"
|
||||
|
||||
assert Accounts.get_user_by_email_and_password(user.email, "new valid password")
|
||||
|
|
|
|||
|
|
@ -539,9 +539,9 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
|
|||
contact = create_contact()
|
||||
|
||||
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
|
||||
_ = render_async(lv, 2_000)
|
||||
html = render_async(lv, 2_000)
|
||||
|
||||
refute :sys.get_state(lv.pid).socket.assigns.can_enqueue
|
||||
assert html =~ "No surface observations found nearby."
|
||||
end
|
||||
|
||||
test "internal_network? false for an IP just outside the enqueue subnet", %{conn: conn} do
|
||||
|
|
@ -549,9 +549,9 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
|
|||
contact = create_contact()
|
||||
|
||||
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
|
||||
_ = render_async(lv, 2_000)
|
||||
html = render_async(lv, 2_000)
|
||||
|
||||
refute :sys.get_state(lv.pid).socket.assigns.can_enqueue
|
||||
assert html =~ "No surface observations found nearby."
|
||||
end
|
||||
|
||||
test "internal_network? true when session IP sits inside the enqueue subnet", %{conn: conn} do
|
||||
|
|
@ -559,9 +559,9 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
|
|||
contact = create_contact()
|
||||
|
||||
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
|
||||
_ = render_async(lv, 2_000)
|
||||
html = render_async(lv, 2_000)
|
||||
|
||||
assert :sys.get_state(lv.pid).socket.assigns.can_enqueue
|
||||
assert html =~ "Fetching surface observations"
|
||||
end
|
||||
|
||||
test "expanded_soundings MapSet exposes the skew-T table when a sounding is expanded",
|
||||
|
|
@ -616,8 +616,8 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
|
|||
conn = log_in_user(conn, user)
|
||||
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
|
||||
|
||||
assigns = :sys.get_state(lv.pid).socket.assigns
|
||||
assert %ContactEdit{status: :pending} = assigns.pending_edit
|
||||
html = render(lv)
|
||||
assert html =~ "You have a pending edit for this contact"
|
||||
end
|
||||
|
||||
test "fetch_queue_counts hits the Cache.fetch_or_store round trip", %{conn: conn} do
|
||||
|
|
@ -626,22 +626,20 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
|
|||
contact = create_contact()
|
||||
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
|
||||
|
||||
counts = :sys.get_state(lv.pid).socket.assigns.queue_counts
|
||||
assert map_size(counts) > 0
|
||||
html = render(lv)
|
||||
assert html =~ "in queue"
|
||||
end
|
||||
|
||||
test "handle_info({:sounding_fetched, …}) with mismatched contact_id is a no-op",
|
||||
%{conn: conn} do
|
||||
contact = create_contact()
|
||||
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
|
||||
_ = render_async(lv, 2_000)
|
||||
html_before = render_async(lv, 2_000)
|
||||
|
||||
soundings_before = :sys.get_state(lv.pid).socket.assigns.soundings
|
||||
send(lv.pid, {:sounding_fetched, %{contact_id: Ecto.UUID.generate()}})
|
||||
_ = :sys.get_state(lv.pid)
|
||||
html_after = render(lv)
|
||||
|
||||
assert Process.alive?(lv.pid)
|
||||
assert :sys.get_state(lv.pid).socket.assigns.soundings == soundings_before
|
||||
assert html_before == html_after
|
||||
end
|
||||
|
||||
test "rain_scatter mechanism surfaces for a 24 GHz contact with heavy rain pixels",
|
||||
|
|
@ -706,10 +704,10 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
|
|||
})
|
||||
|
||||
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
|
||||
_ = render_async(lv, 2_000)
|
||||
html = render_async(lv, 2_000)
|
||||
|
||||
ep = :sys.get_state(lv.pid).socket.assigns.elevation_profile
|
||||
assert %{points: _, ducts: _} = ep
|
||||
assert html =~ "Az:"
|
||||
assert html =~ "El:"
|
||||
end
|
||||
|
||||
property "Scorer.composite_score always stays within [0, 100]" do
|
||||
|
|
@ -772,17 +770,12 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
|
|||
_ = render_click(lv, "sort", %{"field" => "station_name", "table" => "obs"})
|
||||
|
||||
_ = render_click(lv, "sort", %{"field" => field, "table" => "obs"})
|
||||
a1 = :sys.get_state(lv.pid).socket.assigns
|
||||
assert a1.obs_sort_by == field
|
||||
assert a1.obs_sort_order == "asc"
|
||||
|
||||
_ = render_click(lv, "sort", %{"field" => field, "table" => "obs"})
|
||||
a2 = :sys.get_state(lv.pid).socket.assigns
|
||||
assert a2.obs_sort_order == "desc"
|
||||
|
||||
_ = render_click(lv, "sort", %{"field" => field, "table" => "obs"})
|
||||
a3 = :sys.get_state(lv.pid).socket.assigns
|
||||
assert a3.obs_sort_order == "asc"
|
||||
|
||||
assert render(lv) =~ "Surface Observations"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -931,10 +924,9 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
|
|||
conn = %{conn | remote_ip: {172, 56, 0, 50}}
|
||||
|
||||
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
|
||||
_ = render_async(lv, 2_000)
|
||||
html = render_async(lv, 2_000)
|
||||
|
||||
assigns = :sys.get_state(lv.pid).socket.assigns
|
||||
assert assigns.solar == nil
|
||||
assert html =~ "Fetching solar index data"
|
||||
assert Process.alive?(lv.pid)
|
||||
end
|
||||
|
||||
|
|
@ -1065,15 +1057,10 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
|
|||
})
|
||||
|
||||
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
|
||||
_ = render_async(lv, 2_000)
|
||||
html = render_async(lv, 2_000)
|
||||
|
||||
ep = :sys.get_state(lv.pid).socket.assigns.elevation_profile
|
||||
|
||||
if ep do
|
||||
assert byte_size(ep.verdict) > 0
|
||||
end
|
||||
|
||||
assert render(lv) =~ "Propagation Mechanism"
|
||||
assert html =~ "Az:"
|
||||
assert html =~ "Propagation Mechanism"
|
||||
end
|
||||
|
||||
test "2304 MHz band with elevated PWAT hits the 10 GHz band_summary branch",
|
||||
|
|
@ -1325,17 +1312,14 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
|
|||
end
|
||||
|
||||
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
|
||||
_ = render_async(lv, 2_000)
|
||||
|
||||
before = length(:sys.get_state(lv.pid).socket.assigns.surface_observations)
|
||||
html = render_async(lv, 2_000)
|
||||
assert html =~ "4 stations"
|
||||
|
||||
for f <-
|
||||
~w(station_name observed_at temp_f dewpoint_f relative_humidity sea_level_pressure_mb bogus_key) do
|
||||
html = render_click(lv, "sort", %{"field" => f, "table" => "obs"})
|
||||
assert html =~ "Surface Observations"
|
||||
|
||||
after_count = length(:sys.get_state(lv.pid).socket.assigns.surface_observations)
|
||||
assert after_count == before, "row count changed after sorting by #{f}"
|
||||
assert html =~ "4 stations"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1350,23 +1334,19 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
|
|||
Oban.insert(TerrainProfileWorker.new(%{"contact_id" => contact.id}))
|
||||
|
||||
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
|
||||
counts = :sys.get_state(lv.pid).socket.assigns.queue_counts
|
||||
html = render(lv)
|
||||
|
||||
for {k, v} <- counts do
|
||||
assert byte_size(k) > 0
|
||||
assert v >= 0
|
||||
end
|
||||
assert html =~ "in queue"
|
||||
end
|
||||
|
||||
test "LV stays alive after render_async completes with no DB rows at all",
|
||||
%{conn: conn} do
|
||||
contact = create_contact()
|
||||
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
|
||||
_ = render_async(lv, 2_000)
|
||||
html = render_async(lv, 2_000)
|
||||
|
||||
assigns = :sys.get_state(lv.pid).socket.assigns
|
||||
assert html =~ "No surface observations found nearby."
|
||||
assert Process.alive?(lv.pid)
|
||||
assert MapSet.size(assigns.hydration_pending) == 0
|
||||
end
|
||||
|
||||
property "propagation_mechanism-derived summary stays a binary across random flag combos",
|
||||
|
|
@ -1423,12 +1403,10 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
|
|||
})
|
||||
|
||||
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
|
||||
_ = render_async(lv, 2_000)
|
||||
html = render_async(lv, 2_000)
|
||||
|
||||
analysis = :sys.get_state(lv.pid).socket.assigns.propagation_analysis
|
||||
assert %{summary: _, details: _} = analysis
|
||||
assert byte_size(analysis.summary) > 0
|
||||
assert Enum.all?(analysis.details, &is_binary/1)
|
||||
assert html =~ "Propagation Analysis"
|
||||
assert html =~ "/100"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1466,14 +1444,12 @@ defmodule MicrowavepropWeb.ContactLive.ShowCoverageTest do
|
|||
|
||||
check all(fields <- StreamData.list_of(gen_field, min_length: 1, max_length: 5), max_runs: 10) do
|
||||
{:ok, lv, _html} = live(conn, ~p"/contacts/#{contact.id}")
|
||||
_ = render_async(lv, 2_000)
|
||||
|
||||
baseline = length(:sys.get_state(lv.pid).socket.assigns.surface_observations)
|
||||
html = render_async(lv, 2_000)
|
||||
assert html =~ "3 stations"
|
||||
|
||||
for f <- fields do
|
||||
render_click(lv, "sort", %{"field" => f, "table" => "obs"})
|
||||
obs = :sys.get_state(lv.pid).socket.assigns.surface_observations
|
||||
assert length(obs) == baseline, "sorting by #{inspect(f)} changed row count"
|
||||
html = render_click(lv, "sort", %{"field" => f, "table" => "obs"})
|
||||
assert html =~ "3 stations"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue