# -*- coding: utf-8 -*- from __future__ import annotations import time from app.timeutil import push_date_from_ts def test_reconcile_false_failed_shorts(temp_db): ch = temp_db.create_shorts_channel(name="F", enabled=True) day = push_date_from_ts(time.time()) job = temp_db.create_shorts_job( session_id="", room_id="r-false-fail", channel_pk=ch["id"], push_date=day, ) temp_db.update_shorts_job( job["id"], status="failed", youtube_video_id="abc123", youtube_url="https://www.youtube.com/shorts/abc123", error="[Errno 2] No such file", finished_at=time.time(), ) fixed = temp_db.reconcile_false_failed_shorts() assert fixed == 1 updated = temp_db.get_shorts_job(job["id"]) assert updated["status"] == "uploaded" assert updated["error"] == "" def test_reconcile_missing_shorts_clips(temp_db): ch = temp_db.create_shorts_channel(name="M", enabled=True) day = push_date_from_ts(time.time()) job = temp_db.create_shorts_job( session_id="", room_id="r-miss", channel_pk=ch["id"], push_date=day, ) temp_db.update_shorts_job( job["id"], status="scheduled", clip_path="/tmp/does-not-exist-clip.mp4", upload_at=time.time() + 60, ) fixed = temp_db.reconcile_missing_shorts_clips() assert fixed == 1 updated = temp_db.get_shorts_job(job["id"]) assert updated["status"] == "pending" assert updated["clip_path"] == "" assert "丢失" in str(updated["error"])