限制待收听留言周期提醒来源

This commit is contained in:
stu2not
2026-05-27 17:14:55 +08:00
parent 1b75435a3c
commit eebc5a14d8
2 changed files with 22 additions and 10 deletions

View File

@@ -87,13 +87,28 @@ async def test_scheduler_sends_pending_notice_without_websocket_check(monkeypatc
calls.append(target_device_id)
return True
class FakeOfflineAudioCache:
async def get_all_audio_cache(self):
return {}
monkeypatch.setattr("services.scheduler.pending_voice_message_service", FakePendingVoiceService())
monkeypatch.setattr("services.scheduler.offline_audio_cache", FakeOfflineAudioCache())
await scheduler._execute_task()
assert calls == ["TalkingQ_device001"]
@pytest.mark.asyncio
async def test_scheduler_skips_notice_when_no_pending_messages(monkeypatch):
scheduler = TaskScheduler()
calls = []
class FakePendingVoiceService:
async def list_devices_with_pending(self):
return []
async def notify_device_pending_message(self, *, target_device_id):
calls.append(target_device_id)
return True
monkeypatch.setattr("services.scheduler.pending_voice_message_service", FakePendingVoiceService())
await scheduler._execute_task()
assert calls == []