"""Tests for B1 static consent-reachability analysis.""" from compliance.services.consent_reachability_check import ( classify_anchor_target, evaluate_reachability, find_consent_anchors_in_footer, ) def _wrap(footer_inner: str) -> str: return ( "" "
some content
" f"" "" ) class TestFindConsentAnchors: def test_finds_reopen_link_german(self): html = _wrap('' 'Cookie-Einstellungen') anchors = find_consent_anchors_in_footer(html) assert len(anchors) == 1 assert anchors[0]["intent"] == "reopen_cmp" def test_finds_reopen_button(self): html = _wrap('') anchors = find_consent_anchors_in_footer(html) assert anchors[0]["intent"] == "reopen_cmp" def test_info_only_link_to_policy(self): html = _wrap('Cookie-Richtlinie') anchors = find_consent_anchors_in_footer(html) assert len(anchors) == 1 assert anchors[0]["intent"] == "info_only" def test_browser_deflection_link(self): html = _wrap('Browser-Einstellungen') anchors = find_consent_anchors_in_footer(html) assert anchors[0]["intent"] == "browser_deflect" def test_ignores_anchors_outside_footer(self): html = ('' 'Cookie-Einstellungen' '' '') assert find_consent_anchors_in_footer(html) == [] def test_role_contentinfo_treated_as_footer(self): html = ('' '
' 'Cookie-Einstellungen' '
') anchors = find_consent_anchors_in_footer(html) assert len(anchors) == 1 def test_class_with_footer_treated_as_footer(self): html = ('' '') anchors = find_consent_anchors_in_footer(html) assert len(anchors) == 1 def test_empty_html(self): assert find_consent_anchors_in_footer("") == [] def test_malformed_html(self): # broken markup shouldn't crash anchors = find_consent_anchors_in_footer("