40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import time
|
|
|
|
from app.timeutil import push_date_from_ts
|
|
|
|
|
|
def test_claim_manual_upload_from_scheduled(temp_db):
|
|
ch = temp_db.create_shorts_channel(name="U", enabled=True)
|
|
day = push_date_from_ts(time.time())
|
|
job = temp_db.create_shorts_job(
|
|
session_id="",
|
|
room_id="r1",
|
|
channel_pk=ch["id"],
|
|
push_date=day,
|
|
)
|
|
temp_db.update_shorts_job(
|
|
job["id"],
|
|
status="scheduled",
|
|
clip_path="/tmp/fake.mp4",
|
|
upload_at=time.time() + 3600,
|
|
)
|
|
claimed = temp_db.claim_shorts_job_manual_upload(job["id"])
|
|
assert claimed is not None
|
|
assert claimed["status"] == "uploading"
|
|
assert float(claimed["upload_at"]) <= time.time() + 1
|
|
|
|
|
|
def test_claim_manual_upload_rejects_pending(temp_db):
|
|
ch = temp_db.create_shorts_channel(name="U", enabled=True)
|
|
day = push_date_from_ts(time.time())
|
|
job = temp_db.create_shorts_job(
|
|
session_id="",
|
|
room_id="r1",
|
|
channel_pk=ch["id"],
|
|
push_date=day,
|
|
)
|
|
assert temp_db.claim_shorts_job_manual_upload(job["id"]) is None
|