ObjectValidator.stringify_keys: filter out nil values
[akkoma] / test / pleroma / web / activity_pub / transmogrifier / audio_handling_test.exs
index 0636d00c5bd5b9cf646dee332df67388459cc286..a0942ce8b8c6a7f49fd1385cd80448ebe803a122 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.ActivityPub.Transmogrifier.AudioHandlingTest do
@@ -24,6 +24,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AudioHandlingTest do
       "actor" => "http://mastodon.example.org/users/admin",
       "object" => %{
         "type" => "Audio",
+        "to" => ["https://www.w3.org/ns/activitystreams#Public"],
+        "cc" => [],
         "id" => "http://mastodon.example.org/users/admin/listens/1234",
         "attributedTo" => "http://mastodon.example.org/users/admin",
         "title" => "lain radio episode 1",
@@ -35,7 +37,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AudioHandlingTest do
 
     {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
 
-    object = Object.normalize(activity)
+    object = Object.normalize(activity, fetch: false)
 
     assert object.data["title"] == "lain radio episode 1"
     assert object.data["artist"] == "lain"
@@ -48,19 +50,22 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AudioHandlingTest do
       %{url: "https://channels.tests.funkwhale.audio/federation/actors/compositions"} ->
         %Tesla.Env{
           status: 200,
-          body: File.read!("test/fixtures/tesla_mock/funkwhale_channel.json")
+          body: File.read!("test/fixtures/tesla_mock/funkwhale_channel.json"),
+          headers: HttpRequestMock.activitypub_object_headers()
         }
     end)
 
-    data = File.read!("test/fixtures/tesla_mock/funkwhale_create_audio.json") |> Poison.decode!()
+    data = File.read!("test/fixtures/tesla_mock/funkwhale_create_audio.json") |> Jason.decode!()
 
     {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
 
-    assert object = Object.normalize(activity, false)
+    assert object = Object.normalize(activity, fetch: false)
 
     assert object.data["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
 
-    assert object.data["cc"] == []
+    assert object.data["cc"] == [
+             "https://channels.tests.funkwhale.audio/federation/actors/compositions/followers"
+           ]
 
     assert object.data["url"] == "https://channels.tests.funkwhale.audio/library/tracks/74"
 
@@ -68,7 +73,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AudioHandlingTest do
              %{
                "mediaType" => "audio/ogg",
                "type" => "Link",
-               "name" => nil,
                "url" => [
                  %{
                    "href" =>