MCPcopy Create free account
hub / github.com/python-visualization/folium / test_polyline_from_encoded

Function test_polyline_from_encoded

tests/plugins/test_encoded.py:9–43  ·  view source on GitHub ↗

Test `PolyLineFromEncoded` plugin. The test ensures: - The original JS script is present in the HTML file. - The rendering from `PolyLineFromEncoded` and the original plugin gives the same output.

()

Source from the content-addressed store, hash-verified

7
8
9def test_polyline_from_encoded():
10 """Test `PolyLineFromEncoded` plugin.
11
12 The test ensures:
13 - The original JS script is present in the HTML file.
14 - The rendering from `PolyLineFromEncoded` and the original plugin gives the
15 same output.
16 """
17
18 m = Map([35.0, -120.0], zoom_start=3)
19
20 encoded = r"_p~iF~cn~U_ulLn{vA_mqNvxq`@"
21 kwargs = {"color": "green"}
22 polyline = PolyLineFromEncoded(encoded=encoded, **kwargs)
23
24 polyline.add_to(m)
25
26 out = normalize(m._parent.render())
27
28 script = '<script src="https://cdn.jsdelivr.net/npm/polyline-encoded@0.0.9/Polyline.encoded.js"></script>'
29 assert script in out
30
31 tmpl = Template(
32 """
33 var {{this.get_name()}} = L.Polyline.fromEncoded(
34 {{ this.encoded|tojson }},
35 {{ this.options|tojavascript }}
36 ).addTo({{this._parent.get_name()}});
37 """
38 )
39
40 expected_render = tmpl.render(this=polyline)
41 actual_render = polyline._template.module.script(polyline)
42
43 assert normalize(expected_render) == normalize(actual_render)
44
45
46def test_polygon_from_encoded():

Callers

nothing calls this directly

Calls 6

MapClass · 0.90
PolyLineFromEncodedClass · 0.90
normalizeFunction · 0.90
TemplateClass · 0.90
add_toMethod · 0.80
renderMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…