-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_helpers.py
49 lines (43 loc) · 1.68 KB
/
test_helpers.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
import unittest
import os
from helpers import get_image_selection
class TestWikipedia (unittest.TestCase):
"""
Defines the unit test cases for the various helper functions used
"""
def test_wikipedia_response(self):
"""
Tests if we successfully got a list of images back from Wikipedia
"""
# Check a bunch of different possible titles and make sure images are returned
title_list = ['lion']
for title in title_list:
image_list = get_image_selection(title)
self.assertTrue(len(image_list)>0)
def test_wikipedia_redirect(self):
"""
Tests if the function can handle slight changes (ex. 'lions' should direct to the 'Lion' page)
"""
# Check a bunch of different possible titles and make sure images are returned
title_list = ['lions']
for title in title_list:
image_list = get_image_selection(title)
self.assertTrue(len(image_list)>0)
def test_wikipedia_nobigpics(self):
"""
Makes sure that if a page is returned but it has no pics that are big enough, returns a blank list but no errors
"""
title_list = ['landshark', 'oil drilling']
for title in title_list:
image_list = get_image_selection(title)
self.assertTrue(True)
def test_wikipedia_nonsense(self):
"""
Makes sure that if nonsense is supplied function returns a blank list, but no errors
"""
title_list = ['sfjisakl;fjwi;']
for title in title_list:
image_list = get_image_selection(title)
self.assertTrue(True)
if __name__ == '__main__':
unittest.main()