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

Function test_image_overlay

tests/test_raster_layers.py:77–115  ·  view source on GitHub ↗

Test image overlay.

()

Source from the content-addressed store, hash-verified

75
76
77def test_image_overlay():
78 """Test image overlay."""
79 data = [
80 [[1, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0]],
81 [[1, 1, 0, 0.5], [0, 0, 1, 1], [0, 0, 1, 1]],
82 ]
83
84 m = folium.Map()
85 io = folium.raster_layers.ImageOverlay(
86 data, [[0, -180], [90, 180]], mercator_project=True
87 )
88 io.add_to(m)
89 m._repr_html_()
90
91 out = m._parent.render()
92
93 # Verify the URL generation.
94 url = (
95 "data:image/png;base64,"
96 "iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAA"
97 "AF0lEQVR42mP4z8AARFDw/z/DeiA5H4QBV60H6ABl9ZIAAAAASUVORK5CYII="
98 )
99 assert io.url == url
100
101 # Verify the script part is okay.
102 tmpl = Template(
103 """
104 var {{this.get_name()}} = L.imageOverlay(
105 "{{ this.url }}",
106 {{ this.bounds }},
107 {{ this.options }}
108 );
109 {{ this.get_name() }}.addTo({{this._parent.get_name()}});
110 """
111 )
112 assert normalize(tmpl.render(this=io)) in normalize(out)
113
114 bounds = m.get_bounds()
115 assert bounds == [[0, -180], [90, 180]], bounds
116
117
118@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected