MCPcopy
hub / github.com/python-visualization/folium / test_semicircle

Function test_semicircle

tests/plugins/test_semicircle.py:13–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11
12
13def test_semicircle():
14 m = folium.Map([30.0, 0.0], zoom_start=3)
15 sc1 = plugins.SemiCircle(
16 (34, -43),
17 radius=400000,
18 arc=300,
19 direction=20,
20 color="red",
21 fill_color="red",
22 opacity=0,
23 popup="Direction - 20 degrees, arc 300 degrees",
24 )
25 sc2 = plugins.SemiCircle(
26 (46, -30),
27 radius=400000,
28 start_angle=10,
29 stop_angle=50,
30 color="red",
31 fill_color="red",
32 opacity=0,
33 popup="Start angle - 10 degrees, Stop angle - 50 degrees",
34 )
35
36 m.add_child(sc1)
37 m.add_child(sc2)
38 m._repr_html_()
39
40 out = normalize(m._parent.render())
41
42 # We verify that the script import is present.
43 script = '<script src="https://cdn.jsdelivr.net/npm/leaflet-semicircle@2.0.4/Semicircle.min.js"></script>' # noqa
44 assert script in out
45
46 # We verify that the script part is correct.
47 tmpl_sc1 = Template(
48 """
49 var {{ this.get_name() }} = L.semiCircle(
50 {{ this.location|tojson }},
51 {{ this.options|tojavascript }}
52 )
53 .setDirection{{ this.direction }}
54 .addTo({{ this._parent.get_name() }});
55 """
56 )
57
58 tmpl_sc2 = Template(
59 """
60 var {{ this.get_name() }} = L.semiCircle(
61 {{ this.location|tojson }},
62 {{ this.options|tojavascript }}
63 )
64 .addTo({{ this._parent.get_name() }});
65 """
66 )
67 assert normalize(tmpl_sc1.render(this=sc1)) in out
68 assert normalize(tmpl_sc2.render(this=sc2)) in out
69
70 bounds = m.get_bounds()

Callers

nothing calls this directly

Calls 6

_repr_html_Method · 0.95
normalizeFunction · 0.90
TemplateClass · 0.90
get_boundsMethod · 0.80
add_childMethod · 0.45
renderMethod · 0.45

Tested by

no test coverage detected