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