feat(memory): protect Dream cron and polish migration UX

This commit is contained in:
Xubin Ren
2026-04-04 09:01:42 +00:00
parent 6e896249c8
commit 408a61b0e1
4 changed files with 86 additions and 8 deletions
+16 -1
View File
@@ -4,7 +4,7 @@ import json
import pytest
from nanobot.cron.service import CronService
from nanobot.cron.types import CronSchedule
from nanobot.cron.types import CronJob, CronPayload, CronSchedule
def test_add_job_rejects_unknown_timezone(tmp_path) -> None:
@@ -141,3 +141,18 @@ async def test_running_service_honors_external_disable(tmp_path) -> None:
assert called == []
finally:
service.stop()
def test_remove_job_refuses_system_jobs(tmp_path) -> None:
service = CronService(tmp_path / "cron" / "jobs.json")
service.register_system_job(CronJob(
id="dream",
name="dream",
schedule=CronSchedule(kind="cron", expr="0 */2 * * *", tz="UTC"),
payload=CronPayload(kind="system_event"),
))
result = service.remove_job("dream")
assert result == "protected"
assert service.get_job("dream") is not None