fix(work): return approval state cards directly from callbacks
This commit is contained in:
@@ -101,7 +101,7 @@ async def pair(approval_env,tmp_path,monkeypatch):
|
||||
if 'business_receipt_lost'in faults:raise httpx.ReadTimeout('synthetic lost business response')
|
||||
return httpx.Response(200,json={'code':0,'data':{'event':{'event_id':'synthetic-event'}}})
|
||||
client=pc_broker.BrokerWorkClient(directory,transport=transport,api_transport=httpx.MockTransport(platform))
|
||||
task=e['store'].lifecycle.create_task('task-approval','ou_a',host,device['binding_generation'],
|
||||
task=e['store'].lifecycle.create_task(('msg_'+'a'*64),'ou_a',host,device['binding_generation'],
|
||||
'synthetic-session',e['app'].state.broker.worker_id,time.time()+600,'oc_synthetic','om_source')
|
||||
context={k:task[k]for k in ('environment','app_id','owner','host_id','binding_generation',
|
||||
'conversation_id','chat_id','source_message_id')}
|
||||
@@ -203,7 +203,7 @@ async def test_stop_binding_terminal_and_expiry_do_not_execute(pair,failure):
|
||||
(p['directory']/'device.json').write_text(json.dumps(value))
|
||||
elif failure=='terminal':
|
||||
with e['store'].db:e['store'].db.execute('INSERT INTO work_execution_state_v3 VALUES(?,?,?,?)',
|
||||
('task-approval','failed',1,time.time()))
|
||||
(('msg_'+'a'*64),'failed',1,time.time()))
|
||||
else:
|
||||
with e['store'].db:e['store'].db.execute('UPDATE work_approvals_v3 SET expires_at=0')
|
||||
if failure in {'terminal','expired'}:await p['click']()
|
||||
@@ -240,7 +240,7 @@ async def test_card_send_receipt_loss_never_sends_second_card(pair):
|
||||
|
||||
async def test_unsigned_rpc_proof_replay_and_other_task_are_rejected(pair):
|
||||
p=pair;job=p['launch']();row=await p['card']();e=p['env'];path='/work/v2/approvals/status'
|
||||
fields=dict(task_id='task-approval',approval_id=row['approval_id'],operation_digest=row['operation_digest'])
|
||||
fields=dict(task_id=('msg_'+'a'*64),approval_id=row['approval_id'],operation_digest=row['operation_digest'])
|
||||
unsigned=await e['client'].post(path,json=fields);assert unsigned.status_code==422
|
||||
signed=wire(e,path,**fields)
|
||||
assert (await e['client'].post(path,json=signed)).status_code==200
|
||||
@@ -279,7 +279,7 @@ async def test_conflicting_clicks_and_concurrent_consume_grant_at_most_once(pair
|
||||
assert response.json()['toast']['type']=='info'
|
||||
assert conflict.json()['toast']['type']=='warning'
|
||||
e=p['env'];path='/work/v2/approvals/consume'
|
||||
fields=dict(task_id='task-approval',approval_id=row['approval_id'],operation_digest=row['operation_digest'])
|
||||
fields=dict(task_id=('msg_'+'a'*64),approval_id=row['approval_id'],operation_digest=row['operation_digest'])
|
||||
responses=await asyncio.gather(*(e['client'].post(path,json=wire(e,path,**fields))for _ in range(2)))
|
||||
assert sum(r.json().get('execute')is True for r in responses)<=1
|
||||
try:result=await asyncio.wait_for(job,10)
|
||||
|
||||
Reference in New Issue
Block a user