示例#1
0
 def test_relatively_new_zip_code(self):
     # NOTA BENE: this test may need updating every so often when the
     # database gets updated.
     expected = coordinates.LatLongCoordinate(40.762, -111.892)
     actual = self.zs.search('84129')
     self.assertAlmostEqual(expected.latitude, actual.latitude, places=3)
     self.assertAlmostEqual(expected.longitude, actual.longitude, places=3)
示例#2
0
 def test_incorrect_state_close_enough(self):
     states = ['New Yuck', 'North Lakota', 'Tejas', 'Wsahingtion']
     points = [
         (43.155, -71.462), (47.348, -99.310), (30.905, -97.366), (47.331, -121.620),
     ]
     expected = [coordinates.LatLongCoordinate(a, b) for a, b in points]
     actual = self.ss.search_bulk(states)
     self.assertEqual(len(expected), len(actual))
     for i in range(len(expected)):
         with self.subTest(i=i):
             self.assertAlmostEqual(expected[i].latitude, actual[i].latitude, places=3)
             self.assertAlmostEqual(expected[i].longitude, actual[i].longitude, places=3)
示例#3
0
 def test_bulk_search(self):
     codes = [84129, 84118, 90210, 45302, 21030]
     points = [
         (40.762, -111.892),
         (40.650, -112.040),
         (34.100, -118.420),
         (40.400, -84.200),
         (39.490, -76.660),
     ]
     expected = [coordinates.LatLongCoordinate(a, b) for a, b in points]
     actual = self.zs.search_bulk(codes)
     self.assertEqual(len(expected), len(actual))
     for i in range(len(expected)):
         with self.subTest(i=i):
             self.assertAlmostEqual(expected[i].latitude, actual[i].latitude, places=3)
             self.assertAlmostEqual(expected[i].longitude, actual[i].longitude, places=3)
示例#4
0
 def test_bulk_search(self):
     states = ['North Dakota', 'Washington', 'Maryland', 'Florida', 'Iowa']
     points = [
         (47.348, -99.310),
         (47.331, -121.620),
         (39.141, -76.798),
         (27.823, -81.635),
         (41.946, -93.037),
     ]
     expected = [coordinates.LatLongCoordinate(a, b) for a, b in points]
     actual = self.ss.search_bulk(states)
     self.assertEqual(len(expected), len(actual))
     for i in range(len(expected)):
         with self.subTest(i=i):
             self.assertAlmostEqual(expected[i].latitude, actual[i].latitude, places=3)
             self.assertAlmostEqual(expected[i].longitude, actual[i].longitude, places=3)
 def test_bulk_search(self):
     cities = [
         ('Salt Lake City', 'UT'),
         ('Beverly Hills', 'CA'),
         ('Duluth', 'MN'),
         ('Dayton', 'OH'),
         ('Hunt Valley', 'MD'),
     ]
     points = [
         (40.762, -111.892),
         (34.075, -118.400),
         (46.864, -92.058),
         (39.777, -84.185),
         (39.488, -76.657),
     ]
     expected = [coordinates.LatLongCoordinate(a, b) for a, b in points]
     actual = self.cs.search_bulk(cities)
     self.assertEqual(len(expected), len(actual))
     for i in range(len(expected)):
         with self.subTest(i=i):
             self.assertAlmostEqual(expected[i].latitude, actual[i].latitude, places=3)
             self.assertAlmostEqual(expected[i].longitude, actual[i].longitude, places=3)
示例#6
0
 def test_established_zip_code(self):
     expected = coordinates.LatLongCoordinate(40.7599, -111.900)
     actual = self.zs.search('84101')
     self.assertAlmostEqual(expected.latitude, actual.latitude, places=3)
     self.assertAlmostEqual(expected.longitude, actual.longitude, places=3)
示例#7
0
 def test_new_york_to_rhode_island_imperial(self):
     ri = coordinates.LatLongCoordinate(*self.rhode_island)
     ny = coordinates.LatLongCoordinate(*self.new_york)
     gd = geodistance.GeoDistance(ri, ny)
     distance = gd.oblate_spheroid(units='imperial')
     self.assertAlmostEqual(distance, 164.565, places=3)
示例#8
0
 def test_new_york_to_rhode_island_metric(self):
     ri = coordinates.LatLongCoordinate(*self.rhode_island)
     ny = coordinates.LatLongCoordinate(*self.new_york)
     gd = geodistance.GeoDistance(ri, ny)
     distance = gd.oblate_spheroid()
     self.assertAlmostEqual(distance, 264.842, places=3)
示例#9
0
 def test_full_state_name(self):
     state = 'New York'
     expected = coordinates.LatLongCoordinate(41.501, -74.621)
     actual = self.ss.search(state)
     self.assertAlmostEqual(expected.latitude, actual.latitude, places=3)
     self.assertAlmostEqual(expected.longitude, actual.longitude, places=3)
示例#10
0
 def test_search_two_letter_state(self):
     state = 'UT'
     expected = coordinates.LatLongCoordinate(40.401, -111.927)
     actual = self.ss.search(state)
     self.assertAlmostEqual(expected.latitude, actual.latitude, places=3)
     self.assertAlmostEqual(expected.longitude, actual.longitude, places=3)
 def test_salt_lake(self):
     expected = coordinates.LatLongCoordinate(40.762, -111.892)
     actual = self.cs.search('Salt Lake City', 'UT')
     self.assertAlmostEqual(expected.latitude, actual.latitude, places=3)
     self.assertAlmostEqual(expected.longitude, actual.longitude, places=3)