ChatValidationTest: Fix tests.

This commit is contained in:
Lain Soykaf 2023-12-11 09:43:49 +04:00
parent 90a47ca050
commit 3cce929eec
2 changed files with 20 additions and 0 deletions

View File

@ -5,11 +5,13 @@
defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatValidationTest do defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatValidationTest do
use Pleroma.DataCase use Pleroma.DataCase
alias Pleroma.Object alias Pleroma.Object
alias Pleroma.UnstubbedConfigMock, as: ConfigMock
alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.ActivityPub.Builder alias Pleroma.Web.ActivityPub.Builder
alias Pleroma.Web.ActivityPub.ObjectValidator alias Pleroma.Web.ActivityPub.ObjectValidator
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
import Mox
import Pleroma.Factory import Pleroma.Factory
describe "chat message create activities" do describe "chat message create activities" do
@ -82,6 +84,9 @@ test "validates for a basic object with an attachment", %{
filename: "an_image.jpg" filename: "an_image.jpg"
} }
ConfigMock
|> stub_with(Pleroma.Test.StaticConfig)
{:ok, attachment} = ActivityPub.upload(file, actor: user.ap_id) {:ok, attachment} = ActivityPub.upload(file, actor: user.ap_id)
valid_chat_message = valid_chat_message =
@ -103,6 +108,9 @@ test "validates for a basic object with an attachment in an array", %{
filename: "an_image.jpg" filename: "an_image.jpg"
} }
ConfigMock
|> stub_with(Pleroma.Test.StaticConfig)
{:ok, attachment} = ActivityPub.upload(file, actor: user.ap_id) {:ok, attachment} = ActivityPub.upload(file, actor: user.ap_id)
valid_chat_message = valid_chat_message =
@ -124,6 +132,9 @@ test "validates for a basic object with an attachment but without content", %{
filename: "an_image.jpg" filename: "an_image.jpg"
} }
ConfigMock
|> stub_with(Pleroma.Test.StaticConfig)
{:ok, attachment} = ActivityPub.upload(file, actor: user.ap_id) {:ok, attachment} = ActivityPub.upload(file, actor: user.ap_id)
valid_chat_message = valid_chat_message =

View File

@ -18,3 +18,12 @@
uploads = Pleroma.Config.get([Pleroma.Uploaders.Local, :uploads], "test/uploads") uploads = Pleroma.Config.get([Pleroma.Uploaders.Local, :uploads], "test/uploads")
File.rm_rf!(uploads) File.rm_rf!(uploads)
end) end)
defmodule Pleroma.Test.StaticConfig do
@behaviour Pleroma.Config.Getting
@config Application.get_all_env(:pleroma)
def get(path, default \\ nil) do
get_in(@config, path) || default
end
end