MCPcopy Index your code
hub / github.com/plotly/plotly.py / test_cdn_includes_integrity_attribute

Function test_cdn_includes_integrity_attribute

tests/test_io/test_html.py:38–53  ·  view source on GitHub ↗

Test that the CDN script tag includes an integrity attribute with SHA256 hash

(fig1)

Source from the content-addressed store, hash-verified

36
37
38def test_cdn_includes_integrity_attribute(fig1):
39 """Test that the CDN script tag includes an integrity attribute with SHA256 hash"""
40 html_output = pio.to_html(fig1, include_plotlyjs="cdn")
41
42 # Check that the script tag includes integrity attribute
43 assert 'integrity="sha256-' in html_output
44 assert 'crossorigin="anonymous"' in html_output
45
46 # Verify it's in the correct script tag
47 cdn_pattern = re.compile(
48 r'<script[^>]*src="'
49 + re.escape(plotly_cdn_url())
50 + r'"[^>]*integrity="sha256-[A-Za-z0-9+/=]+"[^>]*>'
51 )
52 match = cdn_pattern.search(html_output)
53 assert match is not None, "CDN script tag with integrity attribute not found"
54
55
56def test_outer_wrapper_carries_requested_dimensions(fig1):

Callers

nothing calls this directly

Calls 2

plotly_cdn_urlFunction · 0.90
to_htmlMethod · 0.80

Tested by

no test coverage detected