Files
siftlode/backend/tests/test_my_status_deep.py
peter 238e6f8a61 refactor(catalog): the unit's tables move into catalog/models
Channel, Subscription, Video, SearchFind, ExploredChannel and BlockedChannel (and LIVE_OR_UPCOMING)
leave app/models.py for app/catalog/models.py; app.tables registers them. The User↔Subscription
relationship names its other side as a type only. No schema change.
2026-10-19 02:03:14 +02:00

34 lines
1.6 KiB
Python

"""The Stats page's "Full history: done / requested" ratio counts the SAME channels on both sides — the
ones this user asked full history for. The numerator used to count every subscribed channel whose
back-catalog was complete (another user had asked, or the channel was short), so the page read
"342/329". "Channels without full history yet" still counts every subscribed channel. Needs the DB."""
from app.catalog.models import Channel, Subscription
def test_full_history_ratio_counts_only_the_requested_channels(db, make_user, as_user):
user = make_user("deep@example.com")
db.add_all(
[
Channel(id="UCreqdone", title="Requested, done", backfill_done=True),
Channel(id="UCreqopen", title="Requested, pending", backfill_done=False),
Channel(id="UCdone", title="Not requested, done anyway", backfill_done=True),
Channel(id="UCopen", title="Not requested, pending", backfill_done=False),
]
)
db.flush()
db.add_all(
[
Subscription(user_id=user.id, channel_id="UCreqdone", deep_requested=True),
Subscription(user_id=user.id, channel_id="UCreqopen", deep_requested=True),
Subscription(user_id=user.id, channel_id="UCdone"),
Subscription(user_id=user.id, channel_id="UCopen"),
]
)
db.commit()
body = as_user(user).get("/api/sync/my-status").json()
assert body["channels_deep_requested"] == 2
assert body["channels_deep_done"] == 1 # never more than it is out of
assert body["channels_deep_pending"] == 2 # subscribed channels without full history yet