1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
pub mod error;
pub mod keyboard;
pub mod matchit;
pub mod ndarray;

pub use error::*;
pub use matchit::*;
pub use ndarray::*;

use crate::{extract::Update, responses::Event, RequestBuilder};
use serde_json::{json, Value};

pub struct TestHardness {
    pub update: Update,
}

impl TestHardness {
    pub fn new(object: Vec<Event<Value>>) -> TestHardness {
        TestHardness {
            update: Update {
                ts: None,
                updates: Some(object),
                failed: None,
            },
        }
    }

    pub fn dummy_request(&self) -> RequestBuilder {
        RequestBuilder::new("my super hidden token", 10000)
    }

    pub fn dummy_message(message: &str) -> Event<Value> {
        Event {
            event_id: String::from("0"),
            update_type: String::from("message_new"),
            v: String::from("1.599"),
            object: json!({
                "client_info": {
                    "button_actions": [
                        "text",
                        "vkpay",
                        "open_app",
                        "location",
                        "open_link",
                        "open_photo",
                        "callback",
                        "intent_subscribe",
                        "intent_unsubscribe",
                    ],
                    "carousel": true,
                    "inline_keyboard": true,
                    "keyboard": true,
                    "lang_id": 0,
                },
                "message": {
                    "attachments": [],
                    "conversation_message_id": 000000,
                    "date": 0000000,
                    "from_id": 00000000,
                    "fwd_messages": [],
                    "id": 0,
                    "important": false,
                    "is_hidden": false,
                    "is_unavailable": true,
                    "out": 0,
                    "peer_id": 0000000000,
                    "random_id": 0,
                    "text": message,
                    "version": 0000000,
                },
            }),
        }
    }
}