feat(runtime): implement single-article consolidation runtime and modularize codebase
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
"""Unit tests for Markdown renderer covering scenarios OUT-002 to OUT-010."""
|
||||
|
||||
import yaml
|
||||
|
||||
from src.runtime.candidate.models import CandidateObject
|
||||
from src.runtime.storage.markdown_renderer import render_canonical_markdown
|
||||
|
||||
|
||||
def test_render_canonical_markdown_with_front_matter():
|
||||
blocks = [
|
||||
CandidateObject(
|
||||
id="blk_01",
|
||||
type="heading",
|
||||
text="Primeiro Bloco",
|
||||
extractor="trafilatura",
|
||||
position=1,
|
||||
level=2,
|
||||
),
|
||||
CandidateObject(
|
||||
id="blk_02",
|
||||
type="paragraph",
|
||||
text="Este é o parágrafo editorial.",
|
||||
extractor="trafilatura",
|
||||
position=2,
|
||||
),
|
||||
CandidateObject(
|
||||
id="blk_03", type="list_item", text="Item de lista", extractor="trafilatura", position=3
|
||||
),
|
||||
]
|
||||
|
||||
rendered = render_canonical_markdown(
|
||||
title="Título do Artigo",
|
||||
subtitle="Subtítulo informativo",
|
||||
fingerprint="a" * 64,
|
||||
source_url="https://example.com/art",
|
||||
published_date="2026-08-20T10:00:00Z",
|
||||
language="pt",
|
||||
sentiment="positive",
|
||||
tags=["economia", "petrobras", "brasil"],
|
||||
ecp_target_id="Q123",
|
||||
ecp_target_name="Petrobras",
|
||||
body_blocks=blocks,
|
||||
)
|
||||
|
||||
assert rendered.startswith("---\n")
|
||||
assert "# Título do Artigo" in rendered
|
||||
assert "*Subtítulo informativo*" in rendered
|
||||
assert "## Primeiro Bloco" in rendered
|
||||
assert "Este é o parágrafo editorial." in rendered
|
||||
assert "- Item de lista" in rendered
|
||||
|
||||
# Verify front matter parses as valid YAML
|
||||
parts = rendered.split("---\n")
|
||||
front_matter_raw = parts[1]
|
||||
parsed_fm = yaml.safe_load(front_matter_raw)
|
||||
assert parsed_fm["title"] == "Título do Artigo"
|
||||
assert parsed_fm["fingerprint"] == "a" * 64
|
||||
assert parsed_fm["sentiment"] == "positive"
|
||||
assert parsed_fm["tags"] == ["economia", "petrobras", "brasil"]
|
||||
Reference in New Issue
Block a user