total rebase
[anni] / test / pleroma / web / activity_pub / transmogrifier / event_handling_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ActivityPub.Transmogrifier.EventHandlingTest do
6   use Oban.Testing, repo: Pleroma.Repo
7   use Pleroma.DataCase
8
9   alias Pleroma.Object.Fetcher
10
11   test "Mobilizon Event object" do
12     Tesla.Mock.mock(fn
13       %{url: "https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39"} ->
14         %Tesla.Env{
15           status: 200,
16           body: File.read!("test/fixtures/tesla_mock/mobilizon.org-event.json"),
17           headers: HttpRequestMock.activitypub_object_headers()
18         }
19
20       %{url: "https://mobilizon.org/@tcit"} ->
21         %Tesla.Env{
22           status: 200,
23           body: File.read!("test/fixtures/tesla_mock/mobilizon.org-user.json"),
24           headers: HttpRequestMock.activitypub_object_headers()
25         }
26     end)
27
28     assert {:ok, object} =
29              Fetcher.fetch_object_from_id(
30                "https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39"
31              )
32
33     assert object.data["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
34     assert object.data["cc"] == ["https://mobilizon.org/@tcit/followers"]
35
36     assert object.data["url"] ==
37              "https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39"
38
39     assert object.data["published"] == "2019-12-17T11:33:56Z"
40     assert object.data["name"] == "Mobilizon Launching Party"
41   end
42 end