()
| 11 | |
| 12 | |
| 13 | def test_boat_marker(): |
| 14 | m = folium.Map([30.0, 0.0], zoom_start=3) |
| 15 | bm1 = plugins.BoatMarker( |
| 16 | (34, -43), heading=45, wind_heading=150, wind_speed=45, color="#8f8" |
| 17 | ) |
| 18 | bm2 = plugins.BoatMarker( |
| 19 | (46, -30), heading=-20, wind_heading=46, wind_speed=25, color="#88f" |
| 20 | ) |
| 21 | |
| 22 | m.add_child(bm1) |
| 23 | m.add_child(bm2) |
| 24 | m._repr_html_() |
| 25 | |
| 26 | out = normalize(m._parent.render()) |
| 27 | |
| 28 | # We verify that the script import is present. |
| 29 | script = '<script src="https://unpkg.com/leaflet.boatmarker/leaflet.boatmarker.min.js"></script>' # noqa |
| 30 | assert script in out |
| 31 | |
| 32 | # We verify that the script part is correct. |
| 33 | tmpl = Template( |
| 34 | """ |
| 35 | var {{ this.get_name() }} = L.boatMarker( |
| 36 | {{ this.location|tojson }}, |
| 37 | {{ this.options|tojavascript }} |
| 38 | ).addTo({{ this._parent.get_name() }}); |
| 39 | {{ this.get_name() }}.setHeadingWind( |
| 40 | {{ this.heading }}, |
| 41 | {{ this.wind_speed }}, |
| 42 | {{ this.wind_heading }} |
| 43 | ); |
| 44 | """ |
| 45 | ) |
| 46 | |
| 47 | assert normalize(tmpl.render(this=bm1)) in out |
| 48 | assert normalize(tmpl.render(this=bm2)) in out |
| 49 | |
| 50 | bounds = m.get_bounds() |
| 51 | assert bounds == [[34, -43], [46, -30]], bounds |
| 52 | |
| 53 | |
| 54 | def test_boat_marker_with_no_wind_speed_or_heading(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…