Improved in-test clear_config/n applicability (setup / setup_all / in-test usage).
This commit is contained in:
parent
0e27c274f4
commit
1c05f539aa
84 changed files with 196 additions and 298 deletions
|
|
@ -9,7 +9,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
|||
use Pleroma.Web.ConnCase
|
||||
|
||||
import Pleroma.Factory
|
||||
clear_config([:instance, :max_account_fields])
|
||||
|
||||
setup do: clear_config([:instance, :max_account_fields])
|
||||
|
||||
describe "updating credentials" do
|
||||
setup do: oauth_access(["write:accounts"])
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
import Pleroma.Factory
|
||||
|
||||
describe "account fetching" do
|
||||
clear_config([:instance, :limit_to_local_content])
|
||||
setup do: clear_config([:instance, :limit_to_local_content])
|
||||
|
||||
test "works by id" do
|
||||
user = insert(:user)
|
||||
|
|
@ -150,13 +150,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
describe "user fetching with restrict unauthenticated profiles for local and remote" do
|
||||
setup do: local_and_remote_users()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :local], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :local], true)
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}")
|
||||
|
|
@ -186,9 +182,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
describe "user fetching with restrict unauthenticated profiles for local" do
|
||||
setup do: local_and_remote_users()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :local], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :local], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}")
|
||||
|
|
@ -215,9 +209,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
describe "user fetching with restrict unauthenticated profiles for remote" do
|
||||
setup do: local_and_remote_users()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}")
|
||||
|
|
@ -405,13 +397,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
setup do: local_and_remote_users()
|
||||
setup :local_and_remote_activities
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :local], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :local], true)
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses")
|
||||
|
|
@ -442,9 +430,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
setup do: local_and_remote_users()
|
||||
setup :local_and_remote_activities
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :local], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :local], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses")
|
||||
|
|
@ -472,9 +458,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
setup do: local_and_remote_users()
|
||||
setup :local_and_remote_activities
|
||||
|
||||
clear_config([:restrict_unauthenticated, :profiles, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :profiles, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses")
|
||||
|
|
@ -806,7 +790,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
[valid_params: valid_params]
|
||||
end
|
||||
|
||||
clear_config([:instance, :account_activation_required])
|
||||
setup do: clear_config([:instance, :account_activation_required])
|
||||
|
||||
test "Account registration via Application", %{conn: conn} do
|
||||
conn =
|
||||
|
|
@ -904,7 +888,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
end)
|
||||
end
|
||||
|
||||
clear_config([:instance, :account_activation_required])
|
||||
setup do: clear_config([:instance, :account_activation_required])
|
||||
|
||||
test "returns bad_request if missing email params when :account_activation_required is enabled",
|
||||
%{conn: conn, valid_params: valid_params} do
|
||||
|
|
@ -961,7 +945,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
end
|
||||
|
||||
describe "create account by app / rate limit" do
|
||||
clear_config([:rate_limit, :app_account_creation], {10_000, 2})
|
||||
setup do: clear_config([:rate_limit, :app_account_creation], {10_000, 2})
|
||||
|
||||
test "respects rate limit setting", %{conn: conn} do
|
||||
app_token = insert(:oauth_token, user: nil)
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
|
|||
[image: image]
|
||||
end
|
||||
|
||||
clear_config([:media_proxy])
|
||||
clear_config([Pleroma.Upload])
|
||||
setup do: clear_config([:media_proxy])
|
||||
setup do: clear_config([Pleroma.Upload])
|
||||
|
||||
test "returns uploaded image", %{conn: conn, image: image} do
|
||||
desc = "Description of the image"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityControllerTest do
|
|||
import Pleroma.Factory
|
||||
import Ecto.Query
|
||||
|
||||
clear_config([ScheduledActivity, :enabled])
|
||||
setup do: clear_config([ScheduledActivity, :enabled])
|
||||
|
||||
test "shows scheduled activities" do
|
||||
%{user: user, conn: conn} = oauth_access(["read:statuses"])
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
import Pleroma.Factory
|
||||
|
||||
clear_config([:instance, :federating])
|
||||
clear_config([:instance, :allow_relay])
|
||||
clear_config([:rich_media, :enabled])
|
||||
setup do: clear_config([:instance, :federating])
|
||||
setup do: clear_config([:instance, :allow_relay])
|
||||
setup do: clear_config([:rich_media, :enabled])
|
||||
|
||||
describe "posting statuses" do
|
||||
setup do: oauth_access(["write:statuses"])
|
||||
|
|
@ -485,13 +485,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
describe "status with restrict unauthenticated activities for local and remote" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :local], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :local], true)
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :remote], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
|
||||
|
|
@ -520,9 +516,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
describe "status with restrict unauthenticated activities for local" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :local], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :local], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
|
||||
|
|
@ -548,9 +542,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
describe "status with restrict unauthenticated activities for remote" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :remote], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/statuses/#{local.id}")
|
||||
|
|
@ -614,13 +606,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
describe "getting statuses by ids with restricted unauthenticated for local and remote" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :local], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :local], true)
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :remote], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
|
||||
|
|
@ -640,9 +628,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
describe "getting statuses by ids with restricted unauthenticated for local" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :local], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :local], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
|
||||
|
|
@ -663,9 +649,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
describe "getting statuses by ids with restricted unauthenticated for remote" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :activities, :remote]) do
|
||||
Config.put([:restrict_unauthenticated, :activities, :remote], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :activities, :remote], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
|
||||
res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
|
||||
|
|
@ -908,7 +892,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
%{activity: activity}
|
||||
end
|
||||
|
||||
clear_config([:instance, :max_pinned_statuses], 1)
|
||||
setup do: clear_config([:instance, :max_pinned_statuses], 1)
|
||||
|
||||
test "pin status", %{conn: conn, user: user, activity: activity} do
|
||||
id_str = to_string(activity.id)
|
||||
|
|
|
|||
|
|
@ -100,13 +100,9 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
describe "public with restrict unauthenticated timeline for local and federated timelines" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :timelines, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :timelines, :local], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :timelines, :local], true)
|
||||
|
||||
clear_config([:restrict_unauthenticated, :timelines, :federated]) do
|
||||
Config.put([:restrict_unauthenticated, :timelines, :federated], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :timelines, :federated], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn} do
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
|
||||
|
|
@ -136,9 +132,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
describe "public with restrict unauthenticated timeline for local" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :timelines, :local]) do
|
||||
Config.put([:restrict_unauthenticated, :timelines, :local], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :timelines, :local], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn} do
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
|
||||
|
|
@ -165,9 +159,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
describe "public with restrict unauthenticated timeline for remote" do
|
||||
setup do: local_and_remote_activities()
|
||||
|
||||
clear_config([:restrict_unauthenticated, :timelines, :federated]) do
|
||||
Config.put([:restrict_unauthenticated, :timelines, :federated], true)
|
||||
end
|
||||
setup do: clear_config([:restrict_unauthenticated, :timelines, :federated], true)
|
||||
|
||||
test "if user is unauthenticated", %{conn: conn} do
|
||||
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue