| 10 | |
| 11 | |
| 12 | def test_antpath(): |
| 13 | m = folium.Map([20.0, 0.0], zoom_start=3) |
| 14 | |
| 15 | locations = [ |
| 16 | [59.355600, -31.99219], |
| 17 | [55.178870, -42.89062], |
| 18 | [47.754100, -43.94531], |
| 19 | [38.272690, -37.96875], |
| 20 | [27.059130, -41.13281], |
| 21 | [16.299050, -36.56250], |
| 22 | [8.4071700, -30.23437], |
| 23 | [1.0546300, -22.50000], |
| 24 | [-8.754790, -18.28125], |
| 25 | [-21.61658, -20.03906], |
| 26 | [-31.35364, -24.25781], |
| 27 | [-39.90974, -30.93750], |
| 28 | [-43.83453, -41.13281], |
| 29 | [-47.75410, -49.92187], |
| 30 | [-50.95843, -54.14062], |
| 31 | [-55.97380, -56.60156], |
| 32 | ] |
| 33 | |
| 34 | antpath = plugins.AntPath(locations=locations) |
| 35 | antpath.add_to(m) |
| 36 | |
| 37 | out = m._parent.render() |
| 38 | |
| 39 | # We verify that the script import is present. |
| 40 | script = '<script src="https://cdn.jsdelivr.net/npm/leaflet-ant-path@1.1.2/dist/leaflet-ant-path.min.js"></script>' # noqa |
| 41 | assert script in out |
| 42 | |
| 43 | # We verify that the script part is correct. |
| 44 | tmpl = Template( |
| 45 | """ |
| 46 | {{this.get_name()}} = L.polyline.antPath( |
| 47 | {{ this.locations|tojson }}, |
| 48 | {{ this.options|tojavascript }} |
| 49 | ) |
| 50 | .addTo({{this._parent.get_name()}}); |
| 51 | """ |
| 52 | ) # noqa |
| 53 | |
| 54 | expected_rendered = tmpl.render(this=antpath) |
| 55 | rendered = antpath._template.module.script(antpath) |
| 56 | assert normalize(expected_rendered) == normalize(rendered) |