Test image overlay.
()
| 75 | |
| 76 | |
| 77 | def 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( |
nothing calls this directly
no test coverage detected