mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-17 13:13:18 +08:00
初始化:独立 oclaw 仓库首提交
- 在 oclaw/ 下重新初始化 Git 仓库 - 补齐子仓库 .gitignore,避免提交本地运行态数据(_local、node_modules、logs 等) - 提交当前工程代码与配置 Made-with: Cursor
This commit is contained in:
commit
ba3836f00f
579 changed files with 83112 additions and 0 deletions
29
tests/test_frontmatter_yaml.py
Normal file
29
tests/test_frontmatter_yaml.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from oclaw.prompts.frontmatter import parse_frontmatter_dict, parse_markdown_document
|
||||
|
||||
|
||||
def test_parse_yaml_frontmatter_nested_metadata() -> None:
|
||||
fm = parse_frontmatter_dict(
|
||||
"name: demo\ndescription: x\nmetadata:\n openclaw:\n install:\n - id: i1\n kind: node\n",
|
||||
source="test",
|
||||
)
|
||||
assert fm.get("name") == "demo"
|
||||
md = fm.get("metadata")
|
||||
assert isinstance(md, dict)
|
||||
assert isinstance(md.get("openclaw"), dict)
|
||||
|
||||
|
||||
def test_parse_markdown_document_roundtrip() -> None:
|
||||
raw = "---\ntitle: t\nsummary: s\nread_when: now\n---\n\n# Body\nhello"
|
||||
meta, body = parse_markdown_document(raw, source="test")
|
||||
assert meta.get("title") == "t"
|
||||
assert "hello" in body
|
||||
|
||||
|
||||
def test_strict_yaml_invalid_raises(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setenv("AIA_PROMPT_FRONTMATTER_STRICT", "1")
|
||||
with pytest.raises(ValueError):
|
||||
parse_frontmatter_dict("*invalid\nfoo: bar", source="test")
|
||||
Loading…
Add table
Add a link
Reference in a new issue