commit
d7a7ba20d8
@ -0,0 +1,51 @@
|
||||
use crate::api_core::common::PageInformation;
|
||||
use crate::api_core::Endpoint;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub struct GetPagesResponse {
|
||||
/// The top level notebook page
|
||||
pub pages: PageInformation,
|
||||
}
|
||||
|
||||
pub struct GetPages;
|
||||
|
||||
impl Endpoint for GetPages {
|
||||
type Request = ();
|
||||
type Response = GetPagesResponse;
|
||||
|
||||
fn path() -> String {
|
||||
String::from("manage_pages/get_pages")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub struct GetPageInfoResponse {
|
||||
pub page_info: PageInformation,
|
||||
}
|
||||
|
||||
pub struct GetPageInfo;
|
||||
|
||||
impl Endpoint for GetPageInfo {
|
||||
type Request = ();
|
||||
type Response = GetPageInfoResponse;
|
||||
|
||||
fn path() -> String {
|
||||
String::from("manage_pages/get_page_info")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct FocusPageRequest {
|
||||
pub page_key: String,
|
||||
}
|
||||
|
||||
pub struct FocusPage;
|
||||
|
||||
impl Endpoint for FocusPage {
|
||||
type Request = FocusPageRequest;
|
||||
type Response = ();
|
||||
|
||||
fn path() -> String {
|
||||
String::from("manage_pages/focus_page")
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
use super::super::common;
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_returns_all_pages() {
|
||||
let client = common::get_client();
|
||||
client.get_pages().await.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_returns_page_info() {
|
||||
let client = common::get_client();
|
||||
let result = client
|
||||
.get_page_info("0c33d6599c22d5ec12a57b79d8c5a528ebdab7a8c2b462e6d76e2d0512e917fd")
|
||||
.await;
|
||||
assert!(result.is_err()); // page does not exist
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_focuses_pages() {
|
||||
let client = common::get_client();
|
||||
let result = client
|
||||
.focus_page("0c33d6599c22d5ec12a57b79d8c5a528ebdab7a8c2b462e6d76e2d0512e917fd")
|
||||
.await;
|
||||
|
||||
assert!(result.is_err()); // page does not exist
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
use super::super::common;
|
||||
use hydrus_api::wrapper::page::HydrusPage;
|
||||
|
||||
async fn get_page() -> HydrusPage {
|
||||
let hydrus = common::get_hydrus();
|
||||
|
||||
hydrus.root_page().await.unwrap()
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_can_be_focused() {
|
||||
let page = get_page().await;
|
||||
page.focus().await.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_has_a_name() {
|
||||
let page = get_page().await;
|
||||
assert!(page.name.len() > 0)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_has_a_key() {
|
||||
let page = get_page().await;
|
||||
assert!(page.key.len() > 0)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_has_a_id() {
|
||||
let page = get_page().await;
|
||||
page.id();
|
||||
}
|
Loading…
Reference in New Issue