Exemplo n.º 1
0
 def test_multiple_address_components(self):
     '''ensures handling of results with duplicate address components works correctly'''
     result = GoogleGeocodingResponse(self._open_test_json('pittsburgh.json')).best_result(wrapped=True)
     # ensure multiple results are returned if asked for
     self.assertEquals(len(result.get_address_component('political',allow_multiple=True)),4)
     # ensure exception is thrown if multiple results aren't asked for
     with self.assertRaises(KeyError):
         result.get_address_component('political')
     # ensure empty list is returned works for unavaible key whene allow_multiple=True
     self.assertEquals(len(result.get_address_component('route',allow_multiple=True)),0)
     # ensure default argument works for unavaible key
     self.assertEquals(result.get_address_component('route'),None)
     self.assertEquals(result.get_address_component('route',default='boo boo kitty'),'boo boo kitty')
Exemplo n.º 2
0
 def test_multiple_address_components(self):
     '''ensures handling of results with duplicate address components works correctly'''
     result = GoogleGeocodingResponse(
         self._open_test_json('pittsburgh.json')).best_result(wrapped=True)
     # ensure multiple results are returned if asked for
     self.assertEquals(
         len(result.get_address_component('political',
                                          allow_multiple=True)), 4)
     # ensure exception is thrown if multiple results aren't asked for
     with self.assertRaises(KeyError):
         result.get_address_component('political')
     # ensure empty list is returned works for unavaible key whene allow_multiple=True
     self.assertEquals(
         len(result.get_address_component('route', allow_multiple=True)), 0)
     # ensure default argument works for unavaible key
     self.assertEquals(result.get_address_component('route'), None)
     self.assertEquals(
         result.get_address_component('route', default='boo boo kitty'),
         'boo boo kitty')
Exemplo n.º 3
0
 def test_zero_results_handling(self):
     '''ensure geocoding wrapper gracefully handles zero results returned'''
     response = GoogleGeocodingResponse(self._open_test_json('zero-results.json'))
     self.assertEquals(len(response.results),0)
     self.assertIsNone(response.best_result(),None)
Exemplo n.º 4
0
 def _json_to_best_result(self,fn):
     response = GoogleGeocodingResponse(self._open_test_json(fn))
     return response.best_result(wrapped=True)
Exemplo n.º 5
0
 def test_zero_results_handling(self):
     '''ensure geocoding wrapper gracefully handles zero results returned'''
     response = GoogleGeocodingResponse(
         self._open_test_json('zero-results.json'))
     self.assertEquals(len(response.results), 0)
     self.assertIsNone(response.best_result(), None)
Exemplo n.º 6
0
 def _json_to_best_result(self, fn):
     response = GoogleGeocodingResponse(self._open_test_json(fn))
     return response.best_result(wrapped=True)