eb8dbf66a1
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
"""Tests para extract_obsidian_wikilinks."""
|
|
|
|
from extract_obsidian_wikilinks import extract_obsidian_wikilinks
|
|
|
|
|
|
def test_links_basicos_y_normalizacion():
|
|
body = (
|
|
"See [[Note A]] and [[Note B|the second]] plus [[Note A#Section]] "
|
|
"and [[Note C#^block123]]."
|
|
)
|
|
links = extract_obsidian_wikilinks(body)
|
|
assert links == ["Note A", "Note B", "Note C"]
|
|
|
|
|
|
def test_incluye_embeds():
|
|
body = "Text [[Note A]] and embed ![[diagram.png]] and ![[Note D]]."
|
|
links = extract_obsidian_wikilinks(body)
|
|
assert links == ["Note A", "diagram.png", "Note D"]
|
|
|
|
|
|
def test_dedup_preserva_orden():
|
|
body = "[[Z]] [[A]] [[Z]] [[A|alias]] [[B]]"
|
|
links = extract_obsidian_wikilinks(body)
|
|
assert links == ["Z", "A", "B"]
|
|
|
|
|
|
def test_alias_y_heading_combinados():
|
|
body = "[[Note E#Heading|Custom Alias]]"
|
|
links = extract_obsidian_wikilinks(body)
|
|
assert links == ["Note E"]
|
|
|
|
|
|
def test_whitespace_se_strippa():
|
|
body = "[[ spaced note |alias]] and [[ tight ]]"
|
|
links = extract_obsidian_wikilinks(body)
|
|
assert links == ["spaced note", "tight"]
|
|
|
|
|
|
def test_sin_links():
|
|
assert extract_obsidian_wikilinks("no links here") == []
|
|
|
|
|
|
def test_body_vacio():
|
|
assert extract_obsidian_wikilinks("") == []
|