From 89ef7d7d151cb18e81ad676ca1c205d6995e61d4 Mon Sep 17 00:00:00 2001 From: hajdul88 <52442977+hajdul88@users.noreply.github.com> Date: Tue, 16 Dec 2025 15:41:13 +0100 Subject: [PATCH] feat: adds integration test for community registered retriever case --- .../test_get_search_type_tools_integration.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 cognee/tests/integration/search/test_get_search_type_tools_integration.py diff --git a/cognee/tests/integration/search/test_get_search_type_tools_integration.py b/cognee/tests/integration/search/test_get_search_type_tools_integration.py new file mode 100644 index 000000000..4380a3bdb --- /dev/null +++ b/cognee/tests/integration/search/test_get_search_type_tools_integration.py @@ -0,0 +1,36 @@ +import pytest + +from cognee.modules.search.types import SearchType + + +class _DummyCompletionContextRetriever: + def __init__(self, *args, **kwargs): + self.kwargs = kwargs + + def get_completion(self, *args, **kwargs): + return None + + def get_context(self, *args, **kwargs): + return None + + +@pytest.mark.asyncio +async def test_community_registry_is_consulted(monkeypatch): + """ + This test covers the dynamic import + lookup of community retrievers in + cognee.modules.retrieval.registered_community_retrievers. + """ + import cognee.modules.search.methods.get_search_type_tools as mod + from cognee.modules.retrieval import registered_community_retrievers as registry + + monkeypatch.setattr( + registry, + "registered_community_retrievers", + {SearchType.NATURAL_LANGUAGE: _DummyCompletionContextRetriever}, + ) + + tools = await mod.get_search_type_tools(SearchType.NATURAL_LANGUAGE, query_text="q", top_k=9) + + assert len(tools) == 2 + assert tools[0].__self__.kwargs["top_k"] == 9 + assert tools[1].__self__.kwargs["top_k"] == 9