logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

image_handling_test.exs (1628B)


  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. defmodule Pleroma.Web.ActivityPub.Transmogrifier.ImageHandlingTest do
  5. use Oban.Testing, repo: Pleroma.Repo
  6. use Pleroma.DataCase
  7. alias Pleroma.Activity
  8. alias Pleroma.Object
  9. alias Pleroma.Web.ActivityPub.Transmogrifier
  10. test "Hubzilla Image object" do
  11. Tesla.Mock.mock(fn
  12. %{url: "https://hub.somaton.com/channel/testc6"} ->
  13. %Tesla.Env{
  14. status: 200,
  15. body: File.read!("test/fixtures/hubzilla-actor.json"),
  16. headers: HttpRequestMock.activitypub_object_headers()
  17. }
  18. end)
  19. data = File.read!("test/fixtures/hubzilla-create-image.json") |> Poison.decode!()
  20. {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
  21. assert object = Object.normalize(activity, fetch: false)
  22. assert object.data["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
  23. assert object.data["cc"] == ["https://hub.somaton.com/followers/testc6"]
  24. assert object.data["attachment"] == [
  25. %{
  26. "mediaType" => "image/jpeg",
  27. "type" => "Link",
  28. "url" => [
  29. %{
  30. "height" => 2200,
  31. "href" =>
  32. "https://hub.somaton.com/photo/452583b2-7e1f-4ac3-8334-ff666f134afe-0.jpg",
  33. "mediaType" => "image/jpeg",
  34. "type" => "Link",
  35. "width" => 2200
  36. }
  37. ]
  38. }
  39. ]
  40. end
  41. end