cmvr-visual/backend/tests/test_workflow_output_contract.py

29 lines
1.3 KiB
Python
Raw Normal View History

from types import SimpleNamespace
from unittest.mock import AsyncMock
from sqlalchemy import select
from app.models import Job
async def test_workflow_imports_only_final_enhanced_output(system, monkeypatch):
response = await system.client.post('/api/jobs', json={
'task_type':'video.generate','input':{'prompt':'three-shot source'},'parameters':{}},
headers={'Idempotency-Key':'dual-stage-output'})
assert response.status_code == 202
job_id=response.json()['jobs'][0]['id']
async with system.app.state.db.session() as session:
job=await session.get(Job,job_id)
job.run_id='run';job.step_key='shot_1';job.upstream_id='gpu-result'
job.upstream_result={'outputs':[{'path':'native.mp4'},{'path':'enhanced.mp4'}],
'metadata':{'final_output_indices':[1]}}
await session.commit()
imported=[]
async def import_one(db,settings,job,path,index,**kwargs):
imported.append(index)
return SimpleNamespace(kind='video')
monkeypatch.setattr('app.coordinator.import_output',import_one)
coordinator=system.app.state.coordinator
monkeypatch.setattr(coordinator,'_complete',AsyncMock())
await coordinator._collect_gpu(job)
assert imported==[1]
assert system.provider.download_count==1