douyinWEB/backend/tests/test_cdp_poll_running_disabled.py
2026-09-13 22:10:49 -05:00

25 lines
764 B
Python

#!/usr/bin/env python3
"""Unit: CDP poll includes running-but-disabled Nekos."""
from __future__ import annotations
from app import youtube_neko as yn
from app import yt_assign_db
def test_cdp_poll_ids_include_running_disabled(monkeypatch):
groups = [
{"neko_enabled": True, "neko_instance_id": 1},
{"neko_enabled": False, "neko_instance_id": 6},
{"neko_enabled": False, "neko_instance_id": 9},
]
def fake_state(nid, check_http=False):
return {"running": nid == 6}
monkeypatch.setattr(yt_assign_db, "list_groups", lambda include_urls=False: groups)
monkeypatch.setattr(yn, "_container_state", fake_state)
ids = yn._neko_ids_for_cdp_poll()
assert 1 in ids
assert 6 in ids
assert 9 not in ids