Add tests for Gancio compatibility
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
afff01d6d2
commit
c15123e5ea
|
@ -79,6 +79,43 @@ defmodule Mobilizon.Federation.ActivityPub.TransmogrifierTest do
|
|||
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
|
||||
%Actor{url: group_url, id: group_id} = group = insert(:group)
|
||||
|
||||
|
|
42
test/fixtures/gancio-event-activity.json
vendored
Normal file
42
test/fixtures/gancio-event-activity.json
vendored
Normal 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 "
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue