Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

test: realign two unit tests with current upsert + anchor behavior (#809)

Swati Ahujad3bad2cdcaa2
diff --git a/tests/unit/persistence/test_crud_smoke.py b/tests/unit/persistence/test_crud_smoke.py
index 888a8c622..115dc6406 100644
--- a/tests/unit/persistence/test_crud_smoke.py
+++ b/tests/unit/persistence/test_crud_smoke.py
@@ -66,9 +66,18 @@ async def test_batch_upsert_graph_metrics_inserts_then_updates(async_session):
@pytest.mark.asyncio
async def test_batch_upsert_graph_edges_updates_existing(async_session):
repo = await insert_repo(async_session)
- edges = [{"source_node_id": "a", "target_node_id": "b", "edge_type": "imports"}]
+ edges = [
+ {
+ "source_node_id": "a",
+ "target_node_id": "b",
+ "edge_type": "imports",
+ "confidence": 0.7,
+ }
+ ]
await batch_upsert_graph_edges(async_session, repo.id, edges)
- # Re-upsert the same key with new optional fields → in-place update.
+ # Re-upsert the same key with new optional fields → in-place update, but
+ # confidence keeps the max on collision (a lower re-upsert must not lower
+ # it — the resolver can stamp a real call below the flow floor otherwise).
await batch_upsert_graph_edges(
async_session,
repo.id,
@@ -88,7 +97,7 @@ async def test_batch_upsert_graph_edges_updates_existing(async_session):
rows = list(result.scalars().all())
assert len(rows) == 1
assert rows[0].imported_names_json == '["foo"]'
- assert rows[0].confidence == 0.5
+ assert rows[0].confidence == 0.7
@pytest.mark.asyncio
diff --git a/tests/unit/server/mcp/test_answer_calibration.py b/tests/unit/server/mcp/test_answer_calibration.py
index 5aa6030ad..bfaab2f5c 100644
--- a/tests/unit/server/mcp/test_answer_calibration.py
+++ b/tests/unit/server/mcp/test_answer_calibration.py
@@ -439,7 +439,7 @@ def _patch_anchor(monkeypatch, answer_mod, anchored: dict):
"""Force symbol anchoring to attach ``anchored`` to the top hit, as if the
question named an indexed symbol whose defining file got promoted."""
- async def _fake_anchor(session, repo_id, question_ids, hits):
+ async def _fake_anchor(session, repo_id, question_ids, hits, **kwargs):
if hits:
hits[0]["_anchor_symbols"] = [anchored]
return hits, {"union": {}, "qualified_miss": []}