feat(cli): Platform option parity across Python and Node CLIs (MEM-5893) (#6696)
This commit is contained in:
@@ -8,6 +8,8 @@ import httpx
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
from mem0.client.types import GetAllMemoryOptions, SearchMemoryOptions
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_memory_client():
|
||||
@@ -130,6 +132,55 @@ class TestGetAllEntityParamRejection:
|
||||
)
|
||||
|
||||
|
||||
class TestSearchTypedOptionsParity:
|
||||
"""MEM-5893: SearchMemoryOptions' new typed fields serialize to their v3 snake_case keys."""
|
||||
|
||||
def test_search_options_pass_reference_date_latest_only_keyword_search(self, mock_memory_client):
|
||||
"""search(options=SearchMemoryOptions(...)) should forward the new fields verbatim."""
|
||||
mock_response = MagicMock()
|
||||
mock_response.json.return_value = {"results": []}
|
||||
mock_response.raise_for_status.return_value = None
|
||||
mock_memory_client.client.post.return_value = mock_response
|
||||
|
||||
options = SearchMemoryOptions(
|
||||
filters={"user_id": "u1"},
|
||||
reference_date="2024-01-01",
|
||||
latest_only=True,
|
||||
keyword_search=True,
|
||||
)
|
||||
mock_memory_client.search("test query", options=options)
|
||||
|
||||
mock_memory_client.client.post.assert_called_once_with(
|
||||
"/v3/memories/search/",
|
||||
json={
|
||||
"query": "test query",
|
||||
"filters": {"user_id": "u1"},
|
||||
"reference_date": "2024-01-01",
|
||||
"latest_only": True,
|
||||
"keyword_search": True,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class TestGetAllTypedOptionsParity:
|
||||
"""MEM-5893: GetAllMemoryOptions.latest_only serializes to its v3 snake_case key."""
|
||||
|
||||
def test_get_all_options_pass_latest_only(self, mock_memory_client):
|
||||
"""get_all(options=GetAllMemoryOptions(...)) should forward latest_only verbatim."""
|
||||
mock_response = MagicMock()
|
||||
mock_response.json.return_value = {"results": []}
|
||||
mock_response.raise_for_status.return_value = None
|
||||
mock_memory_client.client.post.return_value = mock_response
|
||||
|
||||
options = GetAllMemoryOptions(filters={"user_id": "u1"}, latest_only=True)
|
||||
mock_memory_client.get_all(options=options)
|
||||
|
||||
mock_memory_client.client.post.assert_called_once_with(
|
||||
"/v3/memories/",
|
||||
json={"filters": {"user_id": "u1"}, "latest_only": True},
|
||||
)
|
||||
|
||||
|
||||
class TestUpdateExpirationDate:
|
||||
"""Tests for update expiration_date payload handling."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user