完善扫描成果与比对资料管理,精简业务菜单和任务工作台,更新批量导入模板。 适配机械臂新协议、坐标系管理及目标位姿组件,增加扫描参数字典和角色自动分配。 修复试运行终止状态与过期扫描任务资源释放,补充回归测试、迁移脚本及接口文档。
53 lines
4.7 KiB
Python
53 lines
4.7 KiB
Python
"""Dev HTTP association test. Uses only read-only arm listing, never power/record/motion APIs."""
|
|
from pathlib import Path
|
|
import json,sys,datetime,uuid
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0,str(ROOT/'scripts'))
|
|
from verify_cmvr_native import Client,TargetReadOnlyDb
|
|
from cleanup_verification import cleanup
|
|
def run():
|
|
c=Client().login();db=TargetReadOnlyDb(c);checks=[]
|
|
prefix='E2E-FIXTURE-TRAJECTORY-'+datetime.datetime.now().strftime('%Y%m%d%H%M%S')+'-'+uuid.uuid4().hex[:4]
|
|
baseline=list(db.select('SELECT id FROM lab_fixture_trajectory ORDER BY id'))
|
|
leases=list(db.select('SELECT owner_key,resource_key,status FROM lab_resource_occupation WHERE deleted=0 ORDER BY resource_key'))
|
|
base='/admin-api/lab/master/fixture';fixture=None
|
|
def check(name,condition):
|
|
if not condition:raise AssertionError(name)
|
|
checks.append(name)
|
|
try:
|
|
fixture=c.request('POST',base+'/create',body={'fixtureCode':prefix,'fixtureName':prefix,'status':'ENABLED'})['data']
|
|
current=lambda:c.request('GET',base+'/trajectory/get',query={'fixtureId':fixture})['data']
|
|
check('new fixture has no association',not current()['current'])
|
|
missing=c.request('GET',base+'/trajectory/get',query={'fixtureId':-1},expected=None)
|
|
check('missing fixture rejected',missing.get('code') not in (0,200))
|
|
listed=c.request('GET','/admin-api/cmvr/api/arm/teaching/listRecordedTrajectories',query={'robotId':'AIMA-20261026-003','deviceId':'aubo_arm'},expected=None)
|
|
candidates=(listed.get('data') or {}).get('trajectories') or []
|
|
if listed.get('code') not in (0,200) or not candidates:raise AssertionError('No read-only real arm trajectory available; preserve diagnostics')
|
|
selected=candidates[0]
|
|
body={'fixtureId':fixture,'expectedVersion':None,'robotId':'AIMA-20261026-003','deviceId':'aubo_arm','fileName':selected['fileName']}
|
|
first=c.request('POST',base+'/trajectory/bind',body=body)['data']
|
|
data=current();check('binding stores chosen arm and file',data['current']['id']==first and data['current']['robotId']==body['robotId'] and data['current']['deviceId']==body['deviceId'] and data['current']['fileName']==body['fileName'])
|
|
check('server sample count preserved',str(data['current']['samples'])==str(selected['samples']))
|
|
body['expectedVersion']=first
|
|
check('same association is idempotent',c.request('POST',base+'/trajectory/bind',body=body)['data']==first and len(current()['history'])==1)
|
|
stale=c.request('POST',base+'/trajectory/unbind',body={'fixtureId':fixture,'expectedVersion':'stale'},expected=None)
|
|
check('stale unlink rejected',stale.get('code') not in (0,200) and current()['current']['id']==first)
|
|
invalid=c.request('POST',base+'/trajectory/bind',body={**body,'fileName':prefix+'.csv'},expected=None)
|
|
check('missing remote file does not replace current',invalid.get('code') not in (0,200) and current()['current']['id']==first)
|
|
page=c.request('GET',base+'/page',query={'pageNo':1,'pageSize':10,'fixtureCode':prefix})['data']['list']
|
|
check('fixture list shows association summary',len(page)==1 and page[0]['trajectoryStatus']=='LINKED' and page[0]['trajectoryFileName']==body['fileName'])
|
|
c.request('POST',base+'/trajectory/unbind',body={'fixtureId':fixture,'expectedVersion':first})
|
|
data=current();check('unlink retains history',not data['current'] and len(data['history'])==1 and data['history'][0]['status']=='UNLINKED')
|
|
body['expectedVersion']=None;second=c.request('POST',base+'/trajectory/bind',body=body)['data']
|
|
check('relink creates next version',second!=first and current()['current']['versionNo']==2 and len(current()['history'])==2)
|
|
check('no new device occupation',leases==list(db.select('SELECT owner_key,resource_key,status FROM lab_resource_occupation WHERE deleted=0 ORDER BY resource_key')))
|
|
result=cleanup([prefix],apply=True)
|
|
check('temporary fixture and associations removed',not db.select('SELECT id FROM lab_fixture WHERE fixture_code=%s',(prefix,)) and not db.select('SELECT id FROM lab_fixture_trajectory WHERE fixture_id=%s',(fixture,)))
|
|
check('customer association rows preserved',baseline==list(db.select('SELECT id FROM lab_fixture_trajectory ORDER BY id')))
|
|
report={'success':True,'prefix':prefix,'passed':len(checks),'checks':checks,'edgeCalls':'ListRecordedTrajectories only','powerRecordingMotionCommands':0,'cleanup':result}
|
|
(ROOT/'.local/fixture-trajectory-http.json').write_text(json.dumps(report,ensure_ascii=False,indent=2,default=str),encoding='utf-8')
|
|
print(json.dumps({'passed':len(checks),'temporaryDataRemoved':True,'powerRecordingMotionCommands':0}))
|
|
except Exception as e:
|
|
(ROOT/'.local/fixture-trajectory-http.json').write_text(json.dumps({'success':False,'prefix':prefix,'fixtureId':fixture,'checks':checks,'error':str(e)},ensure_ascii=False,indent=2),encoding='utf-8');raise
|
|
if __name__=='__main__':run()
|