0a1a965cac47523b51d5c24c69c903134a526808
[akkoma] / test / pleroma / web / activity_pub / transmogrifier / audio_handling_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ActivityPub.Transmogrifier.AudioHandlingTest do
6 use Oban.Testing, repo: Pleroma.Repo
7 use Pleroma.DataCase
8
9 alias Pleroma.Activity
10 alias Pleroma.Object
11 alias Pleroma.Web.ActivityPub.Transmogrifier
12
13 import Pleroma.Factory
14
15 test "Funkwhale Audio object" do
16 Tesla.Mock.mock(fn
17 %{url: "https://channels.tests.funkwhale.audio/federation/actors/compositions"} ->
18 %Tesla.Env{
19 status: 200,
20 body: File.read!("test/fixtures/tesla_mock/funkwhale_channel.json"),
21 headers: HttpRequestMock.activitypub_object_headers()
22 }
23 end)
24
25 data = File.read!("test/fixtures/tesla_mock/funkwhale_create_audio.json") |> Jason.decode!()
26
27 {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
28
29 assert object = Object.normalize(activity, fetch: false)
30
31 assert object.data["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
32
33 assert object.data["cc"] == [
34 "https://channels.tests.funkwhale.audio/federation/actors/compositions/followers"
35 ]
36
37 assert object.data["url"] == "https://channels.tests.funkwhale.audio/library/tracks/74"
38
39 assert object.data["attachment"] == [
40 %{
41 "mediaType" => "audio/ogg",
42 "type" => "Link",
43 "url" => [
44 %{
45 "href" =>
46 "https://channels.tests.funkwhale.audio/api/v1/listen/3901e5d8-0445-49d5-9711-e096cf32e515/?upload=42342395-0208-4fee-a38d-259a6dae0871&download=false",
47 "mediaType" => "audio/ogg",
48 "type" => "Link"
49 }
50 ]
51 }
52 ]
53 end
54 end