view tests/test_web.py @ 6:316e1d54ffd4

move to jinja templates
author Jeff Hammel <k0scist@gmail.com>
date Sat, 24 Jun 2017 15:47:59 -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()