Tests: Stub the Pipeline mocks with the real modules when needed.

This commit is contained in:
lain 2020-12-16 20:28:36 +01:00
parent 74596982be
commit d5a824b463
83 changed files with 168 additions and 2 deletions

View File

@ -14,6 +14,8 @@ defmodule Mix.Tasks.Pleroma.DatabaseTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
setup_all do setup_all do
Mix.shell(Mix.Shell.Process) Mix.shell(Mix.Shell.Process)

View File

@ -12,6 +12,8 @@ defmodule Mix.Tasks.Pleroma.RelayTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
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)

View File

@ -20,6 +20,8 @@ defmodule Mix.Tasks.Pleroma.UserTest do
import Mock import Mock
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
setup_all do setup_all do
Mix.shell(Mix.Shell.Process) Mix.shell(Mix.Shell.Process)

View File

@ -11,6 +11,8 @@ defmodule Pleroma.ActivityTest do
alias Pleroma.ThreadMute alias Pleroma.ThreadMute
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
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)
:ok :ok

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Chat.MessageReferenceTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
describe "messages" do describe "messages" do
test "it returns the last message in a chat" do test "it returns the last message in a chat" do
user = insert(:user) user = insert(:user)

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
alias Pleroma.User alias Pleroma.User
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
@moduletag stubbed_pipeline: true
test "getting a participation will also preload things" do test "getting a participation will also preload things" do
user = insert(:user) user = insert(:user)
other_user = insert(:user) other_user = insert(:user)

View File

@ -13,6 +13,8 @@ defmodule Pleroma.MigrationHelper.NotificationBackfillTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
describe "fill_in_notification_types" do describe "fill_in_notification_types" do
test "it fills in missing notification types" do test "it fills in missing notification types" do
user = insert(:user) user = insert(:user)

View File

@ -21,6 +21,8 @@ defmodule Pleroma.NotificationTest do
alias Pleroma.Web.Push alias Pleroma.Web.Push
alias Pleroma.Web.Streamer alias Pleroma.Web.Streamer
@moduletag stubbed_pipeline: true
describe "create_notifications" do describe "create_notifications" do
test "never returns nil" do test "never returns nil" do
user = insert(:user) user = insert(:user)

View File

@ -13,6 +13,8 @@ defmodule Pleroma.Object.FetcherTest do
import Mock import Mock
import Tesla.Mock import Tesla.Mock
@moduletag stubbed_pipeline: true
setup do setup do
mock(fn mock(fn
%{method: :get, url: "https://mastodon.example.org/users/userisgone"} -> %{method: :get, url: "https://mastodon.example.org/users/userisgone"} ->

View File

@ -14,6 +14,8 @@ defmodule Pleroma.ObjectTest do
alias Pleroma.Tests.ObanHelpers alias Pleroma.Tests.ObanHelpers
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
@moduletag stubbed_pipeline: true
setup do setup do
mock(fn env -> apply(HttpRequestMock, :request, [env]) end) mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok :ok

View File

@ -10,6 +10,8 @@ defmodule Pleroma.StatsTest do
alias Pleroma.Stats alias Pleroma.Stats
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
@moduletag stubbed_pipeline: true
describe "user count" do describe "user count" do
test "it ignores internal users" do test "it ignores internal users" do
_user = insert(:user, local: true) _user = insert(:user, local: true)

View File

@ -16,6 +16,8 @@ defmodule Pleroma.User.BackupTest do
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
alias Pleroma.Workers.BackupWorker alias Pleroma.Workers.BackupWorker
@moduletag stubbed_pipeline: true
setup do setup do
clear_config([Pleroma.Upload, :uploader]) clear_config([Pleroma.Upload, :uploader])
clear_config([Backup, :limit_days]) clear_config([Backup, :limit_days])

View File

@ -12,6 +12,8 @@ defmodule Pleroma.User.ImportTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
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)
:ok :ok

View File

@ -10,6 +10,8 @@ defmodule Pleroma.User.WelcomeChatMessageTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
setup do: clear_config([:welcome]) setup do: clear_config([:welcome])
describe "post_message/1" do describe "post_message/1" do

View File

@ -19,6 +19,8 @@ defmodule Pleroma.UserTest do
import ExUnit.CaptureLog import ExUnit.CaptureLog
import Swoosh.TestAssertions import Swoosh.TestAssertions
@moduletag stubbed_pipeline: true
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)
:ok :ok

View File

@ -26,6 +26,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
require Pleroma.Constants require Pleroma.Constants
@moduletag stubbed_pipeline: true
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)
:ok :ok

View File

@ -22,6 +22,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
import Pleroma.Factory import Pleroma.Factory
import Tesla.Mock import Tesla.Mock
@moduletag stubbed_pipeline: true
setup do setup do
mock(fn env -> apply(HttpRequestMock, :request, [env]) end) mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok :ok

View File

@ -10,6 +10,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicyTest do
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
@moduletag stubbed_pipeline: true
setup do setup do
user = insert(:user) user = insert(:user)

View File

@ -9,6 +9,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
alias Pleroma.Web.ActivityPub.MRF.SimplePolicy alias Pleroma.Web.ActivityPub.MRF.SimplePolicy
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
@moduletag stubbed_pipeline: true
setup do: setup do:
clear_config(:mrf_simple, clear_config(:mrf_simple,
media_removal: [], media_removal: [],

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AcceptValidationTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
setup do setup do
follower = insert(:user) follower = insert(:user)
followed = insert(:user, local: false) followed = insert(:user, local: false)

View File

@ -12,6 +12,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AnnounceValidationTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
describe "announces" do describe "announces" do
setup do setup do
user = insert(:user) user = insert(:user)

View File

@ -12,6 +12,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatValidationTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
describe "chat message create activities" do describe "chat message create activities" do
test "it is invalid if the object already exists" do test "it is invalid if the object already exists" do
user = insert(:user) user = insert(:user)

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactHandlingTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
describe "EmojiReacts" do describe "EmojiReacts" do
setup do setup do
user = insert(:user) user = insert(:user)

View File

@ -12,6 +12,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.LikeValidationTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
describe "likes" do describe "likes" do
setup do setup do
user = insert(:user) user = insert(:user)

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.RejectValidationTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
setup do setup do
follower = insert(:user) follower = insert(:user)
followed = insert(:user, local: false) followed = insert(:user, local: false)

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.UndoHandlingTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
describe "Undos" do describe "Undos" do
setup do setup do
user = insert(:user) user = insert(:user)

View File

@ -18,6 +18,8 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
@as_public "https://www.w3.org/ns/activitystreams#Public" @as_public "https://www.w3.org/ns/activitystreams#Public"
@moduletag stubbed_pipeline: true
setup do setup do
mock(fn env -> apply(HttpRequestMock, :request, [env]) end) mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok :ok

View File

@ -14,6 +14,8 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do
import Pleroma.Factory import Pleroma.Factory
import Mock import Mock
@moduletag stubbed_pipeline: true
test "gets an actor for the relay" do test "gets an actor for the relay" do
user = Relay.get_actor() user = Relay.get_actor()
assert user.ap_id == "#{Pleroma.Web.Endpoint.url()}/relay" assert user.ap_id == "#{Pleroma.Web.Endpoint.url()}/relay"

View File

@ -23,6 +23,8 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
import Mock import Mock
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
describe "handle_after_transaction" do describe "handle_after_transaction" do
test "it streams out notifications and streams" do test "it streams out notifications and streams" do
author = insert(:user, local: true) author = insert(:user, local: true)

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
test "it works for incoming accepts which were pre-accepted" do test "it works for incoming accepts which were pre-accepted" do
follower = insert(:user) follower = insert(:user)
followed = insert(:user) followed = insert(:user)

View File

@ -12,6 +12,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnnounceHandlingTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
test "it works for incoming honk announces" do test "it works for incoming honk announces" do
user = insert(:user, ap_id: "https://honktest/u/test", local: false) user = insert(:user, ap_id: "https://honktest/u/test", local: false)
other_user = insert(:user) other_user = insert(:user)

View File

@ -12,6 +12,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnswerHandlingTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
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)
:ok :ok

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.ArticleHandlingTest do
alias Pleroma.Object.Fetcher alias Pleroma.Object.Fetcher
alias Pleroma.Web.ActivityPub.Transmogrifier alias Pleroma.Web.ActivityPub.Transmogrifier
@moduletag stubbed_pipeline: true
test "Pterotype (Wordpress Plugin) Article" do test "Pterotype (Wordpress Plugin) Article" do
Tesla.Mock.mock(fn %{url: "https://wedistribute.org/wp-json/pterotype/v1/actor/-blog"} -> Tesla.Mock.mock(fn %{url: "https://wedistribute.org/wp-json/pterotype/v1/actor/-blog"} ->
%Tesla.Env{ %Tesla.Env{

View File

@ -12,6 +12,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AudioHandlingTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
test "it works for incoming listens" do test "it works for incoming listens" do
_user = insert(:user, ap_id: "http://mastodon.example.org/users/admin") _user = insert(:user, ap_id: "http://mastodon.example.org/users/admin")

View File

@ -10,6 +10,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.BlockHandlingTest do
alias Pleroma.Web.ActivityPub.Transmogrifier alias Pleroma.Web.ActivityPub.Transmogrifier
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
test "it works for incoming blocks" do test "it works for incoming blocks" do
user = insert(:user) user = insert(:user)

View File

@ -12,6 +12,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageTest do
alias Pleroma.Object alias Pleroma.Object
alias Pleroma.Web.ActivityPub.Transmogrifier alias Pleroma.Web.ActivityPub.Transmogrifier
@moduletag stubbed_pipeline: true
describe "handle_incoming" do describe "handle_incoming" do
test "handles chonks with attachment" do test "handles chonks with attachment" do
data = %{ data = %{

View File

@ -14,6 +14,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.DeleteHandlingTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
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)
:ok :ok

View File

@ -12,6 +12,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.EmojiReactHandlingTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
test "it works for incoming emoji reactions" do test "it works for incoming emoji reactions" do
user = insert(:user) user = insert(:user)
other_user = insert(:user, local: false) other_user = insert(:user, local: false)

View File

@ -7,6 +7,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.EventHandlingTest do
use Pleroma.DataCase use Pleroma.DataCase
alias Pleroma.Object.Fetcher alias Pleroma.Object.Fetcher
@moduletag stubbed_pipeline: true
test "Mobilizon Event object" do test "Mobilizon Event object" do
Tesla.Mock.mock(fn Tesla.Mock.mock(fn

View File

@ -15,6 +15,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
import Ecto.Query import Ecto.Query
import Mock import Mock
@moduletag stubbed_pipeline: true
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)
:ok :ok

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.LikeHandlingTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
test "it works for incoming likes" do test "it works for incoming likes" do
user = insert(:user) user = insert(:user)

View File

@ -16,6 +16,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do
import Pleroma.Factory import Pleroma.Factory
import ExUnit.CaptureLog import ExUnit.CaptureLog
@moduletag stubbed_pipeline: true
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)
:ok :ok

View File

@ -12,6 +12,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.QuestionHandlingTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
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)
:ok :ok

View File

@ -12,6 +12,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
test "it fails for incoming rejects which cannot be correlated" do test "it fails for incoming rejects which cannot be correlated" do
follower = insert(:user) follower = insert(:user)
followed = insert(:user, is_locked: true) followed = insert(:user, is_locked: true)

View File

@ -13,6 +13,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
test "it works for incoming emoji reaction undos" do test "it works for incoming emoji reaction undos" do
user = insert(:user) user = insert(:user)

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UserUpdateHandlingTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
test "it works for incoming update activities" do test "it works for incoming update activities" do
user = insert(:user, local: false) user = insert(:user, local: false)

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.VideoHandlingTest do
alias Pleroma.Object.Fetcher alias Pleroma.Object.Fetcher
alias Pleroma.Web.ActivityPub.Transmogrifier alias Pleroma.Web.ActivityPub.Transmogrifier
@moduletag stubbed_pipeline: true
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)
:ok :ok

View File

@ -18,6 +18,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
import Pleroma.Factory import Pleroma.Factory
import ExUnit.CaptureLog import ExUnit.CaptureLog
@moduletag stubbed_pipeline: true
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)
:ok :ok

View File

@ -16,6 +16,8 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
require Pleroma.Constants require Pleroma.Constants
@moduletag stubbed_pipeline: true
describe "fetch the latest Follow" do describe "fetch the latest Follow" do
test "fetches the latest Follow activity" do test "fetches the latest Follow activity" do
%Activity{data: %{"type" => "Follow"}} = activity = insert(:follow_activity) %Activity{data: %{"type" => "Follow"}} = activity = insert(:follow_activity)

View File

@ -10,6 +10,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
alias Pleroma.Web.ActivityPub.ObjectView alias Pleroma.Web.ActivityPub.ObjectView
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
@moduletag stubbed_pipeline: true
test "renders a note object" do test "renders a note object" do
note = insert(:note) note = insert(:note)

View File

@ -10,6 +10,8 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do
alias Pleroma.Web.ActivityPub.UserView alias Pleroma.Web.ActivityPub.UserView
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
@moduletag stubbed_pipeline: true
test "Renders a user, including the public key" do test "Renders a user, including the public key" do
user = insert(:user) user = insert(:user)
{:ok, user} = User.ensure_keys_present(user) {:ok, user} = User.ensure_keys_present(user)

View File

@ -18,6 +18,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
alias Pleroma.User alias Pleroma.User
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
@moduletag stubbed_pipeline: true
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)

View File

@ -14,6 +14,8 @@ defmodule Pleroma.Web.AdminAPI.ChatControllerTest do
alias Pleroma.Repo alias Pleroma.Repo
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
@moduletag stubbed_pipeline: true
defp admin_setup do defp admin_setup do
admin = insert(:user, is_admin: true) admin = insert(:user, is_admin: true)
token = insert(:oauth_admin_token, user: admin) token = insert(:oauth_admin_token, user: admin)

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Web.AdminAPI.RelayControllerTest do
alias Pleroma.Repo alias Pleroma.Repo
alias Pleroma.User alias Pleroma.User
@moduletag stubbed_pipeline: true
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)

View File

@ -13,6 +13,8 @@ defmodule Pleroma.Web.AdminAPI.StatusControllerTest do
alias Pleroma.User alias Pleroma.User
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
@moduletag stubbed_pipeline: true
setup do setup do
admin = insert(:user, is_admin: true) admin = insert(:user, is_admin: true)
token = insert(:oauth_admin_token, user: admin) token = insert(:oauth_admin_token, user: admin)

View File

@ -19,6 +19,8 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
alias Pleroma.Web.MediaProxy alias Pleroma.Web.MediaProxy
@moduletag stubbed_pipeline: true
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)

View File

@ -25,6 +25,8 @@ defmodule Pleroma.Web.CommonAPITest do
require Pleroma.Constants require Pleroma.Constants
@moduletag stubbed_pipeline: true
setup do: clear_config([:instance, :safe_dm_mentions]) setup do: clear_config([:instance, :safe_dm_mentions])
setup do: clear_config([:instance, :limit]) setup do: clear_config([:instance, :limit])
setup do: clear_config([:instance, :max_pinned_statuses]) setup do: clear_config([:instance, :max_pinned_statuses])

View File

@ -15,6 +15,8 @@ defmodule Pleroma.Web.FederatorTest do
import Pleroma.Factory import Pleroma.Factory
import Mock import Mock
@moduletag stubbed_pipeline: true
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)

View File

@ -14,6 +14,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
describe "account fetching" do describe "account fetching" do
test "works by id" do test "works by id" do
%User{id: user_id} = insert(:user) %User{id: user_id} = insert(:user)

View File

@ -10,6 +10,8 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
describe "locked accounts" do describe "locked accounts" do
setup do setup do
user = insert(:user, is_locked: true) user = insert(:user, is_locked: true)

View File

@ -12,6 +12,8 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
test "does NOT render account/pleroma/relationship by default" do test "does NOT render account/pleroma/relationship by default" do
%{user: user, conn: conn} = oauth_access(["read:notifications"]) %{user: user, conn: conn} = oauth_access(["read:notifications"])
other_user = insert(:user) other_user = insert(:user)

View File

@ -9,6 +9,11 @@ defmodule Pleroma.Web.MastodonAPI.PollControllerTest do
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
import Pleroma.Factory import Pleroma.Factory
import Mox
setup :set_mox_from_context
@moduletag stubbed_pipeline: true
describe "GET /api/v1/polls/:id" do describe "GET /api/v1/polls/:id" do
setup do: oauth_access(["read:statuses"]) setup do: oauth_access(["read:statuses"])
@ -65,6 +70,8 @@ test "votes are added to the poll", %{conn: conn} do
object = Object.normalize(activity) object = Object.normalize(activity)
# Calling this will run a vote in Cachex.fetch, which doesn't have access
# to our mocks unless we run in global mode.
conn = conn =
conn conn
|> put_req_header("content-type", "application/json") |> put_req_header("content-type", "application/json")

View File

@ -19,6 +19,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
setup do: clear_config([:instance, :federating]) setup do: clear_config([:instance, :federating])
setup do: clear_config([:instance, :allow_relay]) setup do: clear_config([:instance, :allow_relay])
setup do: clear_config([:rich_media, :enabled]) setup do: clear_config([:rich_media, :enabled])

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
alias Pleroma.User alias Pleroma.User
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
@moduletag stubbed_pipeline: true
setup do setup do
mock(fn env -> apply(HttpRequestMock, :request, [env]) end) mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok :ok

View File

@ -13,6 +13,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPITest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
describe "follow/3" do describe "follow/3" do
test "returns error when followed user is deactivated" do test "returns error when followed user is deactivated" do
follower = insert(:user) follower = insert(:user)

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
import Mock import Mock
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
setup do: clear_config([:instance, :max_account_fields]) setup do: clear_config([:instance, :max_account_fields])
describe "updating credentials" do describe "updating credentials" do

View File

@ -14,6 +14,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
import Pleroma.Factory import Pleroma.Factory
import Tesla.Mock import Tesla.Mock
@moduletag stubbed_pipeline: true
setup do setup do
mock(fn env -> apply(HttpRequestMock, :request, [env]) end) mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok :ok

View File

@ -22,6 +22,8 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
alias Pleroma.Web.PleromaAPI.Chat.MessageReferenceView alias Pleroma.Web.PleromaAPI.Chat.MessageReferenceView
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
defp test_notifications_rendering(notifications, user, expected_result) do defp test_notifications_rendering(notifications, user, expected_result) do
result = NotificationView.render("index.json", %{notifications: notifications, for: user}) result = NotificationView.render("index.json", %{notifications: notifications, for: user})

View File

@ -12,6 +12,8 @@ defmodule Pleroma.Web.MastodonAPI.PollViewTest do
import Pleroma.Factory import Pleroma.Factory
import Tesla.Mock import Tesla.Mock
@moduletag stubbed_pipeline: true
setup do setup do
mock(fn env -> apply(HttpRequestMock, :request, [env]) end) mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok :ok

View File

@ -22,6 +22,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
import Tesla.Mock import Tesla.Mock
import OpenApiSpex.TestAssertions import OpenApiSpex.TestAssertions
@moduletag stubbed_pipeline: true
setup do setup do
mock(fn env -> apply(HttpRequestMock, :request, [env]) end) mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok :ok

View File

@ -15,6 +15,8 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
require Pleroma.Constants require Pleroma.Constants
@moduletag stubbed_pipeline: true
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)
:ok :ok

View File

@ -13,6 +13,8 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
import Pleroma.Factory import Pleroma.Factory
import Swoosh.TestAssertions import Swoosh.TestAssertions
@moduletag stubbed_pipeline: true
describe "POST /api/v1/pleroma/accounts/confirmation_resend" do describe "POST /api/v1/pleroma/accounts/confirmation_resend" do
setup do setup do
{:ok, user} = {:ok, user} =

View File

@ -13,6 +13,8 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
describe "POST /api/v1/pleroma/chats/:id/messages/:message_id/read" do describe "POST /api/v1/pleroma/chats/:id/messages/:message_id/read" do
setup do: oauth_access(["write:chats"]) setup do: oauth_access(["write:chats"])

View File

@ -3,12 +3,14 @@
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.EmojiPackControllerTest do defmodule Pleroma.Web.PleromaAPI.EmojiPackControllerTest do
use Pleroma.Web.ConnCase, async: false use Pleroma.Web.ConnCase
import Mock import Mock
import Tesla.Mock import Tesla.Mock
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
@emoji_path Path.join( @emoji_path Path.join(
Pleroma.Config.get!([:instance, :static_dir]), Pleroma.Config.get!([:instance, :static_dir]),
"emoji" "emoji"

View File

@ -13,6 +13,8 @@ defmodule Pleroma.Web.PleromaAPI.EmojiReactionControllerTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
test "PUT /api/v1/pleroma/statuses/:id/reactions/:emoji", %{conn: conn} do test "PUT /api/v1/pleroma/statuses/:id/reactions/:emoji", %{conn: conn} do
user = insert(:user) user = insert(:user)
other_user = insert(:user) other_user = insert(:user)

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Web.PleromaAPI.NotificationControllerTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
describe "POST /api/v1/pleroma/notifications/read" do describe "POST /api/v1/pleroma/notifications/read" do
setup do: oauth_access(["write:notifications"]) setup do: oauth_access(["write:notifications"])

View File

@ -11,6 +11,8 @@ defmodule Pleroma.Web.PleromaAPI.UserImportControllerTest do
import Pleroma.Factory import Pleroma.Factory
import Mock import Mock
@moduletag stubbed_pipeline: true
setup do setup do
Tesla.Mock.mock(fn env -> apply(HttpRequestMock, :request, [env]) end) Tesla.Mock.mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok :ok

View File

@ -14,6 +14,8 @@ defmodule Pleroma.Web.PleromaAPI.ChatMessageReferenceViewTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
test "it displays a chat message" do test "it displays a chat message" do
user = insert(:user) user = insert(:user)
recipient = insert(:user) recipient = insert(:user)

View File

@ -16,6 +16,8 @@ defmodule Pleroma.Web.PleromaAPI.ChatViewTest do
import Pleroma.Factory import Pleroma.Factory
@moduletag stubbed_pipeline: true
test "it represents a chat" do test "it represents a chat" do
user = insert(:user) user = insert(:user)
recipient = insert(:user) recipient = insert(:user)

View File

@ -15,6 +15,8 @@ defmodule Pleroma.Web.Push.ImplTest do
alias Pleroma.Web.Push.Impl alias Pleroma.Web.Push.Impl
alias Pleroma.Web.Push.Subscription alias Pleroma.Web.Push.Subscription
@moduletag stubbed_pipeline: true
setup do setup do
Tesla.Mock.mock(fn Tesla.Mock.mock(fn
%{method: :post, url: "https://example.com/example/1234"} -> %{method: :post, url: "https://example.com/example/1234"} ->

View File

@ -17,7 +17,7 @@ defmodule Pleroma.Web.StreamerTest do
alias Pleroma.Web.Streamer alias Pleroma.Web.Streamer
alias Pleroma.Web.StreamerView alias Pleroma.Web.StreamerView
@moduletag needs_streamer: true, capture_log: true @moduletag needs_streamer: true, capture_log: true, stubbed_pipeline: true
setup do: clear_config([:instance, :skip_thread_containment]) setup do: clear_config([:instance, :skip_thread_containment])

View File

@ -14,6 +14,8 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
import Pleroma.Factory import Pleroma.Factory
import Ecto.Query import Ecto.Query
@moduletag stubbed_pipeline: true
setup do setup do
Tesla.Mock.mock(fn env -> apply(HttpRequestMock, :request, [env]) end) Tesla.Mock.mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok :ok

View File

@ -10,6 +10,8 @@ defmodule Pleroma.Workers.PurgeExpiredActivityTest do
alias Pleroma.Workers.PurgeExpiredActivity alias Pleroma.Workers.PurgeExpiredActivity
@moduletag stubbed_pipeline: true
test "enqueue job" do test "enqueue job" do
activity = insert(:note_activity) activity = insert(:note_activity)