cmvr-visual/backend/tests/test_maintenance_admission.py

19 lines
916 B
Python

async def test_maintenance_intent_pauses_existing_upstream_queue_and_survives_toggles(system):
response=await system.client.post('/api/jobs',json={'task_type':'image.generate','input':{'prompt':'hold existing queue'}})
assert response.status_code==202
coordinator=system.app.state.coordinator
await coordinator.run_once(force=True)
controls=[]
async def control(id,desired,command_id):
controls.append((desired,command_id))
return dict(system.provider.remote[id])
system.provider.control=control
marker=system.settings.state_root/'maintenance'
for held in (True,False,True,False):
if held:marker.write_text('hold')
else:marker.unlink()
await coordinator.run_once(force=True)
assert [state for state,_ in controls]==['pause','run','pause','run']
assert len({key for _,key in controls})==4
assert len(system.provider.accepted)==1