Skip to content

Commit

Permalink
Test pleroma follow (#1988)
Browse files Browse the repository at this point in the history
* Add test case for Pleroma follow activity (ref #1984)

* Use WithContext in apub tests where possible
  • Loading branch information
Nutomic authored Dec 12, 2021
1 parent 0ed3856 commit c6ac606
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
18 changes: 18 additions & 0 deletions crates/apub/assets/pleroma/activities/follow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://mycrowd.ca/schemas/litepub-0.1.jsonld",
{
"@language": "und"
}
],
"actor": "https://mycrowd.ca/users/kinetix",
"cc": [],
"id": "https://mycrowd.ca/activities/dab6a4d3-0db0-41ee-8aab-7bfa4929b4fd",
"object": "https://lemmy.ca/u/kinetix",
"state": "pending",
"to": [
"https://lemmy.ca/u/kinetix"
],
"type": "Follow"
}
9 changes: 7 additions & 2 deletions crates/apub/src/protocol/activities/create_or_update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod post;
#[cfg(test)]
mod tests {
use crate::{
context::WithContext,
objects::tests::file_to_json_object,
protocol::{
activities::create_or_update::{comment::CreateOrUpdateComment, post::CreateOrUpdatePost},
Expand All @@ -23,8 +24,12 @@ mod tests {
"assets/lemmy/activities/create_or_update/create_note.json",
);

file_to_json_object::<CreateOrUpdateComment>("assets/pleroma/activities/create_note.json");
file_to_json_object::<CreateOrUpdateComment>("assets/smithereen/activities/create_note.json");
file_to_json_object::<WithContext<CreateOrUpdateComment>>(
"assets/pleroma/activities/create_note.json",
);
file_to_json_object::<WithContext<CreateOrUpdateComment>>(
"assets/smithereen/activities/create_note.json",
);
file_to_json_object::<CreateOrUpdateComment>("assets/mastodon/activities/create_note.json");

file_to_json_object::<CreateOrUpdatePost>("assets/lotide/activities/create_page.json");
Expand Down
18 changes: 12 additions & 6 deletions crates/apub/src/protocol/activities/following/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ pub mod undo_follow;

#[cfg(test)]
mod tests {
use crate::protocol::{
activities::following::{
accept::AcceptFollowCommunity,
follow::FollowCommunity,
undo_follow::UndoFollowCommunity,
use crate::{
context::WithContext,
objects::tests::file_to_json_object,
protocol::{
activities::following::{
accept::AcceptFollowCommunity,
follow::FollowCommunity,
undo_follow::UndoFollowCommunity,
},
tests::test_parse_lemmy_item,
},
tests::test_parse_lemmy_item,
};

#[actix_rt::test]
Expand All @@ -20,5 +24,7 @@ mod tests {
test_parse_lemmy_item::<UndoFollowCommunity>(
"assets/lemmy/activities/following/undo_follow.json",
);

file_to_json_object::<WithContext<FollowCommunity>>("assets/pleroma/activities/follow.json");
}
}
9 changes: 5 additions & 4 deletions crates/apub/src/protocol/objects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct Endpoints {
#[cfg(test)]
mod tests {
use crate::{
context::WithContext,
objects::tests::file_to_json_object,
protocol::{
objects::{chat_message::ChatMessage, group::Group, note::Note, page::Page, person::Person},
Expand All @@ -33,11 +34,11 @@ mod tests {
test_parse_lemmy_item::<Note>("assets/lemmy/objects/note.json");
test_parse_lemmy_item::<ChatMessage>("assets/lemmy/objects/chat_message.json");

file_to_json_object::<Person>("assets/pleroma/objects/person.json");
file_to_json_object::<Note>("assets/pleroma/objects/note.json");
file_to_json_object::<ChatMessage>("assets/pleroma/objects/chat_message.json");
file_to_json_object::<WithContext<Person>>("assets/pleroma/objects/person.json");
file_to_json_object::<WithContext<Note>>("assets/pleroma/objects/note.json");
file_to_json_object::<WithContext<ChatMessage>>("assets/pleroma/objects/chat_message.json");

file_to_json_object::<Person>("assets/smithereen/objects/person.json");
file_to_json_object::<WithContext<Person>>("assets/smithereen/objects/person.json");
file_to_json_object::<Note>("assets/smithereen/objects/note.json");

file_to_json_object::<Person>("assets/mastodon/objects/person.json");
Expand Down

0 comments on commit c6ac606

Please sign in to comment.