mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-24 23:57:38 +01:00
Fix sticker tests
This commit is contained in:
parent
7550af9a25
commit
8cad09498c
2 changed files with 43 additions and 42 deletions
|
@ -1435,42 +1435,43 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn de_sticker() {
|
fn de_sticker() {
|
||||||
let json = r#"{
|
let json = r#"{
|
||||||
"message_id": 199787,
|
"message_id": 199787,
|
||||||
"from": {
|
"from": {
|
||||||
"id": 250918540,
|
"id": 250918540,
|
||||||
"is_bot": false,
|
"is_bot": false,
|
||||||
"first_name": "Андрей",
|
"first_name": "Андрей",
|
||||||
"last_name": "Власов",
|
"last_name": "Власов",
|
||||||
"username": "aka_dude",
|
"username": "aka_dude",
|
||||||
"language_code": "en"
|
"language_code": "en"
|
||||||
},
|
},
|
||||||
"chat": {
|
"chat": {
|
||||||
"id": 250918540,
|
"id": 250918540,
|
||||||
"first_name": "Андрей",
|
"first_name": "Андрей",
|
||||||
"last_name": "Власов",
|
"last_name": "Власов",
|
||||||
"username": "aka_dude",
|
"username": "aka_dude",
|
||||||
"type": "private"
|
"type": "private"
|
||||||
},
|
},
|
||||||
"date": 1568290188,
|
"date": 1568290188,
|
||||||
"sticker": {
|
"sticker": {
|
||||||
"width": 512,
|
"width": 512,
|
||||||
"height": 512,
|
"height": 512,
|
||||||
"emoji": "😡",
|
"emoji": "😡",
|
||||||
"set_name": "AdvenTimeAnim",
|
"set_name": "AdvenTimeAnim",
|
||||||
"is_animated": true,
|
"is_animated": true,
|
||||||
"is_video": false,
|
"is_video": false,
|
||||||
"thumb": {
|
"type": "regular",
|
||||||
"file_id": "AAQCAAMjAAOw0PgMaabKAcaXKCBLubkPAAQBAAdtAAPGKwACFgQ",
|
"thumb": {
|
||||||
"file_unique_id":"",
|
"file_id": "AAMCAgADGQEAARIt0GMwiZ6n4nRbxdpM3pL8vPX6PVAhAAIjAAOw0PgMaabKAcaXKCABAAdtAAMpBA",
|
||||||
"file_size": 4118,
|
"file_unique_id": "AQADIwADsND4DHI",
|
||||||
"width": 128,
|
"file_size": 4118,
|
||||||
"height": 128
|
"width": 128,
|
||||||
},
|
"height": 128
|
||||||
"file_id": "CAADAgADIwADsND4DGmmygHGlyggFgQ",
|
},
|
||||||
"file_unique_id":"",
|
"file_id": "CAACAgIAAxkBAAESLdBjMImep-J0W8XaTN6S_Lz1-j1QIQACIwADsND4DGmmygHGlyggKQQ",
|
||||||
"file_size": 16639
|
"file_unique_id": "AgADIwADsND4DA",
|
||||||
}
|
"file_size": 16639
|
||||||
}"#;
|
}
|
||||||
|
}"#;
|
||||||
from_str::<Message>(json).unwrap();
|
from_str::<Message>(json).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,8 +119,8 @@ pub enum StickerFormat {
|
||||||
/// let _ = sticker.is_regular();
|
/// let _ = sticker.is_regular();
|
||||||
/// let _ = sticker.kind.is_regular();
|
/// let _ = sticker.kind.is_regular();
|
||||||
///
|
///
|
||||||
/// let _ sticker.mask_position();
|
/// let _ = sticker.mask_position();
|
||||||
/// let _ sticker.kind.mask_position();
|
/// let _ = sticker.kind.mask_position();
|
||||||
/// ```
|
/// ```
|
||||||
impl Deref for Sticker {
|
impl Deref for Sticker {
|
||||||
type Target = StickerKind;
|
type Target = StickerKind;
|
||||||
|
@ -418,7 +418,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn sticker_format_serde() {
|
fn sticker_format_serde() {
|
||||||
{
|
{
|
||||||
let json = r#"{"is_animation":false,"is_video":false}"#;
|
let json = r#"{"is_animated":false,"is_video":false}"#;
|
||||||
let fmt: StickerFormat = serde_json::from_str(json).unwrap();
|
let fmt: StickerFormat = serde_json::from_str(json).unwrap();
|
||||||
assert_eq!(fmt, StickerFormat::Raster);
|
assert_eq!(fmt, StickerFormat::Raster);
|
||||||
|
|
||||||
|
@ -426,7 +426,7 @@ mod tests {
|
||||||
assert_eq!(json, json2);
|
assert_eq!(json, json2);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let json = r#"{"is_animation":true,"is_video":false}"#;
|
let json = r#"{"is_animated":true,"is_video":false}"#;
|
||||||
let fmt: StickerFormat = serde_json::from_str(json).unwrap();
|
let fmt: StickerFormat = serde_json::from_str(json).unwrap();
|
||||||
assert_eq!(fmt, StickerFormat::Animated);
|
assert_eq!(fmt, StickerFormat::Animated);
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ mod tests {
|
||||||
assert_eq!(json, json2);
|
assert_eq!(json, json2);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let json = r#"{"is_animation":false,"is_video":true}"#;
|
let json = r#"{"is_animated":false,"is_video":true}"#;
|
||||||
let fmt: StickerFormat = serde_json::from_str(json).unwrap();
|
let fmt: StickerFormat = serde_json::from_str(json).unwrap();
|
||||||
assert_eq!(fmt, StickerFormat::Video);
|
assert_eq!(fmt, StickerFormat::Video);
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ mod tests {
|
||||||
assert_eq!(json, json2);
|
assert_eq!(json, json2);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let json = r#"{"is_animation":true,"is_video":true}"#;
|
let json = r#"{"is_animated":true,"is_video":true}"#;
|
||||||
let fmt: Result<StickerFormat, _> = serde_json::from_str(json);
|
let fmt: Result<StickerFormat, _> = serde_json::from_str(json);
|
||||||
assert!(fmt.is_err());
|
assert!(fmt.is_err());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue