forked from mirrors/akkoma
test: factory: implement support for generating mock audio and listen objects
This commit is contained in:
parent
5fd29edac4
commit
c3d09921e4
1 changed files with 41 additions and 0 deletions
|
@ -71,6 +71,47 @@ defmodule Pleroma.Factory do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def audio_factory(attrs \\ %{}) do
|
||||||
|
text = sequence(:text, &"lain radio episode #{&1}")
|
||||||
|
|
||||||
|
user = attrs[:user] || insert(:user)
|
||||||
|
|
||||||
|
data = %{
|
||||||
|
"type" => "Audio",
|
||||||
|
"id" => Pleroma.Web.ActivityPub.Utils.generate_object_id(),
|
||||||
|
"artist" => "lain",
|
||||||
|
"title" => text,
|
||||||
|
"album" => "lain radio",
|
||||||
|
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
||||||
|
"published" => DateTime.utc_now() |> DateTime.to_iso8601(),
|
||||||
|
"actor" => user.ap_id,
|
||||||
|
"length" => 180_000
|
||||||
|
}
|
||||||
|
|
||||||
|
%Pleroma.Object{
|
||||||
|
data: merge_attributes(data, Map.get(attrs, :data, %{}))
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def listen_factory do
|
||||||
|
audio = insert(:audio)
|
||||||
|
|
||||||
|
data = %{
|
||||||
|
"id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(),
|
||||||
|
"type" => "Listen",
|
||||||
|
"actor" => audio.data["actor"],
|
||||||
|
"to" => audio.data["to"],
|
||||||
|
"object" => audio.data,
|
||||||
|
"published" => audio.data["published"]
|
||||||
|
}
|
||||||
|
|
||||||
|
%Pleroma.Activity{
|
||||||
|
data: data,
|
||||||
|
actor: data["actor"],
|
||||||
|
recipients: data["to"]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def direct_note_factory do
|
def direct_note_factory do
|
||||||
user2 = insert(:user)
|
user2 = insert(:user)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue