-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_app.py
108 lines (87 loc) · 2.81 KB
/
test_app.py
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import app
import math
from datetime import datetime
def test_lambda():
assert app.isascii('a') == True
assert app.isascii('る') == False
def test_init():
app.init()
def test_confidence():
assert math.isclose(app.get_required_confidence("derp"), 0.525)
assert math.isclose(app.get_required_confidence("omg wtf bbq this is totally a legit sequance of words"),0.2)
def test_split_trivial():
assert app.split_words("What the fuck")[0].strip() == "What the fuck"
def test_split_mixed():
words = app.split_words("没有人 overnight 的")
assert words[0].strip() == "没有人"
assert words[1].strip() == "overnight"
assert words[2].strip() == "的"
def test_translate():
app.init()
lang, text = app.translate_text("wo bu yao")
assert lang == 'zh'
lang, text = app.translate_text("hello")
assert text == ""
def test_handle():
# msg = {}
# msg['text'] = 'Fake message'
# msg['from'] = {}
# msg['chat'] = {'id' : 0}
app.handle('Fake message', 0, 0)
def test_handle_translate1():
app.test_mode()
# msg = {}
# msg['text'] = 'dui you ne?'
# msg['from'] = {}
# msg['message_id'] = 0
# msg['chat'] = {'id' : 0}
app.handle('dui you ne?', 0, 0)
def test_handle_translate2():
app.test_mode()
# msg = {}
# msg['text'] = '没有人 overnight 的'
# msg['from'] = {}
# msg['message_id'] = 0
# msg['chat'] = {'id' : 0}
app.handle('没有人 overnight 的',0,0)
def test_handle_command_lyrics():
app.test_mode()
# msg = {}
# msg['text'] = '/lyrics the art of dying by gojira'
# msg['from'] = {}
# msg['message_id'] = 0
# msg['chat'] = {'id' : 0}
app.handle('/lyrics the art of dying by gojira', 0,0)
def test_handle_back():
# msg = {'date' : 0}
app.handle('',0, 0, datetime.utcfromtimestamp(0))
def test_wiki1():
app.test_mode()
app.handle_command('/wiki metallica', 0)
def test_wiki2():
app.test_mode()
app.handle_command('/wiki battery', 0)
def test_wiki3():
app.test_mode()
app.handle_command('/wiki asdhajshdkhwirqwiofhaishd', 0)
def test_lyrics1():
app.test_mode()
app.handle_command('/lyrics backbone by gojira', 0)
def test_lyrics2():
app.test_mode()
app.handle_command('/lyrics Rapid Elemental Dissolve', 0)
def test_lyrics3():
app.test_mode()
app.handle_command('/lyrics asdwqjwodjaosjdoqjwodjaosd', 0)
def test_lyrics4():
app.test_mode()
app.handle_command('/lyrics asdwqjwodjaosjdoqjwodjaosd by qiwjdoijasidjoqiwjdoiajsodijqwd', 0)
def test_animelyrics():
app.test_mode()
app.handle_command('/animelyrics renai circulation', 0)
def test_animelyrics_no_lyrics():
app.test_mode()
app.handle_command('/animelyrics omgwtfbbq', 0)
def test_no_command():
app.test_mode()
assert app.handle_command('peanut', 0) == False