Repository: geopandas/geopandas

Issue:
TST: use a different geocoder than GeocodeFarm in geocoding tests
The CI is failing under geopy new version 2.2.

The error from https://github.com/geopandas/geopandas/runs/3042280515?check_suite_focus=true#step:5:2930:

`GeocodeFarm` has been removed under geopy2.2, see geopy/geopy#445.

```python
_________________________________ test_forward _________________________________
[gw0] linux -- Python 3.7.7 /usr/share/miniconda/envs/test/bin/python

locations = ['260 Broadway, New York, NY', '77 Massachusetts Ave, Cambridge, MA']
points = [<shapely.geometry.point.Point object at 0x7f0ec0b22a10>, <shapely.geometry.point.Point object at 0x7f0ec0b22510>]

    def test_forward(locations, points):
>       from geopy.geocoders import GeocodeFarm
E       ImportError: cannot import name 'GeocodeFarm' from 'geopy.geocoders' (/usr/share/miniconda/envs/test/lib/python3.7/site-packages/geopy/geocoders/__init__.py)

geopandas/tests/test_geocode.py:141: ImportError
_________________________________ test_reverse _________________________________
[gw0] linux -- Python 3.7.7 /usr/share/miniconda/envs/test/bin/python

locations = ['260 Broadway, New York, NY', '77 Massachusetts Ave, Cambridge, MA']
points = [<shapely.geometry.point.Point object at 0x7f0ec0b39250>, <shapely.geometry.point.Point object at 0x7f0ec0b39c10>]

    def test_reverse(locations, points):
>       from geopy.geocoders import GeocodeFarm
E       ImportError: cannot import name 'GeocodeFarm' from 'geopy.geocoders' (/usr/share/miniconda/envs/test/lib/python3.7/site-packages/geopy/geocoders/__init__.py)

geopandas/tests/test_geocode.py:158: ImportError
```


Discussion:
Good catch. We just need to change our tests to use a different geocoder then. Nothing else needs to be done.

Resolving patch:
diff --git a/geopandas/tools/geocoding.py b/geopandas/tools/geocoding.py
--- a/geopandas/tools/geocoding.py
+++ b/geopandas/tools/geocoding.py
@@ -31,13 +31,12 @@ def geocode(strings, provider=None, **kwargs):
     strings : list or Series of addresses to geocode
     provider : str or geopy.geocoder
         Specifies geocoding service to use. If none is provided,
-        will use 'geocodefarm' with a rate limit applied (see the geocodefarm
-        terms of service at:
-        https://geocode.farm/geocoding/free-api-documentation/ ).
+        will use 'photon' (see the Photon's terms of service at:
+        https://photon.komoot.io).
 
         Either the string name used by geopy (as specified in
         geopy.geocoders.SERVICE_TO_GEOCODER) or a geopy Geocoder instance
-        (e.g., geopy.geocoders.GeocodeFarm) may be used.
+        (e.g., geopy.geocoders.Photon) may be used.
 
         Some providers require additional arguments such as access keys
         See each geocoder's specific parameters in geopy.geocoders
@@ -62,11 +61,8 @@ def geocode(strings, provider=None, **kwargs):
     """
 
     if provider is None:
-        # https://geocode.farm/geocoding/free-api-documentation/
-        provider = "geocodefarm"
-        throttle_time = 0.25
-    else:
-        throttle_time = _get_throttle_time(provider)
+        provider = "photon"
+    throttle_time = _get_throttle_time(provider)
 
     return _query(strings, True, provider, throttle_time, **kwargs)
 
@@ -85,13 +81,12 @@ def reverse_geocode(points, provider=None, **kwargs):
         y coordinate is latitude
     provider : str or geopy.geocoder (opt)
         Specifies geocoding service to use. If none is provided,
-        will use 'geocodefarm' with a rate limit applied (see the geocodefarm
-        terms of service at:
-        https://geocode.farm/geocoding/free-api-documentation/ ).
+        will use 'photon' (see the Photon's terms of service at:
+        https://photon.komoot.io).
 
         Either the string name used by geopy (as specified in
         geopy.geocoders.SERVICE_TO_GEOCODER) or a geopy Geocoder instance
-        (e.g., geopy.geocoders.GeocodeFarm) may be used.
+        (e.g., geopy.geocoders.Photon) may be used.
 
         Some providers require additional arguments such as access keys
         See each geocoder's specific parameters in geopy.geocoders
@@ -117,11 +112,8 @@ def reverse_geocode(points, provider=None, **kwargs):
     """
 
     if provider is None:
-        # https://geocode.farm/geocoding/free-api-documentation/
-        provider = "geocodefarm"
-        throttle_time = 0.25
-    else:
-        throttle_time = _get_throttle_time(provider)
+        provider = "photon"
+    throttle_time = _get_throttle_time(provider)
 
     return _query(points, False, provider, throttle_time, **kwargs)
 


Test patch:
diff --git a/geopandas/tests/test_geocode.py b/geopandas/tests/test_geocode.py
--- a/geopandas/tests/test_geocode.py
+++ b/geopandas/tests/test_geocode.py
@@ -138,10 +138,10 @@ def test_bad_provider_reverse():
 
 
 def test_forward(locations, points):
-    from geopy.geocoders import GeocodeFarm
+    from geopy.geocoders import Photon
 
-    for provider in ["geocodefarm", GeocodeFarm]:
-        with mock.patch("geopy.geocoders.GeocodeFarm.geocode", ForwardMock()) as m:
+    for provider in ["photon", Photon]:
+        with mock.patch("geopy.geocoders.Photon.geocode", ForwardMock()) as m:
             g = geocode(locations, provider=provider, timeout=2)
             assert len(locations) == m.call_count
 
@@ -155,10 +155,10 @@ def test_forward(locations, points):
 
 
 def test_reverse(locations, points):
-    from geopy.geocoders import GeocodeFarm
+    from geopy.geocoders import Photon
 
-    for provider in ["geocodefarm", GeocodeFarm]:
-        with mock.patch("geopy.geocoders.GeocodeFarm.reverse", ReverseMock()) as m:
+    for provider in ["photon", Photon]:
+        with mock.patch("geopy.geocoders.Photon.reverse", ReverseMock()) as m:
             g = reverse_geocode(points, provider=provider, timeout=2)
             assert len(points) == m.call_count