diff options
author | feld <feld@feld.me> | 2021-02-02 17:18:07 +0000 |
---|---|---|
committer | feld <feld@feld.me> | 2021-02-02 17:18:07 +0000 |
commit | b36891d1e6f5d4b0874ef19c4418a46d580c4701 (patch) | |
tree | 726875098c3908b5ebf455c6ea00e9a38e405733 /test/support | |
parent | 2012800ed1618eeafddaaaaa05df4d3e10a2afff (diff) | |
parent | cd5ff7a9430a8e5886983610f1e16f966392a7ee (diff) | |
download | pleroma-b36891d1e6f5d4b0874ef19c4418a46d580c4701.tar.gz pleroma-b36891d1e6f5d4b0874ef19c4418a46d580c4701.zip |
Merge branch 'feature/2164-unify-api-arguments' into 'develop'
Unifying timelines api arguments
Closes #2164
See merge request pleroma/pleroma!3281
Diffstat (limited to 'test/support')
-rw-r--r-- | test/support/factory.ex | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex index bf9592064..436e19409 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -104,6 +104,37 @@ defmodule Pleroma.Factory do } end + def attachment_note_factory(attrs \\ %{}) do + user = attrs[:user] || insert(:user) + {length, attrs} = Map.pop(attrs, :length, 1) + + data = %{ + "attachment" => + Stream.repeatedly(fn -> attachment_data(user.ap_id, attrs[:href]) end) + |> Enum.take(length) + } + + build(:note, Map.put(attrs, :data, data)) + end + + defp attachment_data(ap_id, href) do + href = href || sequence(:href, &"#{Pleroma.Web.Endpoint.url()}/media/#{&1}.jpg") + + %{ + "url" => [ + %{ + "href" => href, + "type" => "Link", + "mediaType" => "image/jpeg" + } + ], + "name" => "some name", + "type" => "Document", + "actor" => ap_id, + "mediaType" => "image/jpeg" + } + end + def audio_factory(attrs \\ %{}) do text = sequence(:text, &"lain radio episode #{&1}") |