1
|
1 #!/usr/bin/env python
|
|
2
|
|
3 """
|
|
4 test web functionality
|
|
5 """
|
|
6
|
|
7 import os
|
|
8 import unittest
|
|
9 from common import datafile
|
|
10 from globalneighbors.read import read_city_list
|
|
11 from globalneighbors.web import autocomplete
|
|
12
|
|
13
|
|
14 class WebFunctionalityTest(unittest.TestCase):
|
|
15
|
|
16 def test_autcomplete(self):
|
|
17 """test autocomplete underlying functionality"""
|
|
18
|
|
19 # read base data
|
|
20 cityfile = datafile('cities1000.txt')
|
|
21 assert os.path.exists(cityfile)
|
|
22 cities = read_city_list(cityfile)
|
|
23
|
|
24 # Let's look for Chicago
|
|
25 q = u'Ch'
|
|
26 results = autocomplete(cities, q)
|
|
27 assert all([result.startswith(q)
|
|
28 for result in results])
|
|
29 assert sorted(results) == results
|
|
30 assert 'Chicago' in results
|
|
31
|
|
32
|
|
33 if __name__ == '__main__':
|
|
34 unittest.main()
|