555e282cc4
pi-agent-plugin checks / lint (push) Has been cancelled
pi-agent-plugin checks / test (20) (push) Has been cancelled
pi-agent-plugin checks / test (22) (push) Has been cancelled
pi-agent-plugin checks / build (push) Has been cancelled
TypeScript SDK CI / check_changes (push) Has been cancelled
TypeScript SDK CI / changelog_check (push) Has been cancelled
ci / changelog_check (push) Has been cancelled
ci / check_changes (push) Has been cancelled
ci / build_mem0 (3.10) (push) Has been cancelled
ci / build_mem0 (3.11) (push) Has been cancelled
ci / build_mem0 (3.12) (push) Has been cancelled
CLI Node CI / lint (push) Has been cancelled
CLI Node CI / test (20) (push) Has been cancelled
CLI Node CI / test (22) (push) Has been cancelled
CLI Node CI / build (push) Has been cancelled
CLI Python CI / lint (push) Has been cancelled
CLI Python CI / test (3.10) (push) Has been cancelled
CLI Python CI / test (3.11) (push) Has been cancelled
CLI Python CI / test (3.12) (push) Has been cancelled
CLI Python CI / build (push) Has been cancelled
openclaw checks / lint (push) Has been cancelled
openclaw checks / test (20) (push) Has been cancelled
openclaw checks / test (22) (push) Has been cancelled
openclaw checks / build (push) Has been cancelled
opencode-plugin checks / build (push) Has been cancelled
TypeScript SDK CI / build_ts_sdk (20) (push) Has been cancelled
TypeScript SDK CI / build_ts_sdk (22) (push) Has been cancelled
TypeScript SDK CI / integration_ts_sdk (20) (push) Has been cancelled
TypeScript SDK CI / integration_ts_sdk (22) (push) Has been cancelled
61 lines
2.2 KiB
Python
61 lines
2.2 KiB
Python
import pytest
|
|
|
|
from mem0.memory import main as memory_main
|
|
from mem0.memory.main import AsyncMemory, Memory
|
|
|
|
|
|
def test_sync_project_update_decay_true_raises_with_notice_message(monkeypatch):
|
|
calls = []
|
|
|
|
def get_error(sync_type, trigger_function, trigger_parameter):
|
|
calls.append((sync_type, trigger_function, trigger_parameter))
|
|
return "blocked decay"
|
|
|
|
monkeypatch.setattr(memory_main, "get_decay_feature_error_message", get_error)
|
|
|
|
with pytest.raises(ValueError, match="blocked decay"):
|
|
Memory.__new__(Memory).project.update(decay=True)
|
|
|
|
assert calls == [("sync", "project.update", "decay")]
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_async_project_update_decay_true_raises_with_notice_message(monkeypatch):
|
|
calls = []
|
|
|
|
async def get_error(sync_type, trigger_function, trigger_parameter):
|
|
calls.append((sync_type, trigger_function, trigger_parameter))
|
|
return "blocked async decay"
|
|
|
|
monkeypatch.setattr(memory_main, "get_decay_feature_error_message_async", get_error)
|
|
|
|
with pytest.raises(ValueError, match="blocked async decay"):
|
|
await AsyncMemory.__new__(AsyncMemory).project.update(decay=True)
|
|
|
|
assert calls == [("async", "project.update", "decay")]
|
|
|
|
|
|
@pytest.mark.parametrize("kwargs", [{}, {"decay": False}])
|
|
def test_sync_project_update_non_trigger_raises_plain_error_without_notice(monkeypatch, kwargs):
|
|
monkeypatch.setattr(
|
|
memory_main,
|
|
"get_decay_feature_error_message",
|
|
lambda *args: pytest.fail("decay feature notice should not run"),
|
|
)
|
|
|
|
with pytest.raises(ValueError, match="Project updates are not supported by the OSS Memory SDK."):
|
|
Memory.__new__(Memory).project.update(**kwargs)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.parametrize("kwargs", [{}, {"decay": False}])
|
|
async def test_async_project_update_non_trigger_raises_plain_error_without_notice(monkeypatch, kwargs):
|
|
monkeypatch.setattr(
|
|
memory_main,
|
|
"get_decay_feature_error_message_async",
|
|
lambda *args: pytest.fail("decay feature notice should not run"),
|
|
)
|
|
|
|
with pytest.raises(ValueError, match="Project updates are not supported by the OSS Memory SDK."):
|
|
await AsyncMemory.__new__(AsyncMemory).project.update(**kwargs)
|