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

Function test_polygon_from_encoded

tests/plugins/test_encoded.py:46–81  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

44
45
46def test_polygon_from_encoded():
47 """Test `PolygonFromEncoded` plugin.
48
49 The test ensures:
50 - The original JS script is present in the HTML file.
51 - The rendering from `PolygonFromEncoded` and the original plugin gives the
52 same output.
53 """
54
55 m = Map([40.0, -80.0], zoom_start=3)
56
57 encoded = r"w`j~FpxivO}jz@qnnCd}~Bsa{@~f`C`lkH"
58 polygon = PolygonFromEncoded(encoded=encoded, kwargs={})
59
60 polygon.add_to(m)
61
62 out = normalize(m._parent.render())
63
64 script = '<script src="https://cdn.jsdelivr.net/npm/polyline-encoded@0.0.9/Polyline.encoded.js"></script>'
65 assert script in out
66
67 tmpl = Template(
68 """
69 var {{this.get_name()}} = L.Polygon.fromEncoded(
70 {{ this.encoded|tojson }},
71 {{ this.options|tojavascript }}
72 )
73 .addTo({{this._parent.get_name()}});
74 """
75 )
76
77 expected_render = tmpl.render(this=polygon)
78
79 actual_render = polygon._template.module.script(polygon)
80
81 assert normalize(expected_render) == normalize(actual_render)

Callers

nothing calls this directly

Calls 6

MapClass · 0.90
PolygonFromEncodedClass · 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…