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>
31 lines
975 B
Python
31 lines
975 B
Python
# -*- coding: utf-8 -*-
|
|
from app.youtube_neko import parse_neko_ref
|
|
from app import yt_studio_db
|
|
|
|
|
|
def test_parse_neko_ref():
|
|
assert parse_neko_ref("ops-1") == ("remote", "ops:1", 0)
|
|
assert parse_neko_ref("ops:2") == ("remote", "ops:2", 0)
|
|
assert parse_neko_ref("5") == ("local", "local:5", 5)
|
|
assert parse_neko_ref("") == ("local", "", 0)
|
|
|
|
|
|
def test_insert_sample_roundtrip(tmp_path, monkeypatch):
|
|
# Use real DB — just insert and list
|
|
row = yt_studio_db.insert_sample(
|
|
group_id="g1",
|
|
youtube_channel_id="UC123",
|
|
source_room_id="room9",
|
|
neko_kind="remote",
|
|
neko_ref="ops:1",
|
|
on_air=True,
|
|
live_page_open=True,
|
|
viewer_count=12,
|
|
total_views=100,
|
|
peak_viewers=12,
|
|
)
|
|
assert row.get("group_id") == "g1"
|
|
assert row.get("neko_kind") == "remote"
|
|
rows = yt_studio_db.list_samples(group_id="g1", limit=5)
|
|
assert any(r.get("id") == row.get("id") for r in rows)
|