Path: blob/main/tests/plugins/test_boat_marker.py
1601 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(33"""34var {{ this.get_name() }} = L.boatMarker(35{{ this.location|tojson }},36{{ this.options|tojavascript }}37).addTo({{ this._parent.get_name() }});38{{ this.get_name() }}.setHeadingWind(39{{ this.heading }},40{{ this.wind_speed }},41{{ this.wind_heading }}42);43"""44)4546assert normalize(tmpl.render(this=bm1)) in out47assert normalize(tmpl.render(this=bm2)) in out4849bounds = m.get_bounds()50assert bounds == [[34, -43], [46, -30]], bounds515253def test_boat_marker_with_no_wind_speed_or_heading():54m = folium.Map([30.0, 0.0], zoom_start=3)55bm1 = plugins.BoatMarker((34, -43), heading=45, color="#8f8")56m.add_child(bm1)5758out = normalize(m._parent.render())5960# We verify that the script part is correct.61tmpl = Template(62"""63var {{ this.get_name() }} = L.boatMarker(64{{ this.location|tojson }},65{{ this.options|tojavascript }}66).addTo({{ this._parent.get_name() }});67{{ this.get_name() }}.setHeading({{ this.heading }});68"""69)7071assert normalize(tmpl.render(this=bm1)) in out727374