Skip to content

Commit f2f7f8d

Browse files
committed
adding inline image_overlay test
1 parent 035602a commit f2f7f8d

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

tests/folium_tests.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,14 @@ def test_fit_bounds(self):
484484
def test_image_overlay(self):
485485
"""Test image overlay"""
486486
from numpy.random import random
487-
import imageio
487+
from folium.utilities import write_png
488+
import base64
488489

489490
data = random((100,100))
490-
imageio.imwrite('test.png', data)
491+
png_str = write_png(data)
492+
with open('data.png', 'wb') as f:
493+
f.write(png_str)
494+
inline_image_url = "data:image/png;base64,"+base64.b64encode(png_str)
491495

492496
image_tpl = self.env.get_template('image_layer.js')
493497
image_name = 'Image_Overlay'
@@ -502,8 +506,17 @@ def test_image_overlay(self):
502506
'image_opacity': image_opacity
503507
})
504508

505-
self.map.image_overlay(data)
509+
self.map.image_overlay(data, filename=image_url)
510+
assert image_rendered in self.map.template_vars['image_layers']
511+
506512

513+
image_rendered = image_tpl.render({'image_name': image_name,
514+
'image_url': inline_image_url,
515+
'image_bounds': image_bounds,
516+
'image_opacity': image_opacity
517+
})
518+
519+
self.map.image_overlay(data)
507520
assert image_rendered in self.map.template_vars['image_layers']
508-
521+
509522

0 commit comments

Comments
 (0)