feat(infra): auto-commit con 88 cambios
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
"""Tests para parse_obsidian_frontmatter."""
|
||||
|
||||
from parse_obsidian_frontmatter import parse_obsidian_frontmatter
|
||||
|
||||
|
||||
def test_frontmatter_basico():
|
||||
note = "---\ntitle: My Note\ntags:\n - a\n - b\n---\n\nHello [[other]]."
|
||||
result = parse_obsidian_frontmatter(note)
|
||||
assert result["frontmatter"] == {"title": "My Note", "tags": ["a", "b"]}
|
||||
assert result["body"] == "\nHello [[other]]."
|
||||
|
||||
|
||||
def test_crlf_line_endings():
|
||||
crlf = "---\r\ntitle: X\r\nstatus: done\r\n---\r\nbody line\r\nsecond line"
|
||||
result = parse_obsidian_frontmatter(crlf)
|
||||
assert result["frontmatter"] == {"title": "X", "status": "done"}
|
||||
assert "body line" in result["body"]
|
||||
|
||||
|
||||
def test_sin_frontmatter_devuelve_content_completo():
|
||||
plain = "just a body, no frontmatter\nwith two lines"
|
||||
result = parse_obsidian_frontmatter(plain)
|
||||
assert result == {"frontmatter": {}, "body": plain}
|
||||
|
||||
|
||||
def test_frontmatter_sin_cierre_es_body():
|
||||
broken = "---\ntitle: X\nno closing delimiter\nmore text"
|
||||
result = parse_obsidian_frontmatter(broken)
|
||||
assert result == {"frontmatter": {}, "body": broken}
|
||||
|
||||
|
||||
def test_frontmatter_vacio():
|
||||
empty = "---\n---\nbody after empty frontmatter"
|
||||
result = parse_obsidian_frontmatter(empty)
|
||||
# An empty YAML block parses to None (not a dict) -> treated as no frontmatter.
|
||||
assert result == {"frontmatter": {}, "body": empty}
|
||||
|
||||
|
||||
def test_yaml_invalido_es_body():
|
||||
bad = "---\nthis: is: invalid: yaml: ::\n---\nbody"
|
||||
result = parse_obsidian_frontmatter(bad)
|
||||
assert result == {"frontmatter": {}, "body": bad}
|
||||
|
||||
|
||||
def test_content_vacio():
|
||||
result = parse_obsidian_frontmatter("")
|
||||
assert result == {"frontmatter": {}, "body": ""}
|
||||
Reference in New Issue
Block a user