Skip to content

Commit ab7da9c

Browse files
test: add test for frontmatter entity_type handling
Add test_write_note_respects_frontmatter_entity_type to verify that when write_note is called without entity_type parameter, but the content includes frontmatter with a 'type' field, that type is respected instead of defaulting to 'note'. Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
1 parent b386c54 commit ab7da9c

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

tests/mcp/test_tool_write_note.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,3 +620,45 @@ async def test_write_note_update_existing_with_different_entity_type(app):
620620
assert "type: guide" in content
621621
assert "# Updated Content" in content
622622
assert "- guide" in content
623+
624+
625+
@pytest.mark.asyncio
626+
async def test_write_note_respects_frontmatter_entity_type(app):
627+
"""Test that entity_type in frontmatter is respected when parameter is not provided.
628+
629+
This verifies that when write_note is called without entity_type parameter,
630+
but the content includes frontmatter with a 'type' field, that type is respected
631+
instead of defaulting to 'note'.
632+
"""
633+
note = dedent("""
634+
---
635+
title: Test Guide
636+
type: guide
637+
permalink: guides/test-guide
638+
tags:
639+
- guide
640+
- documentation
641+
---
642+
643+
# Guide Content
644+
This is a guide
645+
""").strip()
646+
647+
# Call write_note without entity_type parameter - it should respect frontmatter type
648+
result = await write_note.fn(
649+
title="Test Guide",
650+
folder="guides",
651+
content=note
652+
)
653+
654+
assert result
655+
assert "# Created note" in result
656+
assert "file_path: guides/Test Guide.md" in result
657+
assert "permalink: guides/test-guide" in result
658+
659+
# Verify the entity type from frontmatter is respected (should be "guide", not "note")
660+
content = await read_note.fn("guides/test-guide")
661+
assert "type: guide" in content
662+
assert "# Guide Content" in content
663+
assert "- guide" in content
664+
assert "- documentation" in content

0 commit comments

Comments
 (0)