-
Notifications
You must be signed in to change notification settings - Fork 16
/
tests.py
78 lines (67 loc) · 2.48 KB
/
tests.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
import unittest, spotify_bot
class TestInlineQueryHandling(unittest.TestCase):
def setUp(self):
self.emptyQuery = ''
self.nonEmptyQuery = 'Coldplay'
self.emptyResults = []
self.nonEmptyResults = [{"artist": "Coldplay"}]
def test_empty_query(self):
self.assertTrue(spotify_bot.is_empty_query(self.emptyQuery))
def test_nonempty_query(self):
self.assertFalse(spotify_bot.is_empty_query(self.nonEmptyQuery))
def test_empty_results(self):
self.assertTrue(spotify_bot.check_no_results(self.emptyResults))
def test_nonempty_results(self):
self.assertFalse(spotify_bot.check_no_results(self.nonEmptyResults))
def test_get_thumbnail_noThumnail(self):
response = {}
empty_tuple = spotify_bot.get_thumbnail(response)
self.assertTrue(empty_tuple[0] == None
and empty_tuple[1] == None
and empty_tuple[2] == None)
def test_get_thumbnail_thumbnailExists(self):
response = {
'images' : [ {
'url' : 'some_url',
'width' : 123,
'height' : 123
}]
}
thumbnail_info = spotify_bot.get_thumbnail(response)
self.assertTrue(thumbnail_info[0] != None
and thumbnail_info[1] != None
and thumbnail_info[2] != None)
def test_build_inline_query_article_track_thumbnail(self):
_type = 'Track'
response = {
'album' : {
'images' : [ {
'url' : 'some_url',
'width' : 123,
'height' : 123
}]
},
'external_urls': {
'spotify' : 'some_spotify_link'
},
'name' : 'some_name'
}
inlineQuery = spotify_bot.build_inline_query_result_article(_type, response)
self.assertIsNotNone(inlineQuery.thumb_url)
def test_build_inline_query_article_not_track_thumbnail(self):
_type = 'Album'
response = {
'images' : [{
'url' : 'some_url',
'width' : 123,
'height' : 123
}],
'external_urls': {
'spotify' : 'some_spotify_link'
},
'name' : 'some_name'
}
inlineQuery = spotify_bot.build_inline_query_result_article(_type, response)
self.assertIsNotNone(inlineQuery.thumb_url)
if __name__ == '__main__':
unittest.main()