diff options
author | kaniini <ariadne@dereferenced.org> | 2019-09-30 10:45:00 +0000 |
---|---|---|
committer | kaniini <ariadne@dereferenced.org> | 2019-09-30 10:45:00 +0000 |
commit | ed176e74027d5a48247bafebc916932b931f56ab (patch) | |
tree | ea90c3aa50c91d3c92715a278f4aa938466e1317 /test/support | |
parent | 90537f398160eddfb8033c1cdfe1acc21ee63c4a (diff) | |
parent | 1d7cbdaf7b2f3ff6576959ed26885d7545f31a14 (diff) | |
download | pleroma-ed176e74027d5a48247bafebc916932b931f56ab.tar.gz |
Merge branch 'feature/scrobbling' into 'develop'
media scrobbling ("now playing" API)
See merge request pleroma/pleroma!1732
Diffstat (limited to 'test/support')
-rw-r--r-- | test/support/factory.ex | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex index 719115003..4f3244025 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -71,6 +71,47 @@ defmodule Pleroma.Factory do } 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 user2 = insert(:user) |