feat: 迁移商务工作台指标和仪表盘榜单
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
"""真实会话只读验证工作台接口与缺表提示,不制造实际商务数据。"""
|
||||
import argparse
|
||||
import json
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--base-url', default='http://127.0.0.1:18000')
|
||||
parser.add_argument('--token-file', required=True, type=Path)
|
||||
parser.add_argument('--output', required=True, type=Path)
|
||||
args = parser.parse_args()
|
||||
token = args.token_file.read_text(encoding='utf-8').strip()
|
||||
checks = []
|
||||
for endpoint in ['summary', 'registerTop', 'payRank', 'unloginTop']:
|
||||
cases = [('', 7), ('sourceDbList=lx,hw,yq', 0 if endpoint == 'summary' else 7)]
|
||||
if endpoint in ['registerTop', 'payRank']:
|
||||
cases.append(('sourceDbList=lx&period=invalid', 7))
|
||||
if endpoint == 'payRank':
|
||||
cases.append(('sourceDbList=lx,hw,yq&order=asc&period=last30', 7))
|
||||
for query, expected in cases:
|
||||
path = '/sw/workbench/' + endpoint + '?' + query
|
||||
req = urllib.request.Request(args.base_url + path, headers={'x-token': token})
|
||||
with urllib.request.urlopen(req, timeout=30) as response:
|
||||
payload = json.load(response)
|
||||
item = {'path': path, 'http': response.status, 'code': payload.get('code'), 'msg': payload.get('msg'), 'passed': payload.get('code') == expected}
|
||||
if endpoint == 'summary' and expected == 0:
|
||||
data = payload.get('data', {})
|
||||
item['available'] = data.get('available')
|
||||
item['passed'] &= data.get('available') is False and all(data.get(key, {}).get('value') is None for key in ['todayRegister', 'todayActive', 'todayPay', 'monthPay', 'activePromote', 'newPromote'])
|
||||
checks.append(item)
|
||||
report = {'scope': '真实 sw7 会话;当前缺业务表,只读验证输入与未接入提示。正向六卡、榜单与权限通过隔离 TCP HTTP 测试。', 'checks': checks, 'passed': all(item['passed'] for item in checks)}
|
||||
args.output.write_text(json.dumps(report, ensure_ascii=False, indent=2) + '\n', encoding='utf-8')
|
||||
print(json.dumps(report, ensure_ascii=False))
|
||||
if not report['passed']:
|
||||
raise SystemExit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user