Skip to content

Commit 22be426

Browse files
author
Martin Journois
committed
Add get_bounds in (almost) each test_folium
1 parent 4d27f47 commit 22be426

1 file changed

Lines changed: 81 additions & 12 deletions

File tree

tests/test_folium.py

Lines changed: 81 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ def test_cloudmade(self):
102102
cloudmade = 'http://{s}.tile.cloudmade.com/###/997/256/{z}/{x}/{y}.png'
103103
assert map._children['cloudmade'].tiles == cloudmade
104104

105+
bounds = map.get_bounds()
106+
assert bounds == [[None, None], [None, None]], bounds
107+
105108
def test_builtin_tile(self):
106109
"""Test custom maptiles."""
107110

@@ -117,6 +120,9 @@ def test_builtin_tile(self):
117120
assert map._children[tiles].tiles == url
118121
assert map._children[tiles].attr == attr
119122

123+
bounds = map.get_bounds()
124+
assert bounds == [[None, None], [None, None]], bounds
125+
120126
def test_custom_tile(self):
121127
"""Test custom tile URLs."""
122128

@@ -130,6 +136,9 @@ def test_custom_tile(self):
130136
assert map._children[url].tiles == url
131137
assert map._children[url].attr == attr
132138

139+
bounds = map.get_bounds()
140+
assert bounds == [[None, None], [None, None]], bounds
141+
133142
def test_wms_layer(self):
134143
"""Test WMS layer URLs."""
135144

@@ -154,6 +163,9 @@ def test_wms_layer(self):
154163
assert (''.join(wms.split())[:-1] in
155164
''.join(map.get_root().render().split()))
156165

166+
bounds = map.get_bounds()
167+
assert bounds == [[None, None], [None, None]], bounds
168+
157169
def test_feature_group(self):
158170
"""Test FeatureGroup."""
159171

@@ -166,6 +178,9 @@ def test_feature_group(self):
166178

167179
map._repr_html_()
168180

181+
bounds = map.get_bounds()
182+
assert bounds == [[45, -30], [45, 30]], bounds
183+
169184
def test_simple_marker(self):
170185
"""Test simple marker addition."""
171186

@@ -182,7 +197,9 @@ def test_simple_marker(self):
182197
'icon': "{icon:new L.Icon.Default()}"})
183198
assert (''.join(mark_1.split())[:-1] in
184199
''.join(self.map.get_root().render().split()))
185-
# assert self.map.template_vars['custom_markers'][0][2] == ""
200+
201+
bounds = self.map.get_bounds()
202+
assert bounds == [[45.5, -122.7], [45.5, -122.7]], bounds
186203

187204
# Test Simple marker addition.
188205
self.map.simple_marker(location=[45.60, -122.8], popup='Hi')
@@ -209,6 +226,10 @@ def test_simple_marker(self):
209226
for child in list(self.map._children.values())[-1]._children.values():
210227
assert not isinstance(child, Popup)
211228

229+
bounds = self.map.get_bounds()
230+
assert bounds == [[45.5, -122.8], [45.6, -122.7]], bounds
231+
232+
212233
def test_circle_marker(self):
213234
"""Test circle marker additions."""
214235

@@ -239,6 +260,9 @@ def test_circle_marker(self):
239260
assert (''.join(circle_2.split())[:-1] in
240261
''.join(self.map.get_root().render().split()))
241262

263+
bounds = self.map.get_bounds()
264+
assert bounds == [[45.6, -122.9], [45.7, -122.8]], bounds
265+
242266
def test_poly_marker(self):
243267
"""Test polygon marker."""
244268

@@ -262,6 +286,9 @@ def test_poly_marker(self):
262286
assert ((''.join(polygon.split()))[-1] in
263287
''.join(self.map.get_root().render().split()))
264288

289+
bounds = self.map.get_bounds()
290+
assert bounds == [[45.5, -122.5], [45.5, -122.5]], bounds
291+
265292
def test_latlng_pop(self):
266293
"""Test lat/lon popovers."""
267294

@@ -273,6 +300,9 @@ def test_latlng_pop(self):
273300
assert ((''.join(pop_templ.split()))[:-1] in
274301
''.join(self.map.get_root().render().split()))
275302

303+
bounds = self.map.get_bounds()
304+
assert bounds == [[None, None], [None, None]], bounds
305+
276306
def test_click_for_marker(self):
277307
"""Test click for marker functionality."""
278308

@@ -294,6 +324,9 @@ def test_click_for_marker(self):
294324
assert ((''.join(click.split()))[:-1] in
295325
''.join(self.map.get_root().render().split()))
296326

327+
bounds = self.map.get_bounds()
328+
assert bounds == [[None, None], [None, None]], bounds
329+
297330
def test_vega_popup(self):
298331
"""Test vega popups."""
299332

@@ -320,6 +353,9 @@ def test_vega_popup(self):
320353
assert ''.join(vega_parse.render().split()) in out
321354
assert (''.join(vega_str.split()))[:-1] in out
322355

356+
bounds = self.map.get_bounds()
357+
assert bounds == [[45.6, -122.8], [45.6, -122.8]], bounds
358+
323359
def test_geo_json_simple(self):
324360
"""Test geojson method."""
325361

@@ -332,6 +368,9 @@ def test_geo_json_simple(self):
332368
isinstance(x, GeoJson)][0]
333369
self.map._repr_html_()
334370

371+
bounds = self.map.get_bounds()
372+
assert bounds == [[18.948267, -171.742517], [71.285909, -66.979601]], bounds
373+
335374
def test_geo_json_str(self):
336375
# No data binding.
337376
self.map = folium.Map([43, -100], zoom_start=4)
@@ -364,6 +403,9 @@ def test_geo_json_str(self):
364403
obj = obj_temp.render(this=geo_json, json=json)
365404
assert ''.join(obj.split())[:-1] in out
366405

406+
bounds = self.map.get_bounds()
407+
assert bounds == [[18.948267, -171.742517], [71.285909, -66.979601]], bounds
408+
367409
def test_geo_json_bad_color(self):
368410
"""Test geojson method."""
369411

@@ -378,6 +420,9 @@ def test_geo_json_bad_color(self):
378420
columns=['FIPS_Code', 'Unemployed_2011'],
379421
key_on='feature.id', fill_color='blue')
380422

423+
bounds = self.map.get_bounds()
424+
assert bounds == [[None, None], [None, None]], bounds
425+
381426
def test_geo_json_bad_threshold_scale(self):
382427
"""Test geojson method."""
383428

@@ -394,6 +439,9 @@ def test_geo_json_bad_threshold_scale(self):
394439
threshold_scale=[1, 2, 3, 4, 5, 6, 7],
395440
fill_color='YlGnBu')
396441

442+
bounds = self.map.get_bounds()
443+
assert bounds == [[None, None], [None, None]], bounds
444+
397445
def test_geo_json_data_binding(self):
398446
"""Test geojson method."""
399447
data = setup_data()
@@ -430,6 +478,9 @@ def test_geo_json_data_binding(self):
430478
'range': d3range})
431479
assert ''.join(colorscale.split())[:-1] in ''.join(out.split())
432480

481+
bounds = self.map.get_bounds()
482+
assert bounds == [[18.948267, -171.742517], [71.285909, -66.979601]], bounds
483+
433484
def test_topo_json(self):
434485
"""Test geojson method."""
435486

@@ -553,6 +604,9 @@ def test_line(self):
553604

554605
assert ''.join(line_rendered.split()) in ''.join(out.split())
555606

607+
bounds = self.map.get_bounds()
608+
assert bounds == [[45.5236, -122.6751], [45.5238, -122.675]], bounds
609+
556610
def test_multi_polyline(self):
557611
"""Test multi_polyline."""
558612

@@ -581,6 +635,9 @@ def test_multi_polyline(self):
581635

582636
assert ''.join(multiline_rendered.split()) in ''.join(out.split())
583637

638+
bounds = self.map.get_bounds()
639+
assert bounds == [[45.5236, -122.6751], [45.5238, -122.675]], bounds
640+
584641
def test_fit_bounds(self):
585642
"""Test fit_bounds."""
586643
bounds = ((52.193636, -2.221575), (52.636878, -1.139759))
@@ -616,6 +673,9 @@ def test_fit_bounds(self):
616673

617674
assert ''.join(fit_bounds_rendered.split()) in ''.join(out.split())
618675

676+
bounds = self.map.get_bounds()
677+
assert bounds == [[None, None], [None, None]], bounds
678+
619679
def test_image_overlay(self):
620680
"""Test image overlay."""
621681
# from numpy.random import random
@@ -668,6 +728,9 @@ def test_image_overlay(self):
668728

669729
assert ''.join(image_rendered.split()) in ''.join(out.split())
670730

731+
bounds = self.map.get_bounds()
732+
assert bounds == [[None, None], [None, None]], bounds
733+
671734
def test_custom_icon(self):
672735
"""Test CustomIcon."""
673736
self.setup()
@@ -688,14 +751,20 @@ def test_custom_icon(self):
688751
self.map.add_children(mk)
689752
self.map._parent.render()
690753

691-
def test_tile_layer():
692-
mapa = folium.Map([48., 5.], tiles='stamentoner', zoom_start=6)
693-
layer = 'http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png'
694-
mapa.add_children(folium.map.TileLayer(layer, name='MapQuest',
695-
attr='attribution'))
696-
mapa.add_children(folium.map.TileLayer(layer,
697-
name='MapQuest2',
698-
attr='attribution2',
699-
overlay=True))
700-
mapa.add_children(folium.map.LayerControl())
701-
mapa._repr_html_()
754+
bounds = self.map.get_bounds()
755+
assert bounds == [[45, -100], [45, -100]], bounds
756+
757+
def test_tile_layer(self):
758+
mapa = folium.Map([48., 5.], tiles='stamentoner', zoom_start=6)
759+
layer = 'http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png'
760+
mapa.add_children(folium.map.TileLayer(layer, name='MapQuest',
761+
attr='attribution'))
762+
mapa.add_children(folium.map.TileLayer(layer,
763+
name='MapQuest2',
764+
attr='attribution2',
765+
overlay=True))
766+
mapa.add_children(folium.map.LayerControl())
767+
mapa._repr_html_()
768+
769+
bounds = self.map.get_bounds()
770+
assert bounds == [[None, None], [None, None]], bounds

0 commit comments

Comments
 (0)