-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
test_beautify_icon.py
58 lines (44 loc) · 1.76 KB
/
test_beautify_icon.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
# -*- coding: utf-8 -*-
"""
Test BeautifyIcon
---------------
"""
from jinja2 import Template
import folium
from folium import plugins
from folium.utilities import normalize
def test_beautify_icon():
m = folium.Map([30., 0.], zoom_start=3)
# BeautifyIcons
ic1 = plugins.BeautifyIcon(
icon='plane', border_color='#b3334f', text_color='#b3334f')
ic2 = plugins.BeautifyIcon(border_color='#00ABDC',
text_color='#00ABDC',
number=10,
inner_icon_style='margin-top:0;')
# Markers, add icons as keyword argument
bm1 = folium.Marker(location=[46, -122],
popup='Portland, OR',
icon=ic1
).add_to(m)
bm2 = folium.Marker(
location=[50, -121],
icon=ic2
).add_to(m)
m.add_child(bm1)
m.add_child(bm2)
m._repr_html_()
out = normalize(m._parent.render())
# We verify that the script import is present.
script = '<script src="https://rawcdn.githack.com/marslan390/BeautifyMarker/master/leaflet-beautify-marker-icon.js"></script>' # noqa
assert script in out
# We verify that the css import is present.
css = '<link rel="stylesheet" href="https://rawcdn.githack.com/marslan390/BeautifyMarker/master/leaflet-beautify-marker-icon.css"/>' # noqa
assert css in out
# We verify that the Beautiful Icons are rendered correctly.
tmpl = Template(u"""
var {{this.get_name()}} = new L.BeautifyIcon.icon({{ this.options|tojson }})
{{this._parent.get_name()}}.setIcon({{this.get_name()}});
""") # noqa
assert normalize(tmpl.render(this=ic1)) in out
assert normalize(tmpl.render(this=ic2)) in out