Coverage for src/local_deep_research/settings/env_definitions/testing.py: 100%
8 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-06 15:42 +0000
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-06 15:42 +0000
1"""
2Testing and CI environment settings.
4These settings control test mode behavior and CI/testing flags.
5"""
7import os
8from ..env_settings import BooleanSetting
11# External environment variables (not LDR-prefixed, set by external systems)
12# These are read directly since we don't control them
13CI = os.environ.get("CI", "false").lower() in ("true", "1", "yes")
14GITHUB_ACTIONS = os.environ.get("GITHUB_ACTIONS", "false").lower() in (
15 "true",
16 "1",
17 "yes",
18)
19TESTING = os.environ.get("TESTING", "false").lower() in ("true", "1", "yes")
22def testing_with_mocks() -> bool:
23 """True when the suite is in mock-only mode and must not touch the network.
25 ``tests/conftest.py`` defaults ``LDR_TESTING_WITH_MOCKS`` to ``"true"`` for
26 the whole run; the dedicated journal-data-integration workflow sets it to
27 ``"false"`` to opt into live network.
29 A **function**, not a module-level constant like ``CI`` / ``TESTING``
30 above, and that difference is load-bearing: those freeze at import, whereas
31 this is read by call sites that tests toggle with ``monkeypatch.setenv``
32 after import. A constant here would silently ignore the toggle.
34 It lives in this subtree rather than next to its callers because
35 ``.pre-commit-hooks/check-env-vars.py`` requires ``LDR_*`` variables to be
36 read through the settings layer, and it cannot go through
37 ``SettingsManager`` itself -- one of its callers is the guard on *opening
38 the settings database*, so consulting settings to answer it is circular.
40 Unset (production) reads false, so no production path is gated.
41 """
42 return os.environ.get("LDR_TESTING_WITH_MOCKS", "").lower() == "true"
45# LDR Testing settings (our application's test configuration)
46TESTING_SETTINGS = [
47 BooleanSetting(
48 key="testing.test_mode",
49 description="Enable test mode (adds delays for testing concurrency)",
50 default=False,
51 ),
52]