Path: blob/main/tests/plugins/test_antpath.py
1601 views
"""1Test AntPath2-------------3"""45import folium6from folium import plugins7from folium.template import Template8from folium.utilities import normalize91011def test_antpath():12m = folium.Map([20.0, 0.0], zoom_start=3)1314locations = [15[59.355600, -31.99219],16[55.178870, -42.89062],17[47.754100, -43.94531],18[38.272690, -37.96875],19[27.059130, -41.13281],20[16.299050, -36.56250],21[8.4071700, -30.23437],22[1.0546300, -22.50000],23[-8.754790, -18.28125],24[-21.61658, -20.03906],25[-31.35364, -24.25781],26[-39.90974, -30.93750],27[-43.83453, -41.13281],28[-47.75410, -49.92187],29[-50.95843, -54.14062],30[-55.97380, -56.60156],31]3233antpath = plugins.AntPath(locations=locations)34antpath.add_to(m)3536out = m._parent.render()3738# We verify that the script import is present.39script = '<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet-ant-path.min.js"></script>' # noqa40assert script in out4142# We verify that the script part is correct.43tmpl = Template(44"""45{{this.get_name()}} = L.polyline.antPath(46{{ this.locations|tojson }},47{{ this.options|tojavascript }}48)49.addTo({{this._parent.get_name()}});50"""51) # noqa5253expected_rendered = tmpl.render(this=antpath)54rendered = antpath._template.module.script(antpath)55assert normalize(expected_rendered) == normalize(rendered)565758