Test: More async/sync tweaks.
This commit is contained in:
parent
b17c36c45a
commit
9d5ce82221
11 changed files with 53 additions and 19 deletions
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.ConfigTest do
|
defmodule Pleroma.ConfigTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase
|
||||||
|
|
||||||
test "get/1 with an atom" do
|
test "get/1 with an atom" do
|
||||||
assert Pleroma.Config.get(:instance) == Application.get_env(:pleroma, :instance)
|
assert Pleroma.Config.get(:instance) == Application.get_env(:pleroma, :instance)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.HTTP.AdapterHelper.GunTest do
|
defmodule Pleroma.HTTP.AdapterHelper.GunTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case
|
||||||
use Pleroma.Tests.Helpers
|
use Pleroma.Tests.Helpers
|
||||||
|
|
||||||
import Mox
|
import Mox
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.Transmogrifier.UserUpdateHandlingTest do
|
defmodule Pleroma.Web.ActivityPub.Transmogrifier.UserUpdateHandlingTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase
|
||||||
|
|
||||||
alias Pleroma.Activity
|
alias Pleroma.Activity
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
@ -103,7 +103,7 @@ test "it works with custom profile fields" do
|
||||||
%{"name" => "foo1", "value" => "updated"}
|
%{"name" => "foo1", "value" => "updated"}
|
||||||
]
|
]
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :max_remote_account_fields], 2)
|
clear_config([:instance, :max_remote_account_fields], 2)
|
||||||
|
|
||||||
update_data =
|
update_data =
|
||||||
update_data
|
update_data
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
use Pleroma.Web.ConnCase, async: true
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
import ExUnit.CaptureLog
|
import ExUnit.CaptureLog
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.MastodonAPI.DomainBlockControllerTest do
|
defmodule Pleroma.Web.MastodonAPI.DomainBlockControllerTest do
|
||||||
|
# TODO: Should not need Cachex
|
||||||
use Pleroma.Web.ConnCase
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
|
defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
|
||||||
|
# TODO: Should not need Cachex
|
||||||
use Pleroma.Web.ConnCase
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
|
@ -11,8 +11,6 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
|
||||||
import Mock
|
import Mock
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
setup do: clear_config([:instance, :max_account_fields])
|
|
||||||
|
|
||||||
describe "updating credentials" do
|
describe "updating credentials" do
|
||||||
setup do: oauth_access(["write:accounts"])
|
setup do: oauth_access(["write:accounts"])
|
||||||
setup :request_content_type
|
setup :request_content_type
|
||||||
|
@ -446,7 +444,7 @@ test "update fields when invalid request", %{conn: conn} do
|
||||||
|> patch("/api/v1/accounts/update_credentials", %{"fields_attributes" => fields})
|
|> patch("/api/v1/accounts/update_credentials", %{"fields_attributes" => fields})
|
||||||
|> json_response_and_validate_schema(403)
|
|> json_response_and_validate_schema(403)
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :max_account_fields], 1)
|
clear_config([:instance, :max_account_fields], 1)
|
||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
%{"name" => "foo", "value" => "bar"},
|
%{"name" => "foo", "value" => "bar"},
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.Plugs.EnsurePublicOrAuthenticatedPlugTest do
|
defmodule Pleroma.Web.Plugs.EnsurePublicOrAuthenticatedPlugTest do
|
||||||
use Pleroma.Web.ConnCase, async: true
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.Plugs.UserEnabledPlugTest do
|
defmodule Pleroma.Web.Plugs.UserEnabledPlugTest do
|
||||||
use Pleroma.Web.ConnCase, async: true
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
alias Pleroma.Web.Plugs.UserEnabledPlug
|
alias Pleroma.Web.Plugs.UserEnabledPlug
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.RelMeTest do
|
defmodule Pleroma.Web.RelMeTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase
|
||||||
|
|
||||||
setup_all do
|
setup_all do
|
||||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||||
|
|
|
@ -14,18 +14,27 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
setup do
|
|
||||||
Tesla.Mock.mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
|
||||||
:ok
|
|
||||||
end
|
|
||||||
|
|
||||||
setup_all do: clear_config([:instance, :federating], true)
|
setup_all do: clear_config([:instance, :federating], true)
|
||||||
setup do: clear_config([:instance])
|
|
||||||
setup do: clear_config([:frontend_configurations, :pleroma_fe])
|
|
||||||
setup do: clear_config([:user, :deny_follow_blocked])
|
setup do: clear_config([:user, :deny_follow_blocked])
|
||||||
|
|
||||||
describe "GET /ostatus_subscribe - remote_follow/2" do
|
describe "GET /ostatus_subscribe - remote_follow/2" do
|
||||||
test "adds status to pleroma instance if the `acct` is a status", %{conn: conn} do
|
test "adds status to pleroma instance if the `acct` is a status", %{conn: conn} do
|
||||||
|
Tesla.Mock.mock(fn
|
||||||
|
%{method: :get, url: "https://mastodon.social/users/emelie/statuses/101849165031453009"} ->
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
headers: [{"content-type", "application/activity+json"}],
|
||||||
|
body: File.read!("test/fixtures/tesla_mock/status.emelie.json")
|
||||||
|
}
|
||||||
|
|
||||||
|
%{method: :get, url: "https://mastodon.social/users/emelie"} ->
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
headers: [{"content-type", "application/activity+json"}],
|
||||||
|
body: File.read!("test/fixtures/tesla_mock/emelie.json")
|
||||||
|
}
|
||||||
|
end)
|
||||||
|
|
||||||
assert conn
|
assert conn
|
||||||
|> get(
|
|> get(
|
||||||
remote_follow_path(conn, :follow, %{
|
remote_follow_path(conn, :follow, %{
|
||||||
|
@ -36,6 +45,15 @@ test "adds status to pleroma instance if the `acct` is a status", %{conn: conn}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "show follow account page if the `acct` is a account link", %{conn: conn} do
|
test "show follow account page if the `acct` is a account link", %{conn: conn} do
|
||||||
|
Tesla.Mock.mock(fn
|
||||||
|
%{method: :get, url: "https://mastodon.social/users/emelie"} ->
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
headers: [{"content-type", "application/activity+json"}],
|
||||||
|
body: File.read!("test/fixtures/tesla_mock/emelie.json")
|
||||||
|
}
|
||||||
|
end)
|
||||||
|
|
||||||
response =
|
response =
|
||||||
conn
|
conn
|
||||||
|> get(remote_follow_path(conn, :follow, %{acct: "https://mastodon.social/users/emelie"}))
|
|> get(remote_follow_path(conn, :follow, %{acct: "https://mastodon.social/users/emelie"}))
|
||||||
|
@ -45,6 +63,15 @@ test "show follow account page if the `acct` is a account link", %{conn: conn} d
|
||||||
end
|
end
|
||||||
|
|
||||||
test "show follow page if the `acct` is a account link", %{conn: conn} do
|
test "show follow page if the `acct` is a account link", %{conn: conn} do
|
||||||
|
Tesla.Mock.mock(fn
|
||||||
|
%{method: :get, url: "https://mastodon.social/users/emelie"} ->
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 200,
|
||||||
|
headers: [{"content-type", "application/activity+json"}],
|
||||||
|
body: File.read!("test/fixtures/tesla_mock/emelie.json")
|
||||||
|
}
|
||||||
|
end)
|
||||||
|
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
response =
|
response =
|
||||||
|
@ -56,7 +83,14 @@ test "show follow page if the `acct` is a account link", %{conn: conn} do
|
||||||
assert response =~ "Remote follow"
|
assert response =~ "Remote follow"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "show follow page with error when user cannot fecth by `acct` link", %{conn: conn} do
|
test "show follow page with error when user can not be fetched by `acct` link", %{conn: conn} do
|
||||||
|
Tesla.Mock.mock(fn
|
||||||
|
%{method: :get, url: "https://mastodon.social/users/not_found"} ->
|
||||||
|
%Tesla.Env{
|
||||||
|
status: 404
|
||||||
|
}
|
||||||
|
end)
|
||||||
|
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
assert capture_log(fn ->
|
assert capture_log(fn ->
|
||||||
|
|
Loading…
Reference in a new issue