Skip to content

Commit 1fac76e

Browse files
HumanBean17claude
andcommitted
fix CI: stub _get_sentence_transformer in all remaining search tests
Previous fix only covered 2 of 11 search tests that call search_v2 without mocking the SentenceTransformer model loader. Adds the stub to all remaining tests in test_mcp_v2.py and test_mcp_v2_compose.py. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 24bcc5c commit 1fac76e

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

tests/test_mcp_v2.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def _fake_search_rows() -> list[dict[str, Any]]:
117117

118118

119119
def test_search_basic_returns_hits_with_symbol_id(monkeypatch, kuzu_graph) -> None:
120+
monkeypatch.setattr("mcp_v2._get_sentence_transformer", lambda *a, **kw: None)
120121
monkeypatch.setattr("mcp_v2.run_search", lambda *args, **kwargs: _fake_search_rows())
121122
out = search_v2("ChatService", graph=kuzu_graph)
122123
assert out.success is True
@@ -125,6 +126,7 @@ def test_search_basic_returns_hits_with_symbol_id(monkeypatch, kuzu_graph) -> No
125126

126127

127128
def test_search_filter_microservice(monkeypatch, kuzu_graph) -> None:
129+
monkeypatch.setattr("mcp_v2._get_sentence_transformer", lambda *a, **kw: None)
128130
monkeypatch.setattr("mcp_v2.run_search", lambda *args, **kwargs: _fake_search_rows())
129131
out = search_v2("ChatService", filter={"microservice": "chat-assign"}, graph=kuzu_graph)
130132
assert out.success is True
@@ -133,6 +135,7 @@ def test_search_filter_microservice(monkeypatch, kuzu_graph) -> None:
133135

134136

135137
def test_search_path_contains_filter(monkeypatch, kuzu_graph) -> None:
138+
monkeypatch.setattr("mcp_v2._get_sentence_transformer", lambda *a, **kw: None)
136139
monkeypatch.setattr("mcp_v2.run_search", lambda *args, **kwargs: _fake_search_rows())
137140
out = search_v2("ChatAssign", path_contains="ChatAssign", graph=kuzu_graph)
138141
assert out.success is True
@@ -566,6 +569,7 @@ async def test_search_invalid_table_rejected(mcp_server) -> None:
566569

567570

568571
def test_search_filter_accepts_json_string(monkeypatch, kuzu_graph) -> None:
572+
monkeypatch.setattr("mcp_v2._get_sentence_transformer", lambda *a, **kw: None)
569573
monkeypatch.setattr("mcp_v2.run_search", lambda *args, **kwargs: _fake_search_rows())
570574
want = {"microservice": "chat-assign"}
571575
out_dict = search_v2("ChatService", filter=want, graph=kuzu_graph)
@@ -576,6 +580,7 @@ def test_search_filter_accepts_json_string(monkeypatch, kuzu_graph) -> None:
576580

577581

578582
def test_search_unknown_filter_key_returns_failure(monkeypatch, kuzu_graph) -> None:
583+
monkeypatch.setattr("mcp_v2._get_sentence_transformer", lambda *a, **kw: None)
579584
monkeypatch.setattr("mcp_v2.run_search", lambda *args, **kwargs: _fake_search_rows())
580585
out = search_v2("ChatService", filter={"typo_key": "x"}, graph=kuzu_graph)
581586
assert out.success is False
@@ -585,6 +590,7 @@ def test_search_unknown_filter_key_returns_failure(monkeypatch, kuzu_graph) -> N
585590

586591

587592
def test_search_cross_kind_filter_returns_failure(monkeypatch, kuzu_graph) -> None:
593+
monkeypatch.setattr("mcp_v2._get_sentence_transformer", lambda *a, **kw: None)
588594
monkeypatch.setattr("mcp_v2.run_search", lambda *args, **kwargs: _fake_search_rows())
589595
out = search_v2("ChatService", filter={"path_prefix": "/api"}, graph=kuzu_graph)
590596
assert out.success is False
@@ -674,6 +680,7 @@ def test_neighbors_validate_call_still_raises(kuzu_graph) -> None:
674680

675681

676682
def test_filter_invalid_json_returns_failure(monkeypatch, kuzu_graph) -> None:
683+
monkeypatch.setattr("mcp_v2._get_sentence_transformer", lambda *a, **kw: None)
677684
monkeypatch.setattr("mcp_v2.run_search", lambda *args, **kwargs: _fake_search_rows())
678685
out = search_v2("ChatService", filter="{not json", graph=kuzu_graph)
679686
assert out.success is False
@@ -713,6 +720,7 @@ def test_wildcard_question_mark_in_fqn_prefix_rejected(kuzu_graph) -> None:
713720

714721

715722
def test_search_wildcard_in_fqn_prefix_rejected_without_run_search(monkeypatch, kuzu_graph) -> None:
723+
monkeypatch.setattr("mcp_v2._get_sentence_transformer", lambda *a, **kw: None)
716724
calls: list[int] = []
717725

718726
def boom(*_a, **_k):

tests/test_mcp_v2_compose.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ def test_meta_returns_per_edge_type_counts(kuzu_graph) -> None:
241241

242242

243243
def test_search_describe_neighbors_chain_end_to_end(kuzu_graph, monkeypatch) -> None:
244+
monkeypatch.setattr("mcp_v2._get_sentence_transformer", lambda *a, **kw: None)
244245
node_id, _ = _method_with_incoming_calls(kuzu_graph)
245246
rows = kuzu_graph._rows( # noqa: SLF001
246247
"MATCH (m:Symbol {id: $id}) RETURN m.fqn AS fqn, m.role AS role, m.module AS module, "

0 commit comments

Comments
 (0)