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

Function test_include

tests/test_map.py:151–196  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

149
150
151def test_include():
152 create_tile = """
153 function(coords, done) {
154 const url = this.getTileUrl(coords);
155 const img = document.createElement('img');
156 fetch(url, {
157 headers: {
158 "Authorization": "Bearer <Token>"
159 },
160 })
161 .then((response) => {
162 img.src = URL.createObjectURL(response.body);
163 done(null, img);
164 })
165 return img;
166 }
167 """
168 TileLayer.include(create_tile=JsCode(create_tile))
169 tiles = TileLayer(
170 tiles="OpenStreetMap",
171 )
172 m = Map(
173 tiles=tiles,
174 )
175 rendered = m.get_root().render()
176 Class._includes.clear()
177 expected = """
178 L.TileLayer.include({
179 "createTile":
180 function(coords, done) {
181 const url = this.getTileUrl(coords);
182 const img = document.createElement('img');
183 fetch(url, {
184 headers: {
185 "Authorization": "Bearer <Token>"
186 },
187 })
188 .then((response) => {
189 img.src = URL.createObjectURL(response.body);
190 done(null, img);
191 })
192 return img;
193 },
194 })
195 """
196 assert normalize(expected) in normalize(rendered)
197
198
199def test_include_once():

Callers

nothing calls this directly

Calls 6

JsCodeClass · 0.90
TileLayerClass · 0.90
MapClass · 0.90
normalizeFunction · 0.90
includeMethod · 0.80
renderMethod · 0.45

Tested by

no test coverage detected