Path: blob/main/tests/plugins/test_polyline_text_path.py
1601 views
"""1Test PolyLineTextPath2---------------3"""45import folium6from folium import plugins7from folium.template import Template8from folium.utilities import normalize91011def test_polyline_text_path():12m = folium.Map([20.0, 0.0], zoom_start=3)1314wind_locations = [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]3233wind_line = folium.PolyLine(wind_locations, weight=15, color="#8EE9FF")34attr = {"fill": "#007DEF", "font-weight": "bold", "font-size": "24"}35wind_textpath = plugins.PolyLineTextPath(36wind_line, ") ", repeat=True, offset=7, attributes=attr37)3839m.add_child(wind_line)40m.add_child(wind_textpath)4142out = normalize(m._parent.render())4344# We verify that the script import is present.45script = '<script src="https://cdn.jsdelivr.net/npm/[email protected]/leaflet.textpath.min.js"></script>' # noqa46assert script in out4748# We verify that the script part is correct.49tmpl = Template(50"""51{{ this.polyline.get_name() }}.setText(52"{{this.text}}",53{{ this.options|tojavascript }}54);55"""56)5758expected = normalize(tmpl.render(this=wind_textpath))59assert expected in out606162