Skip to content

Commit 20cadd4

Browse files
author
Martin Journois
committed
Enhance test_timestamped_geo_json.py
1 parent bfbdfa7 commit 20cadd4

File tree

1 file changed

+48
-5
lines changed

1 file changed

+48
-5
lines changed

tests/plugins/test_timestamped_geo_json.py

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"""
33
Test TimestampedGeoJson
44
-----------------------
5-
65
"""
6+
from jinja2 import Template
7+
import numpy as np
78

89
import folium
910
from folium import plugins
10-
import numpy as np
1111

1212
def test_timestamped_geo_json():
1313
coordinates = [[[[lon-8*np.sin(theta), -47+6*np.cos(theta)] for
@@ -81,7 +81,50 @@ def test_timestamped_geo_json():
8181
],
8282
}
8383

84-
mape = folium.Map([47, 3], zoom_start=1)
85-
mape.add_children(plugins.TimestampedGeoJson(data))
86-
mape._repr_html_()
84+
m = folium.Map([47, 3], zoom_start=1)
85+
tgj = plugins.TimestampedGeoJson(data)
86+
m.add_children(tgj)
87+
m._repr_html_()
88+
89+
out = m._parent.render()
90+
91+
# Verify the imports.
92+
assert ('<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/'
93+
'jquery.min.js"></script>'
94+
) in out
95+
assert ('<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/'
96+
'1.10.2/jquery-ui.min.js"></script>'
97+
) in out
98+
assert ('<script src="https://raw.githubusercontent.com/nezasa/'
99+
'iso8601-js-period/master/iso8601.min.js"></script>'
100+
) in out
101+
assert ('<script src="https://raw.githubusercontent.com/socib/Leaflet.'
102+
'TimeDimension/master/dist/leaflet.timedimension.min.js">'
103+
'</script>'
104+
) in out
105+
assert ('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/'
106+
'libs/highlight.js/8.4/styles/default.min.css" />'
107+
) in out
108+
assert ('<link rel="stylesheet" href="http://apps.socib.es/Leaflet.'
109+
'TimeDimension/dist/leaflet.timedimension.control.min.css" />'
110+
) in out
111+
112+
# Verify that the script is okay.
113+
tmpl = Template("""
114+
{{this._parent.get_name()}}.timeDimension = L.timeDimension();
115+
{{this._parent.get_name()}}.timeDimensionControl = L.control.timeDimension({
116+
position: 'bottomleft',
117+
autoPlay: {{'true' if this.auto_play else 'false'}},
118+
playerOptions: {
119+
transitionTime: {{this.transition_time}},
120+
loop: {{'true' if this.loop else 'false'}}}
121+
});
122+
{{this._parent.get_name()}}.addControl({{this._parent.get_name()}}.timeDimensionControl);
123+
124+
var {{this.get_name()}} = L.timeDimension.layer.geoJson(
125+
L.geoJson({{this.data}}),
126+
{updateTimeDimension: true,addlastPoint: true}
127+
).addTo({{this._parent.get_name()}});
128+
""")
87129

130+
assert ''.join(tmpl.render(this=tgj).split()) in ''.join(out.split())

0 commit comments

Comments
 (0)