Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
test(cron): add regression test for running service picking up external adds
Xubin Ren423aab09ddc5
diff --git a/tests/cron/test_cron_service.py b/tests/cron/test_cron_service.pyindex 4c19580f8..8606e4f58 100644--- a/tests/cron/test_cron_service.py+++ b/tests/cron/test_cron_service.py@@ -176,3 +176,35 @@ def test_reload_jobs(tmp_path):message="hello2",)assert len(service.list_jobs()) == 2+++async def test_running_service_picks_up_external_add(tmp_path):+ """A running service should detect and execute a job added by another instance."""+ store_path = tmp_path / "cron" / "jobs.json"+ called: list[str] = []++ async def on_job(job):+ called.append(job.name)++ service = CronService(store_path, on_job=on_job)+ service.add_job(+ name="heartbeat",+ schedule=CronSchedule(kind="every", every_ms=150),+ message="tick",+ )+ await service.start()+ try:+ await asyncio.sleep(0.05)++ external = CronService(store_path)+ external.add_job(+ name="external",+ schedule=CronSchedule(kind="every", every_ms=150),+ message="ping",+ )++ await asyncio.sleep(0.6)+ assert "external" in called+ finally:+ service.stop()