Write a memory doc with a controlled date so ordering is deterministic to assert.
(mem: Path, filename: str, date: str, *, outcome="dead_end",
question="q", nodes=None)
| 112 | |
| 113 | |
| 114 | def _write_raw_doc(mem: Path, filename: str, date: str, *, outcome="dead_end", |
| 115 | question="q", nodes=None): |
| 116 | """Write a memory doc with a controlled date so ordering is deterministic to assert.""" |
| 117 | mem.mkdir(parents=True, exist_ok=True) |
| 118 | nodes = nodes or [] |
| 119 | lines = ["---", 'type: "query"', f'date: "{date}"', f'question: "{question}"', |
| 120 | 'contributor: "graphify"', f'outcome: "{outcome}"'] |
| 121 | if nodes: |
| 122 | lines.append("source_nodes: [" + ", ".join(f'"{n}"' for n in nodes) + "]") |
| 123 | lines += ["---", "", f"# Q: {question}", ""] |
| 124 | (mem / filename).write_text("\n".join(lines), encoding="utf-8") |
| 125 | |
| 126 | |
| 127 | def test_load_memory_docs_orders_by_date_then_filename(tmp_path): |
no test coverage detected