7a0da7932b
Backwards Compatibility / Verify Encryption Constants (push) Waiting to run
Backwards Compatibility / PyPI Version Compatibility (push) Waiting to run
Backwards Compatibility / Database Migration Tests (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Blocked by required conditions
Docker Tests (Consolidated) / detect-changes (push) Waiting to run
Docker Tests (Consolidated) / Build Test Image (push) Waiting to run
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Blocked by required conditions
Docker Tests (Consolidated) / Accessibility Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Unit Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Example Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / Production Image Smoke Test (push) Blocked by required conditions
Docker Tests (Consolidated) / Infrastructure Tests (push) Blocked by required conditions
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Waiting to run
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
65 lines
2.3 KiB
Python
65 lines
2.3 KiB
Python
"""Regression: ``unwrap_setting`` must not reintroduce the api<->security
|
|
import cycle.
|
|
|
|
``unwrap_setting`` briefly lived in ``api.settings_utils``, whose package
|
|
``__init__`` eagerly imports the research/search/security chain. Low-level
|
|
modules (``security.egress.policy``, ``web_search_engines.search_engine_factory``,
|
|
``notifications.manager``, ...) importing it created a circular import that
|
|
crashed at import time::
|
|
|
|
ImportError: cannot import name 'PolicyDeniedError' from partially
|
|
initialized module 'local_deep_research.security.egress.policy'
|
|
|
|
It now lives in the dependency-free ``utilities.type_utils`` leaf. These
|
|
checks import the cycle-critical modules in FRESH interpreters — pytest's
|
|
module cache would mask a real cycle within a single process — and assert
|
|
they load cleanly.
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
# Statements that sat on (or triggered) the api<->security import cycle.
|
|
# Each must import on its own in a clean interpreter.
|
|
CYCLE_CRITICAL = [
|
|
"from local_deep_research.web_search_engines.search_engine_factory "
|
|
"import PolicyDeniedError",
|
|
"from local_deep_research.security.egress.policy import PolicyDeniedError",
|
|
"import local_deep_research.security",
|
|
"import local_deep_research.web.app_factory",
|
|
]
|
|
|
|
|
|
@pytest.mark.parametrize("stmt", CYCLE_CRITICAL)
|
|
def test_cycle_critical_module_imports_clean(stmt):
|
|
result = subprocess.run(
|
|
[sys.executable, "-c", stmt],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=120,
|
|
)
|
|
assert result.returncode == 0, (
|
|
"Import failed (possible reintroduced circular import):\n"
|
|
f" statement: {stmt}\n{result.stderr}"
|
|
)
|
|
|
|
|
|
def test_unwrap_setting_lives_in_leaf_and_behaves():
|
|
from local_deep_research.utilities.type_utils import unwrap_setting
|
|
|
|
assert unwrap_setting({"value": 5}) == 5
|
|
assert unwrap_setting({"value": None}) is None
|
|
# A dict without a "value" key is returned unchanged.
|
|
assert unwrap_setting({"other": 1}) == {"other": 1}
|
|
assert unwrap_setting("raw") == "raw"
|
|
assert unwrap_setting(None) is None
|
|
|
|
|
|
def test_settings_utils_still_reexports_unwrap_setting():
|
|
# Backwards-compat: the function is still importable from its old home.
|
|
from local_deep_research.api.settings_utils import unwrap_setting
|
|
|
|
assert unwrap_setting({"value": "x"}) == "x"
|