feat(runtime): implement single-article consolidation runtime and modularize codebase
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
"""Integration test for ECP rejection producing zero Markdown files covering scenario OUT-008."""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from src.runtime.cli.consolidate import run_consolidation
|
||||
|
||||
|
||||
def test_ecp_rejection_flow_produces_zero_markdown(tmp_path: Path):
|
||||
# Setup non-related article
|
||||
non_related_article = {
|
||||
"crawled_url": "https://example.com/art_recipe",
|
||||
"selected_extractor": "trafilatura",
|
||||
"input_meta": {
|
||||
"titulo": "Receita de Bolo de Cenoura",
|
||||
"url": "https://example.com/art_recipe",
|
||||
},
|
||||
"trafilatura": {
|
||||
"title": "Receita de Bolo de Cenoura",
|
||||
"canonical_url": "https://example.com/art_recipe",
|
||||
"body_text": "# Receita de Bolo de Cenoura\n\nMisture as cenouras raladas com ovos, farinha e açúcar no liquidificador e asse por 40 minutos.",
|
||||
},
|
||||
}
|
||||
art_file = tmp_path / "article_unrelated.json"
|
||||
art_file.write_text(json.dumps(non_related_article), encoding="utf-8")
|
||||
|
||||
ecp_file = Path("examples/sample_ecp_snapshot.json")
|
||||
|
||||
# Custom config outputting to tmp_path
|
||||
cfg_data = json.loads(Path("runtime_config.local.json").read_text(encoding="utf-8"))
|
||||
out_dir = tmp_path / "output_articles"
|
||||
db_file = tmp_path / "test_runtime.db"
|
||||
cfg_data["paths"]["output_dir"] = str(out_dir)
|
||||
cfg_data["paths"]["sqlite_db"] = str(db_file)
|
||||
cfg_file = tmp_path / "custom_config.json"
|
||||
cfg_file.write_text(json.dumps(cfg_data), encoding="utf-8")
|
||||
|
||||
exit_code = asyncio.run(run_consolidation(art_file, ecp_file, cfg_file))
|
||||
assert exit_code == 0
|
||||
|
||||
# Verify zero .md files exist in output directory
|
||||
md_files = list(out_dir.glob("*.md"))
|
||||
assert len(md_files) == 0, f"Expected 0 Markdown files on rejected ECP, found: {md_files}"
|
||||
|
||||
# Verify .result.json exists with final_status 'rejected_ecp' and generate_markdown False
|
||||
result_files = list(out_dir.glob("*.result.json"))
|
||||
assert len(result_files) == 1
|
||||
manifest = json.loads(result_files[0].read_text(encoding="utf-8"))
|
||||
assert manifest["final_status"] == "rejected_ecp"
|
||||
assert manifest["generate_markdown"] is False
|
||||
assert manifest["markdown_path"] is None
|
||||
assert manifest["markdown_hash"] is None
|
||||
Reference in New Issue
Block a user