Verify that loading data in GeoJson works well for different use cases. Prevent two regressions: - https://github.com/python-visualization/folium/pull/1190 - https://github.com/python-visualization/folium/pull/1289
(driver)
| 6 | |
| 7 | |
| 8 | def test_geojson(driver): |
| 9 | """Verify that loading data in GeoJson works well for different use cases. |
| 10 | |
| 11 | Prevent two regressions: |
| 12 | - https://github.com/python-visualization/folium/pull/1190 |
| 13 | - https://github.com/python-visualization/folium/pull/1289 |
| 14 | |
| 15 | """ |
| 16 | data_url = "https://cdn.jsdelivr.net/gh/python-visualization/folium@main/examples/data/search_bars_rome.json" |
| 17 | |
| 18 | m = folium.Map((41.9, 12.5), zoom_start=10, tiles="cartodbpositron") |
| 19 | marker_cluster = folium.plugins.MarkerCluster(name="cluster").add_to(m) |
| 20 | folium.GeoJson(data_url, embed=False).add_to(marker_cluster) |
| 21 | folium.GeoJson(data_url, embed=False, show=False, name="geojson").add_to(m) |
| 22 | folium.LayerControl(collapsed=False).add_to(m) |
| 23 | |
| 24 | html = m.get_root().render() |
| 25 | with temp_html_filepath(html) as filepath: |
| 26 | driver.get_file(filepath) |
| 27 | assert driver.wait_until(".folium-map") |
| 28 | driver.verify_js_logs() |
| 29 | # Verify the marker cluster is shown, it's a yellow icon with '18' in it. |
| 30 | icon = driver.wait_until(".leaflet-marker-icon.marker-cluster > div > span") |
| 31 | assert icon.text == "18" |
| 32 | # Verify the second GeoJson layer is not shown, because we used show=False. |
| 33 | control_label = driver.wait_until( |
| 34 | ".leaflet-control-layers-overlays > label:nth-of-type(2)" |
| 35 | ) |
| 36 | assert control_label.text == "geojson" |
| 37 | control_input = control_label.find_element(By.CSS_SELECTOR, value="input") |
| 38 | assert control_input.get_attribute("checked") is None |
nothing calls this directly
no test coverage detected