diff --git a/cron/suggestions.py b/cron/suggestions.py index 85d2db49ef..afbd44dbda 100644 --- a/cron/suggestions.py +++ b/cron/suggestions.py @@ -46,11 +46,10 @@ logger = logging.getLogger(__name__) # profile's cron store. Anchor on get_hermes_home() (profile home), not the # shared default root. See cron/jobs.py for the full rationale. # -# Optional test overrides. Production resolves the path at call time so +# Optional test override. Production resolves the path at call time so # multiplexed profile ticks (set_hermes_home_override) cannot leak one # profile's suggestions into the import-time home (#86519). Same pattern as # cron/executions.py. -CRON_DIR: Optional[Path] = None SUGGESTIONS_FILE: Optional[Path] = None diff --git a/tests/cron/test_suggestions.py b/tests/cron/test_suggestions.py index d0be3c666c..3abaf54d31 100644 --- a/tests/cron/test_suggestions.py +++ b/tests/cron/test_suggestions.py @@ -37,6 +37,26 @@ def _add(store, key="k1", title="Test", source="catalog", schedule="0 9 * * *"): class TestStore: + def test_explicit_file_override_wins_over_profile_home(self, tmp_path, monkeypatch): + from hermes_constants import ( + reset_hermes_home_override, + set_hermes_home_override, + ) + import cron.suggestions as suggestions_mod + + explicit_file = tmp_path / "explicit" / "suggestions.json" + profile_home = tmp_path / "profile" + monkeypatch.setattr(suggestions_mod, "SUGGESTIONS_FILE", explicit_file) + + token = set_hermes_home_override(profile_home) + try: + _add(suggestions_mod, key="explicit-file") + finally: + reset_hermes_home_override(token) + + assert explicit_file.exists() + assert not (profile_home / "cron" / "suggestions.json").exists() + def test_profile_override_routes_writes_to_current_home(self, tmp_path): from hermes_constants import ( reset_hermes_home_override,