init: technical-visualization-haness 하네스 설계
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from techviz.insert import build_markdown_block, insert_or_replace
|
||||
|
||||
|
||||
class InsertTests(unittest.TestCase):
|
||||
def test_insert_is_idempotent(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
document = root / "doc.md"
|
||||
svg = root / "diagram.svg"
|
||||
source = root / "diagram.drawio"
|
||||
spec = root / "spec.json"
|
||||
document.write_text("# Doc\n\n<!-- techviz:generate id=diagram -->\n", encoding="utf-8")
|
||||
for path in (svg, source, spec):
|
||||
path.write_text("x", encoding="utf-8")
|
||||
block = build_markdown_block(
|
||||
diagram_id="diagram",
|
||||
alt="A useful diagram",
|
||||
long_description="The diagram explains a source-grounded path.",
|
||||
svg_path=svg,
|
||||
editable_path=source,
|
||||
spec_path=spec,
|
||||
document_path=document,
|
||||
context_sha256="abc",
|
||||
)
|
||||
insert_or_replace(document, "diagram", block)
|
||||
insert_or_replace(document, "diagram", block)
|
||||
result = document.read_text(encoding="utf-8")
|
||||
self.assertEqual(result.count("techviz:begin id=diagram"), 1)
|
||||
self.assertEqual(result.count("techviz:end id=diagram"), 1)
|
||||
self.assertEqual(result.count("techviz:generate id=diagram"), 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user