MCPcopy Create free account
hub / github.com/python-visualization/folium / test_polylineoffset

Function test_polylineoffset

tests/plugins/test_polyline_offset.py:14–73  ·  view source on GitHub ↗
(offset)

Source from the content-addressed store, hash-verified

12
13@pytest.mark.parametrize("offset", [0, 10, -10])
14def test_polylineoffset(offset):
15 m = folium.Map([20.0, 0.0], zoom_start=3)
16
17 locations = [
18 [59.355600, -31.99219],
19 [55.178870, -42.89062],
20 [47.754100, -43.94531],
21 [38.272690, -37.96875],
22 [27.059130, -41.13281],
23 [16.299050, -36.56250],
24 [8.4071700, -30.23437],
25 [1.0546300, -22.50000],
26 [-8.754790, -18.28125],
27 [-21.61658, -20.03906],
28 [-31.35364, -24.25781],
29 [-39.90974, -30.93750],
30 [-43.83453, -41.13281],
31 [-47.75410, -49.92187],
32 [-50.95843, -54.14062],
33 [-55.97380, -56.60156],
34 ]
35
36 polylineoffset = plugins.PolyLineOffset(locations=locations, offset=offset)
37 polylineoffset.add_to(m)
38
39 m._repr_html_()
40 out = m._parent.render()
41
42 # We verify that the script import is present.
43 script = '<script src="https://cdn.jsdelivr.net/npm/leaflet-polylineoffset@1.1.1/leaflet.polylineoffset.min.js"></script>' # noqa
44 assert script in out
45
46 # We verify that the script part is correct.
47 expected_rendered = f"""
48 var {polylineoffset.get_name()} = L.polyline(
49 {locations},
50 {{
51 "bubblingMouseEvents": true,
52 "color": "#3388ff",
53 "dashArray": null,
54 "dashOffset": null,
55 "fill": false,
56 "fillColor": "#3388ff",
57 "fillOpacity": 0.2,
58 "fillRule": "evenodd",
59 "lineCap": "round",
60 "lineJoin": "round",
61 "noClip": false,
62 "offset": {offset},
63 "opacity": 1.0,
64 "smoothFactor": 1.0,
65 "stroke": true,
66 "weight": 3
67 }}
68 )
69 .addTo({m.get_name()});
70 """
71

Callers

nothing calls this directly

Calls 4

_repr_html_Method · 0.95
normalizeFunction · 0.90
add_toMethod · 0.80
renderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…