Skip to content

Commit d6f26d1

Browse files
committed
Add a float image plugin test
1 parent 9c6e5c7 commit d6f26d1

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

tests/plugins/test_float_image.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Test FloatImage
4+
---------------
5+
"""
6+
7+
from jinja2 import Template
8+
9+
import folium
10+
from folium import plugins
11+
12+
13+
def test_float_image():
14+
m = folium.Map([45., 3.], zoom_start=4)
15+
url = 'https://raw.githubusercontent.com/SECOORA/static_assets/master/maps/img/rose.png'
16+
szt = plugins.FloatImage(url, bottom=60, left=70)
17+
m.add_child(szt)
18+
m._repr_html_()
19+
20+
out = m._parent.render()
21+
22+
# Verify that the div has been created.
23+
tmpl = Template("""
24+
<img id="{{this.get_name()}}" alt="float_image"
25+
src="https://raw.githubusercontent.com/SECOORA/static_assets/master/maps/img/rose.png"
26+
style="z-index: 999999">
27+
</img>
28+
""")
29+
assert ''.join(tmpl.render(this=szt).split()) in ''.join(out.split())
30+
31+
# Verify that the style has been created.
32+
tmpl = Template("""
33+
<style>
34+
#{{this.get_name()}} {
35+
position:absolute;
36+
bottom:60%;
37+
left:70%;
38+
}
39+
</style>
40+
""")
41+
assert ''.join(tmpl.render(this=szt).split()) in ''.join(out.split())
42+
43+
bounds = m.get_bounds()
44+
assert bounds == [[None, None], [None, None]], bounds

0 commit comments

Comments
 (0)