From 5b468514ec5e10e3c12311045c5a4746a0e066c2 Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Fri, 19 Jun 2026 10:22:39 +0200 Subject: [PATCH] test(vector): use network-mode 404 signal + https in not-wrap test (#926) - Clear SonarCloud hotspot python:S5332 (insecure http:// URL) by using https:// for the inert placeholder Qdrant URL in the network-mode test. - Make the test faithful to production: stub the network existence-check with UnexpectedResponse(404) (what the real HTTP client raises) instead of the local-mode ValueError("not found"), per round-2 review. Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/unit/vector/test_qdrant_client.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/unit/vector/test_qdrant_client.py b/tests/unit/vector/test_qdrant_client.py index 49581ec2..e88ca443 100644 --- a/tests/unit/vector/test_qdrant_client.py +++ b/tests/unit/vector/test_qdrant_client.py @@ -1134,7 +1134,7 @@ async def test_get_qdrant_client_does_not_wrap_network_mode( from nextcloud_mcp_server.config import Settings settings = Settings( - qdrant_url="http://qdrant:6333", + qdrant_url="https://qdrant:6333", ollama_embedding_model="nomic-embed-text", vector_sync_enabled=False, ) @@ -1149,10 +1149,12 @@ async def test_get_qdrant_client_does_not_wrap_network_mode( lambda: embedding_service, ) - # Drive the create path (collection "not found") so the dimension-validation - # branch — which would need a fully-shaped CollectionInfo — is skipped. + # Drive the create path via the network-mode "not found" signal — an + # UnexpectedResponse(404), as the real HTTP client raises (local mode's + # ValueError("not found") is the other branch). This skips the + # dimension-validation branch that would need a fully-shaped CollectionInfo. provisional = _stub_provisional( - mocker, ValueError(f"Collection {settings.get_collection_name()} not found") + mocker, _make_unexpected(404, b'{"status":{"error":"Not found"}}') ) monkeypatch.setattr( "nextcloud_mcp_server.vector.qdrant_client.AsyncQdrantClient",