Tests AP Factory: fix featured collection factories
Internally it created Objects, tests passed Activities
This commit is contained in:
parent
07849927da
commit
96de44b3d8
2 changed files with 15 additions and 11 deletions
|
|
@ -261,23 +261,27 @@ defmodule Pleroma.ActivityTest do
|
||||||
test "add_by_params_query/3" do
|
test "add_by_params_query/3" do
|
||||||
user = insert(:user)
|
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_activity: note_activity)
|
||||||
insert(:add_activity, user: user, note: note)
|
insert(:add_activity, user: user, note_activity: note_activity)
|
||||||
insert(:add_activity, user: user)
|
insert(:add_activity, user: user)
|
||||||
|
|
||||||
assert Repo.aggregate(Activity, :count, :id) == 4
|
assert Repo.aggregate(Activity, :count, :id) == 5
|
||||||
|
|
||||||
add_query =
|
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
|
assert Repo.aggregate(add_query, :count, :id) == 2
|
||||||
|
|
||||||
Repo.delete_all(add_query)
|
Repo.delete_all(add_query)
|
||||||
assert Repo.aggregate(add_query, :count, :id) == 0
|
assert Repo.aggregate(add_query, :count, :id) == 0
|
||||||
|
|
||||||
assert Repo.aggregate(Activity, :count, :id) == 2
|
assert Repo.aggregate(Activity, :count, :id) == 3
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "associated_object_id() sql function" do
|
describe "associated_object_id() sql function" do
|
||||||
|
|
|
||||||
|
|
@ -305,27 +305,27 @@ defmodule Pleroma.Factory do
|
||||||
featured_collection_activity(attrs, "Add")
|
featured_collection_activity(attrs, "Add")
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_activity_factor(attrs \\ %{}) do
|
def remove_activity_factory(attrs \\ %{}) do
|
||||||
featured_collection_activity(attrs, "Remove")
|
featured_collection_activity(attrs, "Remove")
|
||||||
end
|
end
|
||||||
|
|
||||||
defp featured_collection_activity(attrs, type) do
|
defp featured_collection_activity(attrs, type) do
|
||||||
user = attrs[:user] || insert(:user)
|
user = attrs[:user] || insert(:user)
|
||||||
note = attrs[:note] || insert(:note, user: user)
|
note_activity = attrs[:note_activity] || insert(:note_activity, user: user)
|
||||||
|
|
||||||
data_attrs =
|
data_attrs =
|
||||||
attrs
|
attrs
|
||||||
|> Map.get(:data_attrs, %{})
|
|> Map.get(:data_attrs, %{})
|
||||||
|> Map.put(:type, type)
|
|> Map.put(:type, type)
|
||||||
|
|
||||||
attrs = Map.drop(attrs, [:user, :note, :data_attrs])
|
attrs = Map.drop(attrs, [:user, :note_activity, :data_attrs])
|
||||||
|
|
||||||
data =
|
data =
|
||||||
%{
|
%{
|
||||||
"id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(),
|
"id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(),
|
||||||
"target" => user.featured_address,
|
"target" => user.featured_address,
|
||||||
"object" => note.data["object"],
|
"object" => note_activity.data["object"],
|
||||||
"actor" => note.data["actor"],
|
"actor" => note_activity.data["actor"],
|
||||||
"type" => "Add",
|
"type" => "Add",
|
||||||
"to" => [Pleroma.Constants.as_public()],
|
"to" => [Pleroma.Constants.as_public()],
|
||||||
"cc" => [user.follower_address]
|
"cc" => [user.follower_address]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue