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,46 @@
|
||||
"""Tests para delete_obsidian_note."""
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from delete_obsidian_note import delete_obsidian_note
|
||||
|
||||
|
||||
def test_borra_archivo_existente_y_devuelve_true(tmp_path):
|
||||
# Golden path: borra un .md existente y confirma que desaparece.
|
||||
note = tmp_path / "Borrame.md"
|
||||
note.write_text("contenido", encoding="utf-8")
|
||||
|
||||
result = delete_obsidian_note(str(note))
|
||||
assert result is True
|
||||
assert not note.exists()
|
||||
|
||||
|
||||
def test_archivo_inexistente_lanza_filenotfounderror(tmp_path):
|
||||
# Error path: borrar algo que no existe.
|
||||
with pytest.raises(FileNotFoundError):
|
||||
delete_obsidian_note(str(tmp_path / "fantasma.md"))
|
||||
|
||||
|
||||
def test_directorio_lanza_isadirectoryerror(tmp_path):
|
||||
# Error path: se niega a borrar un directorio.
|
||||
sub = tmp_path / "carpeta"
|
||||
sub.mkdir()
|
||||
with pytest.raises(IsADirectoryError):
|
||||
delete_obsidian_note(str(sub))
|
||||
# El directorio sigue intacto tras el error.
|
||||
assert sub.is_dir()
|
||||
|
||||
|
||||
def test_no_borra_otros_archivos(tmp_path):
|
||||
# Edge: borrar una nota no afecta a las demas del vault.
|
||||
a = tmp_path / "A.md"
|
||||
b = tmp_path / "B.md"
|
||||
a.write_text("a", encoding="utf-8")
|
||||
b.write_text("b", encoding="utf-8")
|
||||
|
||||
assert delete_obsidian_note(str(a)) is True
|
||||
assert not a.exists()
|
||||
assert b.exists()
|
||||
assert os.path.isfile(str(b))
|
||||
Reference in New Issue
Block a user