use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
pub struct ArticleBody {
pub html: Option<String>,
pub wikitext: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
pub struct Image {
pub content_url: String,
pub width: Option<u64>,
pub height: Option<u64>,
pub caption: Option<String>,
pub alternative_text: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
pub struct License {
pub identifier: Option<String>,
pub name: String,
pub url: String,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_article_body() {
let body = ArticleBody {
html: Some("<p>Test content</p>".to_string()),
wikitext: Some("Test content".to_string()),
};
assert!(body.html.is_some());
assert!(body.wikitext.is_some());
}
#[test]
fn test_image() {
let image = Image {
content_url: "https://example.com/image.jpg".to_string(),
width: Some(800),
height: Some(600),
caption: Some("Test image".to_string()),
alternative_text: Some("Alt text".to_string()),
};
assert_eq!(image.width, Some(800));
assert_eq!(image.height, Some(600));
}
#[test]
fn test_license() {
let license = License {
identifier: Some("CC-BY-SA-4.0".to_string()),
name: "Creative Commons Attribution Share Alike 4.0".to_string(),
url: "https://creativecommons.org/licenses/by-sa/4.0/".to_string(),
};
assert_eq!(license.identifier, Some("CC-BY-SA-4.0".to_string()));
}
}