diff options
author | feld <feld@feld.me> | 2021-02-02 17:57:58 +0000 |
---|---|---|
committer | feld <feld@feld.me> | 2021-02-02 17:57:58 +0000 |
commit | d289ad8579dacdf1459bbbdaf404bfcd042255ae (patch) | |
tree | da6bfbe54853ad66dd81763e7b8d3be3b121a2a3 /test/support | |
parent | c369d2b93028e4dc11f1f2c4cd7380ee0392ccac (diff) | |
parent | 6a2d3fb9a3775fc0e167c71bb8a8fba3608b2f17 (diff) | |
download | pleroma-d289ad8579dacdf1459bbbdaf404bfcd042255ae.tar.gz pleroma-d289ad8579dacdf1459bbbdaf404bfcd042255ae.zip |
Merge branch 'develop' into 'fix/2411-mutes-api'
# Conflicts:
# CHANGELOG.md
# docs/development/API/differences_in_mastoapi_responses.md
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}") |