diff tests/test_web.py @ 1:1b94f3bf97e5

* limit distance function * start gridding * improve unicode handling
author Jeff Hammel <k0scist@gmail.com>
date Sat, 24 Jun 2017 14:02:14 -0700
parents
children 94af113e498a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_web.py	Sat Jun 24 14:02:14 2017 -0700
@@ -0,0 +1,34 @@
+#!/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()