Skip to content

Commit

Permalink
TST: test compatibility with latest folium (#3488)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfleis authored Dec 13, 2024
1 parent 4ddfd24 commit fee8128
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions geopandas/tests/test_explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

BRANCA_05 = Version(branca.__version__) > Version("0.4.2")
FOLIUM_G_014 = Version(folium.__version__) > Version("0.14.0")
FOLIUM_GE_019 = Version(folium.__version__) >= Version("0.19.0")


@pytest.fixture(scope="class")
Expand Down Expand Up @@ -70,7 +71,10 @@ def test_map_settings_default(self):
pytest.approx(2.842170943040401e-14, rel=1e-6),
]
assert m.options["zoom"] == 10
assert m.options["zoomControl"] is True
if not FOLIUM_GE_019:
assert m.options["zoomControl"] is True
else:
assert m.options["zoom_control"] is True
assert m.position == "relative"
assert m.height == (100.0, "%")
assert m.width == (100.0, "%")
Expand All @@ -93,7 +97,10 @@ def test_map_settings_custom(self):
pytest.approx(-73.9778006856748, rel=1e-6),
]
assert m.options["zoom"] == 10
assert m.options["zoomControl"] is False
if not FOLIUM_GE_019:
assert m.options["zoomControl"] is False
else:
assert m.options["zoom_control"] is False
assert m.height == (200.0, "px")
assert m.width == (200.0, "px")

Expand Down Expand Up @@ -751,7 +758,7 @@ def test_xyzservices_providers(self):
'attribution":"\\u0026copy;\\u003cahref=\\"https://www.openstreetmap.org'
in out_str
)
assert '"maxZoom":20,"minZoom":0' in out_str
assert '"maxZoom":20' in out_str

@pytest.mark.skipif(not HAS_PYPROJ, reason="requires pyproj")
def test_xyzservices_query_name(self):
Expand All @@ -768,7 +775,7 @@ def test_xyzservices_query_name(self):
'attribution":"\\u0026copy;\\u003cahref=\\"https://www.openstreetmap.org'
in out_str
)
assert '"maxZoom":20,"minZoom":0' in out_str
assert '"maxZoom":20' in out_str

@pytest.mark.skipif(not HAS_PYPROJ, reason="requires pyproj")
def test_xyzservices_providers_min_zoom_override(self):
Expand All @@ -779,7 +786,7 @@ def test_xyzservices_providers_min_zoom_override(self):
)
out_str = self._fetch_map_string(m)

assert '"maxZoom":20,"minZoom":3' in out_str
assert '"minZoom":3' in out_str

@pytest.mark.skipif(not HAS_PYPROJ, reason="requires pyproj")
def test_xyzservices_providers_max_zoom_override(self):
Expand All @@ -790,7 +797,7 @@ def test_xyzservices_providers_max_zoom_override(self):
)
out_str = self._fetch_map_string(m)

assert '"maxZoom":12,"minZoom":0' in out_str
assert '"maxZoom":12' in out_str

@pytest.mark.skipif(not HAS_PYPROJ, reason="requires pyproj")
def test_xyzservices_providers_both_zooms_override(self):
Expand All @@ -803,7 +810,8 @@ def test_xyzservices_providers_both_zooms_override(self):
)
out_str = self._fetch_map_string(m)

assert '"maxZoom":12,"minZoom":3' in out_str
assert '"maxZoom":12' in out_str
assert '"minZoom":3' in out_str

def test_linearrings(self):
rings = self.nybb.explode(index_parts=True).exterior
Expand Down Expand Up @@ -979,9 +987,15 @@ def test_multiple_geoseries(self):
def test_map_kwds(self):
def check():
out_str = self._fetch_map_string(m)
assert "zoomControl:false" in out_str
assert "dragging:false" in out_str
assert "scrollWheelZoom:false" in out_str
if not FOLIUM_GE_019:
assert m.options["zoomControl"] is False
else:
assert m.options["zoom_control"] is False
assert "dragging:false" in out_str or '"dragging":false' in out_str
assert (
"scrollWheelZoom:false" in out_str
or '"scrollWheelZoom":false' in out_str
)

# check that folium and leaflet Map() parameters can be passed
m = self.world.explore(
Expand Down

0 comments on commit fee8128

Please sign in to comment.