7a0da7932b
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Has been cancelled
Docker Tests (Consolidated) / Accessibility Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Unit Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Example Tests (push) Has been cancelled
Docker Tests (Consolidated) / Production Image Smoke Test (push) Has been cancelled
Docker Tests (Consolidated) / Infrastructure Tests (push) Has been cancelled
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Has been cancelled
Backwards Compatibility / Verify Encryption Constants (push) Has been cancelled
Backwards Compatibility / PyPI Version Compatibility (push) Has been cancelled
Backwards Compatibility / Database Migration Tests (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Docker Tests (Consolidated) / detect-changes (push) Has been cancelled
Docker Tests (Consolidated) / Build Test Image (push) Has been cancelled
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Has been cancelled
208 lines
6.4 KiB
Python
208 lines
6.4 KiB
Python
"""
|
|
Full coverage tests for document_loaders/loader_registry.py.
|
|
|
|
Targets uncovered paths:
|
|
- get_loader_for_path: unsupported extension returns None
|
|
- Conditional registry entries (HAS_ODT_LOADER, etc.)
|
|
- get_supported_extensions returns correct list
|
|
"""
|
|
|
|
|
|
class TestGetLoaderForPathUnsupported:
|
|
"""Cover get_loader_for_path with unsupported extensions."""
|
|
|
|
def test_unsupported_extension_returns_none(self, tmp_path):
|
|
"""Returns None for file with unsupported extension."""
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
get_loader_for_path,
|
|
)
|
|
|
|
f = tmp_path / "data.xyz123"
|
|
f.write_text("content")
|
|
result = get_loader_for_path(f)
|
|
assert result is None
|
|
|
|
def test_no_extension_returns_none(self, tmp_path):
|
|
"""Returns None for file with no extension."""
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
get_loader_for_path,
|
|
)
|
|
|
|
f = tmp_path / "Makefile"
|
|
f.write_text("all: build")
|
|
result = get_loader_for_path(f)
|
|
assert result is None
|
|
|
|
def test_string_path_input(self, tmp_path):
|
|
"""Accepts string path input."""
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
get_loader_for_path,
|
|
)
|
|
|
|
f = tmp_path / "test.txt"
|
|
f.write_text("hello")
|
|
result = get_loader_for_path(str(f))
|
|
assert result is not None
|
|
|
|
|
|
class TestGetSupportedExtensions:
|
|
"""Cover get_supported_extensions."""
|
|
|
|
def test_returns_list_of_strings(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
get_supported_extensions,
|
|
)
|
|
|
|
extensions = get_supported_extensions()
|
|
assert isinstance(extensions, list)
|
|
assert all(isinstance(e, str) for e in extensions)
|
|
assert all(e.startswith(".") for e in extensions)
|
|
|
|
def test_contains_required_extensions(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
get_supported_extensions,
|
|
)
|
|
|
|
extensions = get_supported_extensions()
|
|
for required in [".pdf", ".txt", ".md", ".csv", ".json", ".yaml"]:
|
|
assert required in extensions
|
|
|
|
|
|
class TestConditionalLoaderRegistration:
|
|
"""Test conditional loader registration flags."""
|
|
|
|
def test_odt_loader_flag_is_bool(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
HAS_ODT_LOADER,
|
|
)
|
|
|
|
assert isinstance(HAS_ODT_LOADER, bool)
|
|
|
|
def test_epub_loader_flag_is_bool(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
HAS_EPUB_LOADER,
|
|
)
|
|
|
|
assert isinstance(HAS_EPUB_LOADER, bool)
|
|
|
|
def test_rtf_loader_flag_is_bool(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
HAS_RTF_LOADER,
|
|
)
|
|
|
|
assert isinstance(HAS_RTF_LOADER, bool)
|
|
|
|
def test_rst_loader_flag_is_bool(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
HAS_RST_LOADER,
|
|
)
|
|
|
|
assert isinstance(HAS_RST_LOADER, bool)
|
|
|
|
def test_org_loader_flag_is_bool(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
HAS_ORG_LOADER,
|
|
)
|
|
|
|
assert isinstance(HAS_ORG_LOADER, bool)
|
|
|
|
def test_image_loader_flag_is_bool(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
HAS_IMAGE_LOADER,
|
|
)
|
|
|
|
assert isinstance(HAS_IMAGE_LOADER, bool)
|
|
|
|
def test_odt_in_registry_iff_flag_and_dep(self):
|
|
# ODT needs both the loader class and python-docx (the partitioner
|
|
# imports python-docx and shells out to pandoc).
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
HAS_DOCX_DEP,
|
|
HAS_ODT_LOADER,
|
|
LOADER_REGISTRY,
|
|
)
|
|
|
|
assert (".odt" in LOADER_REGISTRY) == (HAS_ODT_LOADER and HAS_DOCX_DEP)
|
|
|
|
def test_epub_in_registry_iff_flag_and_dep(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
HAS_EPUB_LOADER,
|
|
HAS_PANDOC_DEP,
|
|
LOADER_REGISTRY,
|
|
)
|
|
|
|
assert (".epub" in LOADER_REGISTRY) == (
|
|
HAS_EPUB_LOADER and HAS_PANDOC_DEP
|
|
)
|
|
|
|
def test_rtf_in_registry_iff_flag_and_dep(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
HAS_PANDOC_DEP,
|
|
HAS_RTF_LOADER,
|
|
LOADER_REGISTRY,
|
|
)
|
|
|
|
assert (".rtf" in LOADER_REGISTRY) == (
|
|
HAS_RTF_LOADER and HAS_PANDOC_DEP
|
|
)
|
|
|
|
def test_rst_in_registry_iff_flag_and_dep(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
HAS_PANDOC_DEP,
|
|
HAS_RST_LOADER,
|
|
LOADER_REGISTRY,
|
|
)
|
|
|
|
assert (".rst" in LOADER_REGISTRY) == (
|
|
HAS_RST_LOADER and HAS_PANDOC_DEP
|
|
)
|
|
|
|
def test_org_in_registry_iff_flag_and_dep(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
HAS_ORG_LOADER,
|
|
HAS_PANDOC_DEP,
|
|
LOADER_REGISTRY,
|
|
)
|
|
|
|
assert (".org" in LOADER_REGISTRY) == (
|
|
HAS_ORG_LOADER and HAS_PANDOC_DEP
|
|
)
|
|
|
|
def test_image_extensions_in_registry_iff_flag_and_dep(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
HAS_IMAGE_LOADER,
|
|
HAS_OCR_DEP,
|
|
LOADER_REGISTRY,
|
|
)
|
|
|
|
image_exts = [".png", ".jpg", ".jpeg", ".tiff", ".tif", ".bmp", ".heic"]
|
|
for ext in image_exts:
|
|
assert (ext in LOADER_REGISTRY) == (
|
|
HAS_IMAGE_LOADER and HAS_OCR_DEP
|
|
)
|
|
|
|
|
|
class TestIsExtensionSupportedCaseInsensitive:
|
|
"""Cover case-insensitive extension checking."""
|
|
|
|
def test_uppercase_with_dot(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
is_extension_supported,
|
|
)
|
|
|
|
assert is_extension_supported(".PDF") is True
|
|
|
|
def test_mixed_case_without_dot(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
is_extension_supported,
|
|
)
|
|
|
|
assert is_extension_supported("Html") is True
|
|
|
|
def test_uppercase_json(self):
|
|
from local_deep_research.document_loaders.loader_registry import (
|
|
is_extension_supported,
|
|
)
|
|
|
|
assert is_extension_supported(".JSON") is True
|