"""tag_and_embed (embed-only) / backfill task tests. The pure _is_video helper is a unit test; the DB-touching backfill query is an integration test with monkeypatched dispatch.""" from pathlib import Path import pytest from backend.app.tasks.ml import _is_video def test_is_video(): assert _is_video(Path("a.mp4")) is True assert _is_video(Path("a.MKV")) is True assert _is_video(Path("a.jpg")) is False @pytest.mark.integration @pytest.mark.asyncio async def test_backfill_enqueues_missing(db, monkeypatch): from backend.app.models import ImageRecord from backend.app.tasks import ml as ml_tasks calls = [] monkeypatch.setattr( ml_tasks.tag_and_embed, "delay", lambda image_id: calls.append(image_id) ) img = ImageRecord( path="/images/n.jpg", sha256="n" * 64, size_bytes=1, mime="image/jpeg", width=1, height=1, origin="imported_filesystem", integrity_status="unknown", siglip_embedding=None, ) db.add(img) await db.commit() count = ml_tasks.backfill() assert count >= 1 assert img.id in calls