view tests/test_web.py @ 12:6d89ea94930b

add passthrough fileserver for autocomplete
author Jeff Hammel <k0scist@gmail.com>
date Sun, 25 Jun 2017 13:18:13 -0700
parents 1b94f3bf97e5
children 94af113e498a
line wrap: on
line source

#!/usr/bin/env python

"""
test web functionality
"""

import os
import unittest
from common import datafile
from globalneighbors.read import read_city_list
from globalneighbors.web import autocomplete


class WebFunctionalityTest(unittest.TestCase):

    def test_autcomplete(self):
        """test autocomplete underlying functionality"""

        # read base data
        cityfile = datafile('cities1000.txt')
        assert os.path.exists(cityfile)
        cities = read_city_list(cityfile)

        # Let's look for Chicago
        q = u'Ch'
        results = autocomplete(cities, q)
        assert all([result.startswith(q)
                    for result in results])
        assert sorted(results) == results
        assert 'Chicago' in results


if __name__ == '__main__':
    unittest.main()