Tighten http/youtubei live probes, classify Studio encoder_lost vs waiting, and keep dy/dylive public live counts aligned via edge assign_lives. Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""time_slot source pick must skip offline sticky rooms."""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
|
|
def test_pick_source_excludes_sticky_offline(monkeypatch):
|
|
from app import youtube_relay_pipeline as yrp
|
|
|
|
rooms = [
|
|
{"room_id": "111", "url": "https://live.douyin.com/111", "last_anchor": "A"},
|
|
{"room_id": "222", "url": "https://live.douyin.com/222", "last_anchor": "B"},
|
|
{"room_id": "333", "url": "https://live.douyin.com/333", "last_anchor": "C"},
|
|
]
|
|
monkeypatch.setattr(yrp.db, "list_live_douyin_rooms_for_shorts", lambda limit=40: rooms)
|
|
monkeypatch.setattr(yrp, "_group_in_active_slot", lambda gid, keyed_only=False: True)
|
|
monkeypatch.setattr(yrp, "_group_uses_time_slot", lambda g: True)
|
|
|
|
group: dict[str, Any] = {"id": "g1", "enabled": 1, "category": "time_slot"}
|
|
|
|
sticky = yrp.pick_source_for_group(group, prefer_room_id="111")
|
|
assert sticky and sticky["room_id"] == "111"
|
|
|
|
rotated = yrp.pick_source_for_group(
|
|
group,
|
|
prefer_room_id="111",
|
|
exclude_room_ids={"111"},
|
|
)
|
|
assert rotated and rotated["room_id"] == "222"
|
|
|
|
cleared = yrp.pick_source_for_group(
|
|
group,
|
|
prefer_room_id="",
|
|
exclude_room_ids={"111", "222"},
|
|
)
|
|
assert cleared and cleared["room_id"] == "333"
|