logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/
commit: 96de44b3d8af8acb0c63fc1b405a9d73f3d8a758
parent 07849927dad0572e2f2dda706c164d48ae676d78
Author: Phantasm <phantasm@centrum.cz>
Date:   Thu, 25 Dec 2025 19:16:26 +0100

Tests AP Factory: fix featured collection factories

Internally it created Objects, tests passed Activities

Diffstat:

Mtest/pleroma/activity_test.exs16++++++++++------
Mtest/support/factory.ex10+++++-----
2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/test/pleroma/activity_test.exs b/test/pleroma/activity_test.exs @@ -261,23 +261,27 @@ defmodule Pleroma.ActivityTest do test "add_by_params_query/3" do user = insert(:user) - note = insert(:note_activity, user: user) + note_activity = insert(:note_activity, user: user) - insert(:add_activity, user: user, note: note) - insert(:add_activity, user: user, note: note) + insert(:add_activity, user: user, note_activity: note_activity) + insert(:add_activity, user: user, note_activity: note_activity) insert(:add_activity, user: user) - assert Repo.aggregate(Activity, :count, :id) == 4 + assert Repo.aggregate(Activity, :count, :id) == 5 add_query = - Activity.add_by_params_query(note.data["object"], user.ap_id, user.featured_address) + Activity.add_by_params_query( + note_activity.data["object"], + user.ap_id, + user.featured_address + ) assert Repo.aggregate(add_query, :count, :id) == 2 Repo.delete_all(add_query) assert Repo.aggregate(add_query, :count, :id) == 0 - assert Repo.aggregate(Activity, :count, :id) == 2 + assert Repo.aggregate(Activity, :count, :id) == 3 end describe "associated_object_id() sql function" do diff --git a/test/support/factory.ex b/test/support/factory.ex @@ -305,27 +305,27 @@ defmodule Pleroma.Factory do featured_collection_activity(attrs, "Add") end - def remove_activity_factor(attrs \\ %{}) do + def remove_activity_factory(attrs \\ %{}) do featured_collection_activity(attrs, "Remove") end defp featured_collection_activity(attrs, type) do user = attrs[:user] || insert(:user) - note = attrs[:note] || insert(:note, user: user) + note_activity = attrs[:note_activity] || insert(:note_activity, user: user) data_attrs = attrs |> Map.get(:data_attrs, %{}) |> Map.put(:type, type) - attrs = Map.drop(attrs, [:user, :note, :data_attrs]) + attrs = Map.drop(attrs, [:user, :note_activity, :data_attrs]) data = %{ "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(), "target" => user.featured_address, - "object" => note.data["object"], - "actor" => note.data["actor"], + "object" => note_activity.data["object"], + "actor" => note_activity.data["actor"], "type" => "Add", "to" => [Pleroma.Constants.as_public()], "cc" => [user.follower_address]