Path: blob/main/tests/plugins/test_boat_marker.py
2529 views
"""1Test BoatMarker2---------------34"""56import folium7from folium import plugins8from folium.template import Template9from folium.utilities import normalize101112def test_boat_marker():13m = folium.Map([30.0, 0.0], zoom_start=3)14bm1 = plugins.BoatMarker(15(34, -43), heading=45, wind_heading=150, wind_speed=45, color="#8f8"16)17bm2 = plugins.BoatMarker(18(46, -30), heading=-20, wind_heading=46, wind_speed=25, color="#88f"19)2021m.add_child(bm1)22m.add_child(bm2)23m._repr_html_()2425out = normalize(m._parent.render())2627# We verify that the script import is present.28script = '<script src="https://unpkg.com/leaflet.boatmarker/leaflet.boatmarker.min.js"></script>' # noqa29assert script in out3031# We verify that the script part is correct.32tmpl = Template("""33var {{ this.get_name() }} = L.boatMarker(34{{ this.location|tojson }},35{{ this.options|tojavascript }}36).addTo({{ this._parent.get_name() }});37{{ this.get_name() }}.setHeadingWind(38{{ this.heading }},39{{ this.wind_speed }},40{{ this.wind_heading }}41);42""")4344assert normalize(tmpl.render(this=bm1)) in out45assert normalize(tmpl.render(this=bm2)) in out4647bounds = m.get_bounds()48assert bounds == [[34, -43], [46, -30]], bounds495051def test_boat_marker_with_no_wind_speed_or_heading():52m = folium.Map([30.0, 0.0], zoom_start=3)53bm1 = plugins.BoatMarker((34, -43), heading=45, color="#8f8")54m.add_child(bm1)5556out = normalize(m._parent.render())5758# We verify that the script part is correct.59tmpl = Template("""60var {{ this.get_name() }} = L.boatMarker(61{{ this.location|tojson }},62{{ this.options|tojavascript }}63).addTo({{ this._parent.get_name() }});64{{ this.get_name() }}.setHeading({{ this.heading }});65""")6667assert normalize(tmpl.render(this=bm1)) in out686970