docs(thesis): resolve review findings and verify examples
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
"""Exercise the comparison snippet when the optional LangGraph library exists."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("text", "expected_report"),
|
||||
[(" Notes ", "# Report\n\nNotes"), (" ", "")],
|
||||
)
|
||||
def test_langgraph_comparison_routes_updated_state(
|
||||
text: str, expected_report: str
|
||||
) -> None:
|
||||
"""Check the rendered example without making LangGraph a product dependency."""
|
||||
pytest.importorskip("langgraph.graph")
|
||||
manuscript = (
|
||||
Path(__file__).resolve().parents[2]
|
||||
/ "docs/thesis/system-design-implementation.md"
|
||||
).read_text(encoding="utf-8")
|
||||
section = manuscript.split("<!-- langgraph-comparison -->", 1)[1]
|
||||
snippet = section.split("```python\n", 1)[1].split("```", 1)[0]
|
||||
namespace = {}
|
||||
# This is trusted repository prose, executed exactly as displayed.
|
||||
exec(compile(snippet, "thesis-langgraph-example", "exec"), namespace)
|
||||
result = namespace["graph"].invoke({"text": text, "report": ""})
|
||||
assert result["text"] == text.strip()
|
||||
assert result["report"] == expected_report
|
||||
Reference in New Issue
Block a user