Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
python-visualization
GitHub Repository: python-visualization/folium
Path: blob/main/tests/plugins/test_float_image.py
1601 views
1
"""
2
Test FloatImage
3
---------------
4
"""
5
6
import folium
7
from folium import plugins
8
from folium.template import Template
9
from folium.utilities import normalize
10
11
12
def test_float_image():
13
m = folium.Map([45.0, 3.0], zoom_start=4)
14
url = "https://raw.githubusercontent.com/SECOORA/static_assets/master/maps/img/rose.png"
15
szt = plugins.FloatImage(url, bottom=60, left=70, width="20%")
16
m.add_child(szt)
17
m._repr_html_()
18
19
out = normalize(m._parent.render())
20
21
# Verify that the div has been created.
22
tmpl = Template(
23
"""
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
)
30
assert normalize(tmpl.render(this=szt)) in out
31
32
# Verify that the style has been created.
33
tmpl = Template(
34
"""
35
<style>
36
#{{this.get_name()}} {
37
position: absolute;
38
bottom: 60%;
39
left: 70%;
40
width: 20%;
41
}
42
</style>
43
"""
44
)
45
assert normalize(tmpl.render(this=szt)) in out
46
47
bounds = m.get_bounds()
48
assert bounds == [[None, None], [None, None]], bounds
49
50