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

Function test_pattern

tests/plugins/test_pattern.py:14–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12
13
14def test_pattern():
15 m = folium.Map([40.0, -105.0], zoom_start=6)
16
17 stripes = plugins.pattern.StripePattern(angle=-45)
18 stripes.add_to(m)
19 circles = plugins.pattern.CirclePattern(
20 width=20, height=20, radius=5, fill_opacity=0.5, opacity=1
21 )
22
23 def style_function(feature):
24 default_style = {
25 "opacity": 1.0,
26 "fillColor": "#ffff00",
27 "color": "black",
28 "weight": 2,
29 }
30
31 if feature["properties"]["name"] == "Colorado":
32 default_style["fillPattern"] = stripes
33 default_style["fillOpacity"] = 1.0
34
35 if feature["properties"]["name"] == "Utah":
36 default_style["fillPattern"] = circles
37 default_style["fillOpacity"] = 1.0
38
39 return default_style
40
41 data = os.path.join(os.path.dirname(__file__), os.pardir, "us-states.json")
42 folium.GeoJson(data, style_function=style_function).add_to(m)
43
44 out = normalize(m._parent.render())
45
46 # We verify that the script import is present.
47 script = '<script src="https://teastman.github.io/Leaflet.pattern/leaflet.pattern.js"></script>' # noqa
48 assert script in out

Callers

nothing calls this directly

Calls 3

normalizeFunction · 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…