logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/
commit: 58436392ddedb71debf58ae413ba86e384f4612c
parent 06b321465c6a55acc968557ad2f66d9ec35d5004
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat, 29 Feb 2020 06:14:02 +0100

Add fixtures on honk

Diffstat:

Atest/fixtures/tesla_mock/honk-event.json1+
Atest/fixtures/tesla_mock/honk-user.json1+
Mtest/pleroma/object/fetcher_test.exs7+++++++
Mtest/pleroma/web/mastodon_api/views/status_view_test.exs15+++++++++++++++
Mtest/support/http_request_mock.ex18++++++++++++++++++
5 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/test/fixtures/tesla_mock/honk-event.json b/test/fixtures/tesla_mock/honk-event.json @@ -0,0 +1 @@ +{"@context":"https://www.w3.org/ns/activitystreams","attributedTo":"https://honk.tedunangst.com/u/tedu","content":"EuroBSDCon 2020.<br><br>Ich liebe Wien.<br><br><a class=\"mention u-url\" href=\"https://2020.eurobsdcon.org/\" rel=noreferrer>https://2020.eurobsdcon.org/</a>","context":"data:,electrichonkytonk-l6H6FZm3jyV8QS3sKr","conversation":"data:,electrichonkytonk-l6H6FZm3jyV8QS3sKr","id":"https://honk.tedunangst.com/u/tedu/h/8dkPX284T8286Mm9HD","published":"2020-02-17T06:05:45Z","startTime":"2020-09-17T09:00:00-04:00","summary":"","to":"https://www.w3.org/ns/activitystreams#Public","type":"Event","url":"https://honk.tedunangst.com/u/tedu/h/8dkPX284T8286Mm9HD"} diff --git a/test/fixtures/tesla_mock/honk-user.json b/test/fixtures/tesla_mock/honk-user.json @@ -0,0 +1 @@ +{"@context":"https://www.w3.org/ns/activitystreams","followers":"https://honk.tedunangst.com/u/tedu/followers","following":"https://honk.tedunangst.com/u/tedu/following","icon":{"mediaType":"image/png","type":"Image","url":"https://honk.tedunangst.com/a?a=https%3A%2F%2Fhonk.tedunangst.com%2Fu%2Ftedu"},"id":"https://honk.tedunangst.com/u/tedu","inbox":"https://honk.tedunangst.com/u/tedu/inbox","name":"tedu","outbox":"https://honk.tedunangst.com/u/tedu/outbox","preferredUsername":"tedu","publicKey":{"id":"https://honk.tedunangst.com/u/tedu#key","owner":"https://honk.tedunangst.com/u/tedu","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA593GZ9TYrvWgMaMKQ6k6\ngkItUapUgNnNXzU9J63GRtYZ7CE/Zi39Kgpsxu77hHBj34vwjr1Oc9AMrVDIMfu9\nEirW1RWxPvrjThBU56VgkpkAXVsieaffJo80BA00QzV4x69Jgat6OT7ox/HMvMxR\nyZ6CXNCPKQALYqQF6v1fX1kO9lhIA+mPd0JN/qMKvZfd1NXABEk9nORUneH7Audt\nIHNdJzKMHC6wPSQWC7SmXT0/nq6o5mR2SgvwTI/JUx6T5r8NDrwSaqB69e+EMJqR\nxKOh9N4A1ba/AQOQZbO/YkFyYY2VE4HWbvS9XpYL74yT9D6Fp4cUovJiXC+ziam0\nNwIDAQAB\n-----END PUBLIC KEY-----\n"},"summary":"Honker in chief.","type":"Person","url":"https://honk.tedunangst.com/u/tedu"} diff --git a/test/pleroma/object/fetcher_test.exs b/test/pleroma/object/fetcher_test.exs @@ -206,6 +206,13 @@ defmodule Pleroma.Object.FetcherTest do assert object end + test "it can fetch Honk events" do + {:ok, object} = + Fetcher.fetch_object_from_id("https://honk.tedunangst.com/u/tedu/h/8dkPX284T8286Mm9HD") + + assert object + end + test "it can fetch wedistribute articles" do {:ok, object} = Fetcher.fetch_object_from_id("https://wedistribute.org/wp-json/pterotype/v1/object/85810") diff --git a/test/pleroma/web/mastodon_api/views/status_view_test.exs b/test/pleroma/web/mastodon_api/views/status_view_test.exs @@ -745,6 +745,21 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do "<p><a href=\"https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39\">Mobilizon Launching Party</a></p><p>Mobilizon is now federated! 🎉</p><p></p><p>You can view this event from other instances if they are subscribed to mobilizon.org, and soon directly from Mastodon and Pleroma. It is possible that you may see some comments from other instances, including Mastodon ones, just below.</p><p></p><p>With a Mobilizon account on an instance, you may <strong>participate</strong> at events from other instances and <strong>add comments</strong> on events.</p><p></p><p>Of course, it&#39;s still <u>a work in progress</u>: if reports made from an instance on events and comments can be federated, you can&#39;t block people right now, and moderators actions are rather limited, but this <strong>will definitely get fixed over time</strong> until first stable version next year.</p><p></p><p>Anyway, if you want to come up with some feedback, head over to our forum or - if you feel you have technical skills and are familiar with it - on our Gitlab repository.</p><p></p><p>Also, to people that want to set Mobilizon themselves even though we really don&#39;t advise to do that for now, we have a little documentation but it&#39;s quite the early days and you&#39;ll probably need some help. No worries, you can chat with us on our Forum or though our Matrix channel.</p><p></p><p>Check our website for more informations and follow us on Twitter or Mastodon.</p>" end + test "a Honk event" do + user = insert(:user) + + {:ok, object} = + Pleroma.Object.Fetcher.fetch_object_from_id( + "https://honk.tedunangst.com/u/tedu/h/8dkPX284T8286Mm9HD" + ) + + %Activity{} = activity = Activity.get_create_by_object_ap_id(object.data["id"]) + + represented = StatusView.render("show.json", %{for: user, activity: activity}) + + assert represented[:id] == to_string(activity.id) + end + describe "build_tags/1" do test "it returns a a dictionary tags" do object_tags = [ diff --git a/test/support/http_request_mock.ex b/test/support/http_request_mock.ex @@ -362,6 +362,24 @@ defmodule HttpRequestMock do }} end + def get("https://honk.tedunangst.com/u/tedu/h/8dkPX284T8286Mm9HD", _, _, + Accept: "application/activity+json" + ) do + {:ok, + %Tesla.Env{ + status: 200, + body: File.read!("test/fixtures/tesla_mock/honk-event.json") + }} + end + + def get("https://honk.tedunangst.com/u/tedu", _, _, Accept: "application/activity+json") do + {:ok, + %Tesla.Env{ + status: 200, + body: File.read!("test/fixtures/tesla_mock/honk-user.json") + }} + end + def get("https://baptiste.gelez.xyz/@/BaptisteGelez", _, _, _) do {:ok, %Tesla.Env{