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