]> Untitled Git - lemmy.git/commitdiff
Test pleroma follow (#1988)
authorNutomic <me@nutomic.com>
Sun, 12 Dec 2021 02:39:18 +0000 (02:39 +0000)
committerGitHub <noreply@github.com>
Sun, 12 Dec 2021 02:39:18 +0000 (21:39 -0500)
* Add test case for Pleroma follow activity (ref #1984)

* Use WithContext in apub tests where possible

crates/apub/assets/pleroma/activities/follow.json [new file with mode: 0644]
crates/apub/src/protocol/activities/create_or_update/mod.rs
crates/apub/src/protocol/activities/following/mod.rs
crates/apub/src/protocol/objects/mod.rs

diff --git a/crates/apub/assets/pleroma/activities/follow.json b/crates/apub/assets/pleroma/activities/follow.json
new file mode 100644 (file)
index 0000000..8d0f008
--- /dev/null
@@ -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"
+}
index 63ddcf96703301611a7d43a988d218f294743cde..8693647f644200711f33a65c63c92c393edee0b1 100644 (file)
@@ -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},
@@ -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");
index 3258dbb7e0b3fe964af58724c900f246b6fdb72e..693725a9454c366ce79bcf1f046cc05f3ba7f445 100644 (file)
@@ -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]
@@ -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");
   }
 }
index bd590d493e78fe8d8d29c0133717b7b5bd37d2b4..4ee13b775a21273bfec540f22ee4ec97f4d6756f 100644 (file)
@@ -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},
@@ -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");