mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 20:31:19 +00:00
Move apub test files into tree structure
This commit is contained in:
parent
03d8ac75ef
commit
aaaf039779
15 changed files with 28 additions and 34 deletions
|
@ -131,15 +131,13 @@ impl GetCommunity for CreateOrUpdateComment {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serial_test::serial;
|
||||
|
||||
use crate::objects::tests::file_to_json_object;
|
||||
|
||||
use super::*;
|
||||
use crate::objects::tests::file_to_json_object;
|
||||
use serial_test::serial;
|
||||
|
||||
#[actix_rt::test]
|
||||
#[serial]
|
||||
async fn test_parse_pleroma_create_comment() {
|
||||
let _: CreateOrUpdateComment = file_to_json_object("assets/pleroma-create-comment.json");
|
||||
file_to_json_object::<CreateOrUpdateComment>("assets/pleroma/activities/create-note.json");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,30 +186,29 @@ impl ApubObject for ApubComment {
|
|||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use assert_json_diff::assert_json_include;
|
||||
use serial_test::serial;
|
||||
|
||||
use super::*;
|
||||
use crate::objects::{
|
||||
community::ApubCommunity,
|
||||
person::ApubPerson,
|
||||
post::ApubPost,
|
||||
tests::{file_to_json_object, init_context},
|
||||
};
|
||||
|
||||
use super::*;
|
||||
use crate::objects::{person::ApubPerson, post::ApubPost};
|
||||
use assert_json_diff::assert_json_include;
|
||||
use serial_test::serial;
|
||||
|
||||
pub(crate) async fn prepare_comment_test(
|
||||
url: &Url,
|
||||
context: &LemmyContext,
|
||||
) -> (ApubPerson, ApubCommunity, ApubPost) {
|
||||
let person_json = file_to_json_object("assets/lemmy-person.json");
|
||||
let person_json = file_to_json_object("assets/lemmy/objects/person.json");
|
||||
let person = ApubPerson::from_apub(&person_json, context, url, &mut 0)
|
||||
.await
|
||||
.unwrap();
|
||||
let community_json = file_to_json_object("assets/lemmy-community.json");
|
||||
let community_json = file_to_json_object("assets/lemmy/objects/group.json");
|
||||
let community = ApubCommunity::from_apub(&community_json, context, url, &mut 0)
|
||||
.await
|
||||
.unwrap();
|
||||
let post_json = file_to_json_object("assets/lemmy-post.json");
|
||||
let post_json = file_to_json_object("assets/lemmy/objects/page.json");
|
||||
let post = ApubPost::from_apub(&post_json, context, url, &mut 0)
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -229,7 +228,7 @@ pub(crate) mod tests {
|
|||
let url = Url::parse("https://enterprise.lemmy.ml/comment/38741").unwrap();
|
||||
let data = prepare_comment_test(&url, &context).await;
|
||||
|
||||
let json = file_to_json_object("assets/lemmy-comment.json");
|
||||
let json = file_to_json_object("assets/lemmy/objects/note.json");
|
||||
let mut request_counter = 0;
|
||||
let comment = ApubComment::from_apub(&json, &context, &url, &mut request_counter)
|
||||
.await
|
||||
|
@ -257,11 +256,11 @@ pub(crate) mod tests {
|
|||
let pleroma_url =
|
||||
Url::parse("https://queer.hacktivis.me/objects/8d4973f4-53de-49cd-8c27-df160e16a9c2")
|
||||
.unwrap();
|
||||
let person_json = file_to_json_object("assets/pleroma-person.json");
|
||||
let person_json = file_to_json_object("assets/pleroma/objects/person.json");
|
||||
ApubPerson::from_apub(&person_json, &context, &pleroma_url, &mut 0)
|
||||
.await
|
||||
.unwrap();
|
||||
let json = file_to_json_object("assets/pleroma-comment.json");
|
||||
let json = file_to_json_object("assets/pleroma/objects/note.json");
|
||||
let mut request_counter = 0;
|
||||
let comment = ApubComment::from_apub(&json, &context, &pleroma_url, &mut request_counter)
|
||||
.await
|
||||
|
|
|
@ -223,20 +223,17 @@ impl ApubCommunity {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use assert_json_diff::assert_json_include;
|
||||
use serial_test::serial;
|
||||
|
||||
use lemmy_db_schema::traits::Crud;
|
||||
|
||||
use crate::objects::tests::{file_to_json_object, init_context};
|
||||
|
||||
use super::*;
|
||||
use crate::objects::tests::{file_to_json_object, init_context};
|
||||
use assert_json_diff::assert_json_include;
|
||||
use lemmy_db_schema::traits::Crud;
|
||||
use serial_test::serial;
|
||||
|
||||
#[actix_rt::test]
|
||||
#[serial]
|
||||
async fn test_parse_lemmy_community() {
|
||||
let context = init_context();
|
||||
let mut json: Group = file_to_json_object("assets/lemmy-community.json");
|
||||
let mut json: Group = file_to_json_object("assets/lemmy/objects/group.json");
|
||||
let json_orig = json.clone();
|
||||
// change these links so they dont fetch over the network
|
||||
json.moderators = Some(ObjectId::new(
|
||||
|
|
|
@ -256,7 +256,7 @@ mod tests {
|
|||
#[serial]
|
||||
async fn test_parse_lemmy_person() {
|
||||
let context = init_context();
|
||||
let json = file_to_json_object("assets/lemmy-person.json");
|
||||
let json = file_to_json_object("assets/lemmy/objects/person.json");
|
||||
let url = Url::parse("https://enterprise.lemmy.ml/u/picard").unwrap();
|
||||
let mut request_counter = 0;
|
||||
let person = ApubPerson::from_apub(&json, &context, &url, &mut request_counter)
|
||||
|
@ -280,7 +280,7 @@ mod tests {
|
|||
#[serial]
|
||||
async fn test_parse_pleroma_person() {
|
||||
let context = init_context();
|
||||
let json = file_to_json_object("assets/pleroma-person.json");
|
||||
let json = file_to_json_object("assets/pleroma/objects/person.json");
|
||||
let url = Url::parse("https://queer.hacktivis.me/users/lanodan").unwrap();
|
||||
let mut request_counter = 0;
|
||||
let person = ApubPerson::from_apub(&json, &context, &url, &mut request_counter)
|
||||
|
|
|
@ -206,15 +206,15 @@ mod tests {
|
|||
async fn test_parse_lemmy_post() {
|
||||
let context = init_context();
|
||||
let url = Url::parse("https://enterprise.lemmy.ml/post/55143").unwrap();
|
||||
let community_json = file_to_json_object("assets/lemmy-community.json");
|
||||
let community_json = file_to_json_object("assets/lemmy/objects/group.json");
|
||||
let community = ApubCommunity::from_apub(&community_json, &context, &url, &mut 0)
|
||||
.await
|
||||
.unwrap();
|
||||
let person_json = file_to_json_object("assets/lemmy-person.json");
|
||||
let person_json = file_to_json_object("assets/lemmy/objects/person.json");
|
||||
let person = ApubPerson::from_apub(&person_json, &context, &url, &mut 0)
|
||||
.await
|
||||
.unwrap();
|
||||
let json = file_to_json_object("assets/lemmy-post.json");
|
||||
let json = file_to_json_object("assets/lemmy/objects/page.json");
|
||||
let mut request_counter = 0;
|
||||
let post = ApubPost::from_apub(&json, &context, &url, &mut request_counter)
|
||||
.await
|
||||
|
|
|
@ -146,11 +146,11 @@ mod tests {
|
|||
use serial_test::serial;
|
||||
|
||||
async fn prepare_comment_test(url: &Url, context: &LemmyContext) -> (ApubPerson, ApubPerson) {
|
||||
let lemmy_person = file_to_json_object("assets/lemmy-person.json");
|
||||
let lemmy_person = file_to_json_object("assets/lemmy/objects/person.json");
|
||||
let person1 = ApubPerson::from_apub(&lemmy_person, context, url, &mut 0)
|
||||
.await
|
||||
.unwrap();
|
||||
let pleroma_person = file_to_json_object("assets/pleroma-person.json");
|
||||
let pleroma_person = file_to_json_object("assets/pleroma/objects/person.json");
|
||||
let pleroma_url = Url::parse("https://queer.hacktivis.me/users/lanodan").unwrap();
|
||||
let person2 = ApubPerson::from_apub(&pleroma_person, context, &pleroma_url, &mut 0)
|
||||
.await
|
||||
|
@ -169,7 +169,7 @@ mod tests {
|
|||
let context = init_context();
|
||||
let url = Url::parse("https://enterprise.lemmy.ml/private_message/1621").unwrap();
|
||||
let data = prepare_comment_test(&url, &context).await;
|
||||
let json = file_to_json_object("assets/lemmy-private-message.json");
|
||||
let json = file_to_json_object("assets/lemmy/objects/chat_message.json");
|
||||
let mut request_counter = 0;
|
||||
let pm = ApubPrivateMessage::from_apub(&json, &context, &url, &mut request_counter)
|
||||
.await
|
||||
|
@ -193,7 +193,7 @@ mod tests {
|
|||
let url = Url::parse("https://enterprise.lemmy.ml/private_message/1621").unwrap();
|
||||
let data = prepare_comment_test(&url, &context).await;
|
||||
let pleroma_url = Url::parse("https://queer.hacktivis.me/objects/2").unwrap();
|
||||
let json = file_to_json_object("assets/pleroma-private-message.json");
|
||||
let json = file_to_json_object("assets/pleroma/objects/chat_message.json");
|
||||
let mut request_counter = 0;
|
||||
let pm = ApubPrivateMessage::from_apub(&json, &context, &pleroma_url, &mut request_counter)
|
||||
.await
|
||||
|
|
Loading…
Reference in a new issue