# -*- coding: utf-8 -*- from __future__ import annotations import time from pathlib import Path from app.timeutil import push_date_from_ts def test_clip_ready_enrichment_via_path(temp_db, tmp_path): ch = temp_db.create_shorts_channel(name="P", enabled=True) day = push_date_from_ts(time.time()) job = temp_db.create_shorts_job( session_id="", room_id="r-prev", channel_pk=ch["id"], push_date=day, ) clip = tmp_path / f"{job['id']}.mp4" clip.write_bytes(b"0" * 60_000) temp_db.update_shorts_job(job["id"], status="scheduled", clip_path=str(clip), upload_at=time.time() + 60) updated = temp_db.get_shorts_job(job["id"]) assert Path(updated["clip_path"]).is_file() missing = temp_db.reconcile_missing_shorts_clips() assert missing == 0 def test_bulk_retry_requeues_failed(temp_db): ch = temp_db.create_shorts_channel(name="B", enabled=True) day = push_date_from_ts(time.time()) job = temp_db.create_shorts_job( session_id="", room_id="r-bulk", channel_pk=ch["id"], push_date=day, ) temp_db.update_shorts_job(job["id"], status="failed", error="boom", finished_at=time.time()) # Simulate retry helper path: no clip → pending temp_db.update_shorts_job( job["id"], status="pending", clip_path="", error="", finished_at=0, upload_at=0, ) updated = temp_db.get_shorts_job(job["id"]) assert updated["status"] == "pending"