"""Unit tests for card fragment parser.""" from __future__ import annotations import pytest from blog.bp.blog.services.posts_data import _parse_card_fragments class TestParseCardFragments: def test_empty_string(self): assert _parse_card_fragments("") == {} def test_single_block(self): html = '
card
' result = _parse_card_fragments(html) assert result == {"42": "
card
"} def test_multiple_blocks(self): html = ( 'A' 'B' ) result = _parse_card_fragments(html) assert result == {"1": "A", "2": "B"} def test_empty_inner_skipped(self): html = ' ' result = _parse_card_fragments(html) assert result == {} def test_multiline_content(self): html = '\n

line1

\n

line2

\n' result = _parse_card_fragments(html) assert "5" in result assert "

line1

" in result["5"] def test_mismatched_ids_not_captured(self): html = 'content' result = _parse_card_fragments(html) assert result == {} def test_no_markers(self): html = '
no markers here
' assert _parse_card_fragments(html) == {}