You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hydrus-api-rs/tests/wrapper/test_hydrus.rs

72 lines
1.9 KiB
Rust

use super::super::common;
use hydrus_api::api_core::adding_tags::TagAction;
use hydrus_api::wrapper::builders::search_builder::SortType;
use hydrus_api::wrapper::service::{ServiceName, ServiceType};
use hydrus_api::wrapper::url::UrlType;
#[tokio::test]
async fn it_retrieves_version_info() {
let hydrus = common::get_hydrus();
let version = hydrus.version().await.unwrap();
assert!(version.hydrus > 0);
assert!(version.api > 0);
}
#[tokio::test]
async fn it_retrieves_services() {
let hydrus = common::get_hydrus();
let services = hydrus.services().await.unwrap();
// assuming hydrus is configured correctly
assert!(services.get_services(ServiceType::AllKnownFiles).len() > 0);
assert!(services.get_services(ServiceType::AllKnownTags).len() > 0);
}
#[tokio::test]
async fn it_retrieves_url_information() {
let hydrus = common::get_hydrus();
let url = hydrus
.url("https://www.pixiv.net/member_illust.php?illust_id=83406361&mode=medium")
.await
.unwrap();
assert_eq!(url.url_type, UrlType::Post)
}
#[tokio::test]
async fn it_searches() {
let hydrus = common::get_hydrus();
hydrus
.search()
.add_tag("character:megumin".into())
.sort_by(SortType::ModifiedTime)
.run()
.await
.unwrap();
}
#[tokio::test]
async fn it_adds_tags() {
let hydrus = common::get_hydrus();
hydrus
.tagging()
.add_tag(
ServiceName::my_tags(),
TagAction::AddToLocalService,
"summer".into(),
)
.add_file("0000000000000000000000000000000000000000000000000000000000000000")
.run()
.await
.unwrap();
}
#[tokio::test]
async fn it_sets_the_user_agent() {
let hydrus = common::get_hydrus();
hydrus
.set_user_agent("Mozilla/5.0 (compatible; Hydrus Client)")
.await
.unwrap();
}