~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
Fix document loader test failures after centralized registry refactor
LearningCircuitc106f348a309
diff --git a/tests/research_library/routes/test_rag_routes.py b/tests/research_library/routes/test_rag_routes.pyindex 100f433c24..1654897c00 100644--- a/tests/research_library/routes/test_rag_routes.py+++ b/tests/research_library/routes/test_rag_routes.py@@ -758,12 +758,10 @@ class TestExtractTextFromFile:from local_deep_research.research_library.routes.rag_routes import (extract_text_from_file,)- import iocontent = b"Hello, this is a test text file."- file_obj = io.BytesIO(content)- text = extract_text_from_file(file_obj, "test.txt")+ text = extract_text_from_file(content, "txt", "test.txt")assert "Hello" in textdef test_extract_text_from_md_file(self):@@ -771,12 +769,10 @@ class TestExtractTextFromFile:from local_deep_research.research_library.routes.rag_routes import (extract_text_from_file,)- import iocontent = b"# Header\n\nThis is markdown content."- file_obj = io.BytesIO(content)- text = extract_text_from_file(file_obj, "test.md")+ text = extract_text_from_file(content, "md", "test.md")assert "Header" in text or "markdown" in textdef test_extract_text_from_unknown_file(self):@@ -784,14 +780,12 @@ class TestExtractTextFromFile:from local_deep_research.research_library.routes.rag_routes import (extract_text_from_file,)- import iocontent = b"Some content"- file_obj = io.BytesIO(content)- text = extract_text_from_file(file_obj, "test.xyz")- # Should return something or empty string- assert text is not None or text == ""+ text = extract_text_from_file(content, "xyz", "test.xyz")+ # Should return None for unsupported file types+ assert text is None# ============= Extended Tests for Phase 3.2 Coverage =============diff --git a/tests/web_search_engines/engines/test_search_engine_local.py b/tests/web_search_engines/engines/test_search_engine_local.pyindex cf75c965b3..b16ee01e77 100644--- a/tests/web_search_engines/engines/test_search_engine_local.py+++ b/tests/web_search_engines/engines/test_search_engine_local.py@@ -26,11 +26,14 @@ class TestGetFileLoader:pdf_file = tmp_path / "test.pdf"pdf_file.touch()+ mock_loader = Mock()with patch(- "local_deep_research.web_search_engines.engines.search_engine_local.PyPDFLoader"- ) as mock_loader:- _get_file_loader(str(pdf_file))- mock_loader.assert_called_once_with(str(pdf_file))+ "local_deep_research.web_search_engines.engines.search_engine_local.get_loader_for_path",+ return_value=mock_loader,+ ) as mock_get_loader:+ result = _get_file_loader(str(pdf_file))+ mock_get_loader.assert_called_once_with(str(pdf_file))+ assert result is mock_loaderdef test_get_file_loader_txt(self, tmp_path):"""Get file loader for text files."""@@ -41,11 +44,14 @@ class TestGetFileLoader:txt_file = tmp_path / "test.txt"txt_file.touch()+ mock_loader = Mock()with patch(- "local_deep_research.web_search_engines.engines.search_engine_local.TextLoader"- ) as mock_loader:- _get_file_loader(str(txt_file))- mock_loader.assert_called_once_with(str(txt_file))+ "local_deep_research.web_search_engines.engines.search_engine_local.get_loader_for_path",+ return_value=mock_loader,+ ) as mock_get_loader:+ result = _get_file_loader(str(txt_file))+ mock_get_loader.assert_called_once_with(str(txt_file))+ assert result is mock_loaderdef test_get_file_loader_markdown(self, tmp_path):"""Get file loader for markdown files."""@@ -56,11 +62,14 @@ class TestGetFileLoader:md_file = tmp_path / "test.md"md_file.touch()+ mock_loader = Mock()with patch(- "local_deep_research.web_search_engines.engines.search_engine_local.UnstructuredMarkdownLoader"- ) as mock_loader:- _get_file_loader(str(md_file))- mock_loader.assert_called_once_with(str(md_file))+ "local_deep_research.web_search_engines.engines.search_engine_local.get_loader_for_path",+ return_value=mock_loader,+ ) as mock_get_loader:+ result = _get_file_loader(str(md_file))+ mock_get_loader.assert_called_once_with(str(md_file))+ assert result is mock_loaderdef test_get_file_loader_docx(self, tmp_path):"""Get file loader for Word documents."""@@ -71,11 +80,14 @@ class TestGetFileLoader:docx_file = tmp_path / "test.docx"docx_file.touch()+ mock_loader = Mock()with patch(- "local_deep_research.web_search_engines.engines.search_engine_local.UnstructuredWordDocumentLoader"- ) as mock_loader:- _get_file_loader(str(docx_file))- mock_loader.assert_called_once_with(str(docx_file))+ "local_deep_research.web_search_engines.engines.search_engine_local.get_loader_for_path",+ return_value=mock_loader,+ ) as mock_get_loader:+ result = _get_file_loader(str(docx_file))+ mock_get_loader.assert_called_once_with(str(docx_file))+ assert result is mock_loaderdef test_get_file_loader_csv(self, tmp_path):"""Get file loader for CSV files."""@@ -86,11 +98,14 @@ class TestGetFileLoader:csv_file = tmp_path / "test.csv"csv_file.touch()+ mock_loader = Mock()with patch(- "local_deep_research.web_search_engines.engines.search_engine_local.CSVLoader"- ) as mock_loader:- _get_file_loader(str(csv_file))- mock_loader.assert_called_once_with(str(csv_file))+ "local_deep_research.web_search_engines.engines.search_engine_local.get_loader_for_path",+ return_value=mock_loader,+ ) as mock_get_loader:+ result = _get_file_loader(str(csv_file))+ mock_get_loader.assert_called_once_with(str(csv_file))+ assert result is mock_loaderdef test_get_file_loader_xlsx(self, tmp_path):"""Get file loader for Excel files."""@@ -101,11 +116,14 @@ class TestGetFileLoader:xlsx_file = tmp_path / "test.xlsx"xlsx_file.touch()+ mock_loader = Mock()with patch(- "local_deep_research.web_search_engines.engines.search_engine_local.UnstructuredExcelLoader"- ) as mock_loader:- _get_file_loader(str(xlsx_file))- mock_loader.assert_called_once_with(str(xlsx_file))+ "local_deep_research.web_search_engines.engines.search_engine_local.get_loader_for_path",+ return_value=mock_loader,+ ) as mock_get_loader:+ result = _get_file_loader(str(xlsx_file))+ mock_get_loader.assert_called_once_with(str(xlsx_file))+ assert result is mock_loaderdef test_get_file_loader_unknown_extension(self, tmp_path):"""Get file loader for unknown extension falls back to TextLoader."""@@ -116,13 +134,21 @@ class TestGetFileLoader:unknown_file = tmp_path / "test.xyz"unknown_file.touch()+ # When extension is not supported, get_loader_for_path returns None+ # and _get_file_loader falls back to TextLoaderwith patch(- "local_deep_research.web_search_engines.engines.search_engine_local.TextLoader"- ) as mock_loader:- _get_file_loader(str(unknown_file))- mock_loader.assert_called_once_with(- str(unknown_file), encoding="utf-8"- )+ "local_deep_research.web_search_engines.engines.search_engine_local.is_extension_supported",+ return_value=False,+ ):+ with patch(+ "local_deep_research.web_search_engines.engines.search_engine_local.TextLoader"+ ) as mock_text_loader:+ _get_file_loader(str(unknown_file))+ mock_text_loader.assert_called_once_with(+ str(unknown_file),+ encoding="utf-8",+ autodetect_encoding=True,+ )def test_get_file_loader_exception(self, tmp_path):"""Get file loader handles exceptions."""@@ -133,12 +159,21 @@ class TestGetFileLoader:pdf_file = tmp_path / "test.pdf"pdf_file.touch()+ # When get_loader_for_path raises an exception, it should return Nonewith patch(- "local_deep_research.web_search_engines.engines.search_engine_local.PyPDFLoader",- side_effect=Exception("Loader error"),+ "local_deep_research.web_search_engines.engines.search_engine_local.is_extension_supported",+ return_value=True,):- loader = _get_file_loader(str(pdf_file))- assert loader is None+ with patch(+ "local_deep_research.web_search_engines.engines.search_engine_local.get_loader_for_path",+ return_value=None,+ ):+ with patch(+ "local_deep_research.web_search_engines.engines.search_engine_local.TextLoader",+ side_effect=Exception("Loader error"),+ ):+ loader = _get_file_loader(str(pdf_file))+ assert loader is Noneclass TestLoadDocument: