From 1708b576664f3b6be6361d931b99535606a5db15 Mon Sep 17 00:00:00 2001 From: Allen Cheng Date: Sat, 27 Jun 2026 17:01:37 -0700 Subject: [PATCH] test: fix stale `_DummyInner` mock signatures in test_embeddings.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hand-written `_DummyInner` stub in `test_embeddings.py` had `add` / `upsert` / `search` signatures that drifted from the real pyo3 bindings as they gained parameters (`tenant`, `source`, `run_id`, `created_at`, and the projection args). `Context.add` now passes 22 positional args to `_inner.add`, but the stub accepted at most 18 — so every test that exercised `add` / `upsert` failed with `TypeError: _DummyInner.add() takes from 10 to 18 positional arguments but 22 were given`, before reaching its assertion. These failures predated and were independent of any feature change; they weren't caught in CI because the Python test workflow's path doesn't match how the suite is invoked locally. Fix: capture only the leading arguments the tests assert on (`role`, `content`, `data_type`, `embedding`, and `external_id` for `upsert`) and absorb the rest with `*args, **kwargs`, so the stub no longer drifts when the real binding signatures grow. `test_embeddings.py`: 15 passed (was 8 failing). No production code changed. --- python/tests/test_embeddings.py | 71 ++++++++++----------------------- 1 file changed, 22 insertions(+), 49 deletions(-) diff --git a/python/tests/test_embeddings.py b/python/tests/test_embeddings.py index eba0fff..fcb784c 100644 --- a/python/tests/test_embeddings.py +++ b/python/tests/test_embeddings.py @@ -46,7 +46,12 @@ def _ctx_no_provider() -> Context: class _DummyInner: - """Minimal inner stub that records calls.""" + """Minimal inner stub that records calls. + + Captures only the leading arguments the tests assert on and absorbs the + rest with ``*args, **kwargs``, so the stub doesn't drift as the real + binding signatures grow (e.g. new ``tenant``/``source``/projection args). + """ def __init__(self) -> None: self.add_calls: list[dict[str, Any]] = [] @@ -54,25 +59,14 @@ def __init__(self) -> None: self.search_calls: list[tuple[Any, ...]] = [] self.upsert_calls: list[dict[str, Any]] = [] - def add( # noqa: PLR0913 + def add( self, role: str, content: Any, - data_type: Any, - embedding: Any, - bot_id: Any, - session_id: Any, - external_id: Any, - state_metadata: Any, - metadata_json: Any, - expires_at: Any = None, - retention_policy: Any = None, - lifecycle_status: Any = None, - retired_at: Any = None, - retired_reason: Any = None, - supersedes_id: Any = None, - superseded_by_id: Any = None, - relationships_json: Any = None, + data_type: Any = None, + embedding: Any = None, + *args: Any, + **kwargs: Any, ) -> None: self.add_calls.append( {"role": role, "content": content, "embedding": embedding} @@ -81,44 +75,23 @@ def add( # noqa: PLR0913 def add_many(self, records: list[dict[str, Any]]) -> None: self.add_many_calls.append(records) - def search( - self, - vector: list[float], - limit: Any, - filters_json: Any, - include_expired: bool = False, - include_retired: bool = False, - include_relationships: bool = False, - ) -> list[Any]: - self.search_calls.append( - ( - vector, - limit, - filters_json, - include_expired, - include_retired, - include_relationships, - ) - ) + def search(self, vector: list[float], *args: Any, **kwargs: Any) -> list[Any]: + self.search_calls.append((vector, *args)) return [] def upsert( # noqa: PLR0913 self, role: str, content: Any, - data_type: Any, - embedding: Any, - bot_id: Any, - session_id: Any, - external_id: Any, - metadata_json: Any, - expires_at: Any = None, - retention_policy: Any = None, - lifecycle_status: Any = None, - retired_at: Any = None, - retired_reason: Any = None, - relationships_json: Any = None, - key: str = "external_id", + data_type: Any = None, + embedding: Any = None, + bot_id: Any = None, + session_id: Any = None, + tenant: Any = None, + source: Any = None, + external_id: Any = None, + *args: Any, + **kwargs: Any, ) -> dict[str, Any]: self.upsert_calls.append( {"role": role, "content": content, "embedding": embedding}