test(cron): carry owner persistence repositories in merged fixtures
Main's scheduler and error-diagnostics stubs omitted the owner's sessions repository because it was unused before suppressed-run cleanup. Supply that production contract without changing the existing expectations.
This commit is contained in:
@@ -3,6 +3,8 @@ from types import SimpleNamespace
|
||||
|
||||
from cron import jobs, scheduler
|
||||
from gateway import session_cron
|
||||
from tests.fixtures.storage_seed import seed_session
|
||||
from tests.gateway.fixtures.storage_handles import close_storage_handles, storage_handle
|
||||
|
||||
|
||||
def test_run_error_persists_redacted_cause_but_returns_summary(tmp_path, monkeypatch):
|
||||
@@ -15,12 +17,15 @@ def test_run_error_persists_redacted_cause_but_returns_summary(tmp_path, monkeyp
|
||||
monkeypatch.setattr(scheduler, "_resolve_cron_agent_setup", fail_setup)
|
||||
with jobs.use_cron_store(tmp_path):
|
||||
job = jobs.create_job(prompt="Check status", schedule="every 1h", model="local-probe", deliver="local")
|
||||
owner = SimpleNamespace(db=SimpleNamespace(db_path=tmp_path / "state.db"))
|
||||
store = storage_handle(tmp_path)
|
||||
seed_session(store, "diagnostic-session", "cron")
|
||||
owner = SimpleNamespace(persistence=store)
|
||||
token = session_cron._execution.set((owner, "diagnostic-session", job["id"], "diagnostic-fire"))
|
||||
try:
|
||||
success, output, response, error = scheduler.run_job(job, execution_id="diagnostic-fire")
|
||||
finally:
|
||||
session_cron._execution.reset(token)
|
||||
assert store.sessions.get("diagnostic-session").end_reason == "cron_suppressed"
|
||||
saved = jobs.save_job_output(job["id"], output).read_text(encoding="utf-8")
|
||||
assert not success and response == "" and error == "RuntimeError: Connection error."
|
||||
assert "Traceback (most recent call last)" in saved and "fail_setup" in saved
|
||||
|
||||
@@ -41,7 +41,8 @@ def _run_owned_job(job, tmp_path, db=None):
|
||||
persistence = storage_handle(tmp_path)
|
||||
seed_session(persistence, ref.session_id, "cron")
|
||||
else:
|
||||
persistence = SimpleNamespace(scope=profile_scope(home=tmp_path), serves_same_store=lambda _store: True)
|
||||
persistence = SimpleNamespace(scope=profile_scope(home=tmp_path), serves_same_store=lambda _store: True,
|
||||
sessions=db.sessions)
|
||||
authority = SimpleNamespace(
|
||||
persistence=persistence,
|
||||
sessions={ref.session_id: SimpleNamespace(source=SimpleNamespace(user_id="cron-owner"))},
|
||||
|
||||
Reference in New Issue
Block a user