mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
5b4f0eafcc
* configure logging * set mcp output logging also * fix type check errors * fix type check * rename Permalink schema type * fix type errors * add typechecks to ci workflow * pytest coverage setup * add tests for status cli * sync tests coverage * watch_service test coverage * tests for tool_utils.py * clean up imports * file_utils coverage * markdown plugins coverage * 99% test coverage * more test coverage, remove ObservationCategory * more tool coverage * fix type-check * format, upgrade deps --------- Co-authored-by: phernandez <phernandez@basicmachines.co>
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
"""Tests for get_entity MCP tool."""
|
|
|
|
import pytest
|
|
from mcp.server.fastmcp.exceptions import ToolError
|
|
|
|
from basic_memory.mcp.tools import notes
|
|
from basic_memory.mcp.tools.knowledge import get_entity
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_basic_entity(client):
|
|
"""Test retrieving a basic entity."""
|
|
# First create an entity
|
|
permalink = await notes.write_note(
|
|
title="Test Note",
|
|
folder="test",
|
|
content="""
|
|
# Test\nThis is a test note
|
|
- [note] First observation
|
|
""",
|
|
tags=["test", "documentation"],
|
|
)
|
|
|
|
assert permalink # Got a valid permalink
|
|
|
|
# Get the entity without content
|
|
entity = await get_entity(permalink)
|
|
|
|
# Verify entity details
|
|
assert entity.file_path == "test/Test Note.md"
|
|
assert entity.entity_type == "note"
|
|
assert entity.permalink == "test/test-note"
|
|
|
|
# Check observations
|
|
assert len(entity.observations) == 1
|
|
obs = entity.observations[0]
|
|
assert obs.content == "First observation"
|
|
assert obs.category == "note"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_nonexistent_entity(client):
|
|
"""Test attempting to get a non-existent entity."""
|
|
with pytest.raises(ToolError):
|
|
await get_entity("test/nonexistent")
|