Add tests for Gancio compatibility

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-11-10 16:41:01 +01:00
parent afff01d6d2
commit c15123e5ea
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
2 changed files with 79 additions and 0 deletions

View File

@ -79,6 +79,43 @@ defmodule Mobilizon.Federation.ActivityPub.TransmogrifierTest do
end end
end end
test "it works for incoming events from Gancio" do
data = File.read!("test/fixtures/gancio-event-activity.json") |> Jason.decode!()
{:ok, %Activity{data: data, local: false}, %Event{} = event} =
Transmogrifier.handle_incoming(data)
assert data["id"] == "https://demo.gancio.org/federation/m/1/activity"
assert data["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
# assert data["cc"] == [nil]
assert data["actor"] == "https://demo.gancio.org/federation/u/gancio"
object = data["object"]
assert object["id"] ==
"https://demo.gancio.org/federation/m/1"
assert object["to"] == ["https://www.w3.org/ns/activitystreams#Public"]
assert object["cc"] == []
assert object["actor"] == "https://demo.gancio.org/federation/u/gancio"
assert object["location"]["name"] == "Colosseo"
assert object["attributedTo"] == "https://demo.gancio.org/federation/u/gancio"
assert event.title == "Demo event"
assert event.begins_on == ~U[2021-07-14 15:30:57Z]
assert event.ends_on == ~U[2021-07-14 16:30:57Z]
assert event.picture.file.content_type == "image/jpeg"
assert event.picture.file.name == "unknown.jpg"
assert length(event.tags) == 1
assert hd(event.tags).title == "test"
assert event.physical_address.description == "Colosseo"
end
test "it works for incoming events for local groups" do test "it works for incoming events for local groups" do
%Actor{url: group_url, id: group_id} = group = insert(:group) %Actor{url: group_url, id: group_id} = group = insert(:group)

View File

@ -0,0 +1,42 @@
{
"id": "https://demo.gancio.org/federation/m/1#create",
"type": "Create",
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"cc": ["https://demo.gancio.org/federation/u/gancio/followers"],
"published": "2021-07-01T22:33:36Z",
"actor": "https://demo.gancio.org/federation/u/gancio",
"object": {
"id": "https://demo.gancio.org/federation/m/1",
"name": "Demo event",
"url": "https://demo.gancio.org/event/demo-event",
"type": "Event",
"startTime": "2021-07-14T17:30:57+02:00",
"endTime": "2021-07-14T18:30:57+02:00",
"location": {
"name": "Colosseo"
},
"attachment": [
{
"type": "Document",
"mediaType": "image/jpeg",
"url": "https://demo.gancio.org/media/7215892e7326a9b326b6bcad5b57642e.jpg",
"name": "",
"blurHash": null,
"focalPoint": [0, 0]
}
],
"tag": [
{
"type": "Hashtag",
"name": "#test",
"href": "/tags/test"
}
],
"published": "2021-07-01T22:33:36Z",
"attributedTo": "https://demo.gancio.org/federation/u/gancio",
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"cc": ["https://demo.gancio.org/federation/u/gancio/followers"],
"content": "\n 📍 Colosseo\n 📅 Wednesday, 14 July (17:30)\n\n \n ",
"summary": "\n 📍 Colosseo\n 📅 Wednesday, 14 July (17:30)\n\n \n "
}
}