集成旋转底座、机械臂示教与坐标系,完善扫描参数、电量和框架点复用。增加组合执行、步骤进度与日志,优化首屏和流程画布性能,修复表头主题适配,并保留验证脚本和回归测试。
44 lines
2.1 KiB
Python
44 lines
2.1 KiB
Python
"""Authenticated scanner parameter boundaries; never submits a device command."""
|
|
import json
|
|
from pathlib import Path
|
|
from verify_cmvr_native import Client, TargetReadOnlyDb, require
|
|
|
|
def run():
|
|
client = Client().login()
|
|
db = TargetReadOnlyDb(client)
|
|
cases = [
|
|
('defaults', {'pointDistance': .2, 'brightness': 8}, 200),
|
|
('lower bounds', {'pointDistance': .05, 'brightness': 1}, 200),
|
|
('upper bounds', {'pointDistance': 10, 'brightness': 18}, 200),
|
|
('brightness only', {'brightness': 8}, 200),
|
|
('distance only', {'pointDistance': .2}, 200),
|
|
('distance too small', {'pointDistance': .049}, 400),
|
|
('distance too large', {'pointDistance': 10.001}, 400),
|
|
('distance string', {'pointDistance': '0.2'}, 400),
|
|
('brightness zero', {'brightness': 0}, 400),
|
|
('brightness too large', {'brightness': 19}, 400),
|
|
('fractional brightness', {'brightness': 8.5}, 400),
|
|
('brightness string', {'brightness': '8'}, 400),
|
|
('empty object', {}, 400)
|
|
]
|
|
before = db.select('SELECT COUNT(*) n FROM lab_scanner_command')[0]['n']
|
|
results = []
|
|
try:
|
|
for name, body, expected in cases:
|
|
response = client.native('POST', '/scanner/validate', {
|
|
'operation': 'PARAMETERS', 'requestJson': json.dumps(body)
|
|
}, expected=None)
|
|
require(response.get('code') == expected, name + ': unexpected validation code ' + str(response.get('code')))
|
|
results.append({'name': name, 'code': expected, 'passed': True})
|
|
require(db.select('SELECT COUNT(*) n FROM lab_scanner_command')[0]['n'] == before,
|
|
'Validation created a scanner command')
|
|
finally:
|
|
db.close()
|
|
return {'passed': True, 'checks': results, 'deviceCommands': 0}
|
|
|
|
if __name__ == '__main__':
|
|
result = run()
|
|
path = Path(__file__).resolve().parents[1] / '.local/optimization-audit-parameters.json'
|
|
path.write_text(json.dumps(result, indent=2), encoding='utf-8')
|
|
print(json.dumps({'passed': True, 'checks': len(result['checks']), 'deviceCommands': 0}))
|