Files
MemRelay/backend/tests/test_basic_memory.py
T

35 lines
1019 B
Python

import asyncio
import pytest
from memrelay.basic_memory import BasicMemoryClient
from memrelay.errors import AppError
def test_write_note_maps_conflict_response_to_stable_error() -> None:
client = BasicMemoryClient("http://basic-memory.test/mcp", 1)
async def conflict_call(_name: str, _arguments: dict) -> dict:
return {
"action": "conflict",
"error": "A note with this title already exists",
"permalink": "global/existing-note",
}
client.call = conflict_call # type: ignore[method-assign]
with pytest.raises(AppError) as exc_info:
asyncio.run(
client.write_note(
title="Existing note",
content="content",
directory="global",
tags=[],
note_type="fact",
metadata={},
overwrite=False,
)
)
assert exc_info.value.code == "BASIC_MEMORY_CONFLICT"
assert exc_info.value.status_code == 409