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
123 lines
4.3 KiB
Python
123 lines
4.3 KiB
Python
"""Extended tests for paths module - covering untested directory functions."""
|
|
|
|
from pathlib import Path
|
|
|
|
from local_deep_research.config.paths import (
|
|
get_library_directory,
|
|
get_config_directory,
|
|
get_models_directory,
|
|
get_research_outputs_directory,
|
|
)
|
|
|
|
|
|
class TestGetLibraryDirectory:
|
|
"""Tests for get_library_directory function."""
|
|
|
|
def test_returns_library_subdirectory(self, mock_env_data_dir):
|
|
"""Should return library subdirectory of data dir."""
|
|
result = get_library_directory()
|
|
assert result.name == "library"
|
|
assert result.parent == mock_env_data_dir
|
|
|
|
def test_creates_directory(self, mock_env_data_dir):
|
|
"""Should create directory if it doesn't exist."""
|
|
result = get_library_directory()
|
|
assert result.exists()
|
|
assert result.is_dir()
|
|
|
|
def test_returns_path_object(self, mock_env_data_dir):
|
|
"""Should return Path object."""
|
|
result = get_library_directory()
|
|
assert isinstance(result, Path)
|
|
|
|
def test_idempotent_when_directory_exists(self, mock_env_data_dir):
|
|
"""Calling twice should work fine when directory already exists."""
|
|
result1 = get_library_directory()
|
|
result2 = get_library_directory()
|
|
assert result1 == result2
|
|
assert result1.exists()
|
|
|
|
|
|
class TestGetConfigDirectory:
|
|
"""Tests for get_config_directory function."""
|
|
|
|
def test_returns_config_subdirectory(self, mock_env_data_dir):
|
|
"""Should return config subdirectory of data dir."""
|
|
result = get_config_directory()
|
|
assert result.name == "config"
|
|
assert result.parent == mock_env_data_dir
|
|
|
|
def test_creates_directory(self, mock_env_data_dir):
|
|
"""Should create directory if it doesn't exist."""
|
|
result = get_config_directory()
|
|
assert result.exists()
|
|
assert result.is_dir()
|
|
|
|
def test_returns_path_object(self, mock_env_data_dir):
|
|
"""Should return Path object."""
|
|
result = get_config_directory()
|
|
assert isinstance(result, Path)
|
|
|
|
|
|
class TestGetModelsDirectory:
|
|
"""Tests for get_models_directory function."""
|
|
|
|
def test_returns_models_subdirectory(self, mock_env_data_dir):
|
|
"""Should return models subdirectory of data dir."""
|
|
result = get_models_directory()
|
|
assert result.name == "models"
|
|
assert result.parent == mock_env_data_dir
|
|
|
|
def test_creates_directory(self, mock_env_data_dir):
|
|
"""Should create directory if it doesn't exist."""
|
|
result = get_models_directory()
|
|
assert result.exists()
|
|
assert result.is_dir()
|
|
|
|
def test_returns_path_object(self, mock_env_data_dir):
|
|
"""Should return Path object."""
|
|
result = get_models_directory()
|
|
assert isinstance(result, Path)
|
|
|
|
|
|
class TestAllDirectoriesUseDataDir:
|
|
"""Verify all directory functions consistently use get_data_directory as base."""
|
|
|
|
def test_all_subdirectories_share_same_parent(self, mock_env_data_dir):
|
|
"""All subdirectory functions should use the same data directory."""
|
|
library = get_library_directory()
|
|
config = get_config_directory()
|
|
models = get_models_directory()
|
|
outputs = get_research_outputs_directory()
|
|
|
|
assert library.parent == mock_env_data_dir
|
|
assert config.parent == mock_env_data_dir
|
|
assert models.parent == mock_env_data_dir
|
|
assert outputs.parent == mock_env_data_dir
|
|
|
|
def test_env_var_override_affects_all_directories(
|
|
self, tmp_path, monkeypatch
|
|
):
|
|
"""LDR_DATA_DIR override should affect all directory functions."""
|
|
custom_dir = tmp_path / "custom_data"
|
|
custom_dir.mkdir()
|
|
monkeypatch.setenv("LDR_DATA_DIR", str(custom_dir))
|
|
|
|
library = get_library_directory()
|
|
config = get_config_directory()
|
|
models = get_models_directory()
|
|
|
|
assert library.parent == custom_dir
|
|
assert config.parent == custom_dir
|
|
assert models.parent == custom_dir
|
|
|
|
def test_all_directories_are_distinct(self, mock_env_data_dir):
|
|
"""All directory functions should return different paths."""
|
|
library = get_library_directory()
|
|
config = get_config_directory()
|
|
models = get_models_directory()
|
|
outputs = get_research_outputs_directory()
|
|
|
|
paths = {library, config, models, outputs}
|
|
assert len(paths) == 4, "All directory paths should be unique"
|