Exemple #1
0
 def test_geocode_returns_invalid_format(self, mock):
     """Test geocode_location returns None if the response is unusual."""
     mock_geocoder = Mock()
     mock_geocoder.geocode.return_value = "this isn't right!"
     mock.return_value = mock_geocoder
     self.assertEqual(
         location.geocode_location('some location'),
         (None, None)
     )
Exemple #2
0
 def test_geocode_location_geocoder_raises_exception(self, mock):
     """Test that geocode_location returns None if there's an exception."""
     exception = ValueError('something went wrong')
     mock_geocoder = Mock()
     mock_geocoder.geocode.side_effect = exception
     mock.return_value = mock_geocoder
     self.assertEqual(
         location.geocode_location('some location'),
         (None, None)
     )
Exemple #3
0
 def test_geocode_location(self, mock):
     """Test that a location is geocoded correctly."""
     mock_geocoder = Mock()
     mock_geocoder.geocode.return_value = [
         (u'North Desplaines St & West Fulton Mkt, Chicago, IL 60661, USA',
          (41.8868014, -87.6442893))
     ]
     mock.return_value = mock_geocoder
     self.assertEqual(
         location.geocode_location('something'),
         (41.8868014, -87.6442893)
     )