import pytest from account.utils.sanitize import sanitize_relationship_notes @pytest.mark.parametrize( 'html, expected', [ pytest.param( 'bolditalicunderlineHello
World', 'bolditalicunderlineHello
World', id='basic safe tags', ), pytest.param( '', '', id='list structure', ), pytest.param( "

Text

", '

Text

', id='safe and unsafe attributes', ), pytest.param( '

Bold

', '

Bold

', id='nested safe tags', ), pytest.param( "Hello", 'Hello', id='style attribute sanitization', ), pytest.param( "Google", 'Google', id='safe link', ), pytest.param( "Click", 'Click', id='dangerous protocol blocking', ), pytest.param( "Hello", 'Hello', id='script tag stripping', ), pytest.param('', '', id='empty string'), ], ) def test_sanitize_relationship_notes(html, expected): """ Minimal high-confidence test set covering: - Tag allowlist - Attribute allowlist - Protocol filtering - Nested HTML safety - XSS protection """ result = sanitize_relationship_notes(html) assert result == expected def test_none_input_raises_type_error(): """Ensure None input raises TypeError.""" with pytest.raises(TypeError): sanitize_relationship_notes(None)