-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_cliquery.py
42 lines (32 loc) · 1.25 KB
/
test_cliquery.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
#!/usr/bin/env python
"""Unit tests for cliquery"""
import unittest
from cliquery import cliquery
class CliqueryTestCase(unittest.TestCase):
def call_search(self, query):
parser = cliquery.get_parser()
args = vars(parser.parse_args(query.split()))
return cliquery.search(args)
def setUp(self):
self.queries = ['testing one two three',
'sentence with $p3c!@l-chars',
'nospaces']
self.inst_queries = ['how old is barack obama']
def tearDown(self):
pass
def test_answer_links(self):
"""-fp returns the url of top link"""
for query in self.queries:
links = self.call_search(query + ' -fp')
if isinstance(links, list):
for link in links:
self.assertTrue(link.startswith('http://') or
link.startswith('https://'))
elif links is None:
# None indicates an internet connection error
pass
elif not isinstance(links, bool):
self.assertTrue(links.startswith('http://') or
links.startswith('https://'))
if __name__ == '__main__':
unittest.main()