Operator-saved defaults and apply-all now persist; API-limited mode only clamps channels above the effective cap. Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
"""Global daily quota defaults for Shorts / TikTok."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from app import db
|
|
|
|
|
|
def test_shorts_quota_defaults_roundtrip(temp_db):
|
|
out = db.set_shorts_quota_defaults(daily_min=7, daily_max=12, apply_all=False)
|
|
assert out["daily_min"] == 7
|
|
assert out["daily_max"] == 12
|
|
assert db.shorts_quota_defaults() == {"daily_min": 7, "daily_max": 12}
|
|
|
|
|
|
def test_shorts_quota_apply_all_channels(temp_db):
|
|
db.set_shorts_quota_defaults(daily_min=5, daily_max=8, apply_all=False)
|
|
a = db.create_shorts_channel(name="A", daily_min=9, daily_max=9)
|
|
b = db.create_shorts_channel(name="B", enabled=False, daily_min=9, daily_max=9)
|
|
out = db.set_shorts_quota_defaults(daily_min=6, daily_max=11, apply_all=True, enabled_only=True)
|
|
assert out["updated_channels"] >= 1
|
|
a2 = db.get_shorts_channel(a["id"])
|
|
b2 = db.get_shorts_channel(b["id"])
|
|
assert int(a2["daily_min"]) == 6 and int(a2["daily_max"]) == 11
|
|
# disabled channel untouched when enabled_only
|
|
assert int(b2["daily_min"]) == 9
|
|
|
|
|
|
def test_tiktok_quota_defaults_clamp(temp_db):
|
|
out = db.set_tiktok_quota_defaults(daily_min=40, daily_max=1, apply_all=False)
|
|
assert out["daily_min"] == 30
|
|
assert out["daily_max"] == 30
|
|
|
|
|
|
def test_yt_long_reconcile_respects_saved_channel_daily_max(temp_db):
|
|
from app import yt_long_db
|
|
|
|
db.update_settings_map({"yt_long_channel_daily_max": 9, "yt_long_quota_limited_day": ""})
|
|
yt_long_db.reconcile_yt_long_upload_caps()
|
|
assert yt_long_db.yt_long_channel_daily_max() == 9
|
|
assert yt_long_db.effective_yt_long_channel_daily_max() == 9
|