mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +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]
|
||||
fn de_sticker() {
|
||||
let json = r#"{
|
||||
"message_id": 199787,
|
||||
"from": {
|
||||
"id": 250918540,
|
||||
"is_bot": false,
|
||||
"first_name": "Андрей",
|
||||
"last_name": "Власов",
|
||||
"username": "aka_dude",
|
||||
"language_code": "en"
|
||||
},
|
||||
"chat": {
|
||||
"id": 250918540,
|
||||
"first_name": "Андрей",
|
||||
"last_name": "Власов",
|
||||
"username": "aka_dude",
|
||||
"type": "private"
|
||||
},
|
||||
"date": 1568290188,
|
||||
"sticker": {
|
||||
"width": 512,
|
||||
"height": 512,
|
||||
"emoji": "😡",
|
||||
"set_name": "AdvenTimeAnim",
|
||||
"is_animated": true,
|
||||
"is_video": false,
|
||||
"thumb": {
|
||||
"file_id": "AAQCAAMjAAOw0PgMaabKAcaXKCBLubkPAAQBAAdtAAPGKwACFgQ",
|
||||
"file_unique_id":"",
|
||||
"file_size": 4118,
|
||||
"width": 128,
|
||||
"height": 128
|
||||
},
|
||||
"file_id": "CAADAgADIwADsND4DGmmygHGlyggFgQ",
|
||||
"file_unique_id":"",
|
||||
"file_size": 16639
|
||||
}
|
||||
}"#;
|
||||
"message_id": 199787,
|
||||
"from": {
|
||||
"id": 250918540,
|
||||
"is_bot": false,
|
||||
"first_name": "Андрей",
|
||||
"last_name": "Власов",
|
||||
"username": "aka_dude",
|
||||
"language_code": "en"
|
||||
},
|
||||
"chat": {
|
||||
"id": 250918540,
|
||||
"first_name": "Андрей",
|
||||
"last_name": "Власов",
|
||||
"username": "aka_dude",
|
||||
"type": "private"
|
||||
},
|
||||
"date": 1568290188,
|
||||
"sticker": {
|
||||
"width": 512,
|
||||
"height": 512,
|
||||
"emoji": "😡",
|
||||
"set_name": "AdvenTimeAnim",
|
||||
"is_animated": true,
|
||||
"is_video": false,
|
||||
"type": "regular",
|
||||
"thumb": {
|
||||
"file_id": "AAMCAgADGQEAARIt0GMwiZ6n4nRbxdpM3pL8vPX6PVAhAAIjAAOw0PgMaabKAcaXKCABAAdtAAMpBA",
|
||||
"file_unique_id": "AQADIwADsND4DHI",
|
||||
"file_size": 4118,
|
||||
"width": 128,
|
||||
"height": 128
|
||||
},
|
||||
"file_id": "CAACAgIAAxkBAAESLdBjMImep-J0W8XaTN6S_Lz1-j1QIQACIwADsND4DGmmygHGlyggKQQ",
|
||||
"file_unique_id": "AgADIwADsND4DA",
|
||||
"file_size": 16639
|
||||
}
|
||||
}"#;
|
||||
from_str::<Message>(json).unwrap();
|
||||
}
|
||||
|
||||
|
|
|
@ -119,8 +119,8 @@ pub enum StickerFormat {
|
|||
/// let _ = sticker.is_regular();
|
||||
/// let _ = sticker.kind.is_regular();
|
||||
///
|
||||
/// let _ sticker.mask_position();
|
||||
/// let _ sticker.kind.mask_position();
|
||||
/// let _ = sticker.mask_position();
|
||||
/// let _ = sticker.kind.mask_position();
|
||||
/// ```
|
||||
impl Deref for Sticker {
|
||||
type Target = StickerKind;
|
||||
|
@ -418,7 +418,7 @@ mod tests {
|
|||
#[test]
|
||||
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();
|
||||
assert_eq!(fmt, StickerFormat::Raster);
|
||||
|
||||
|
@ -426,7 +426,7 @@ mod tests {
|
|||
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();
|
||||
assert_eq!(fmt, StickerFormat::Animated);
|
||||
|
||||
|
@ -434,7 +434,7 @@ mod tests {
|
|||
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();
|
||||
assert_eq!(fmt, StickerFormat::Video);
|
||||
|
||||
|
@ -442,7 +442,7 @@ mod tests {
|
|||
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);
|
||||
assert!(fmt.is_err());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue